semantic refactor
This commit is contained in:
parent
4aa2d2a255
commit
21cc4e3320
|
@ -66,8 +66,8 @@ export default class Controller {
|
||||||
|
|
||||||
submit() {
|
submit() {
|
||||||
this._unsetDirtyForm();
|
this._unsetDirtyForm();
|
||||||
let submitWatcher = this.$scope.watcher.dataChanged();
|
let canWatcherSubmit = this.$scope.watcher.dataChanged();
|
||||||
let submitObservations;
|
let canObservationsSubmit;
|
||||||
let repeatedTypes = false;
|
let repeatedTypes = false;
|
||||||
let types = [];
|
let types = [];
|
||||||
let observationsObj = {
|
let observationsObj = {
|
||||||
|
@ -95,21 +95,21 @@ export default class Controller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
submitObservations = observationsObj.update.length > 0 || observationsObj.create.length > 0 || observationsObj.delete.length > 0;
|
canObservationsSubmit = observationsObj.update.length > 0 || observationsObj.create.length > 0 || observationsObj.delete.length > 0;
|
||||||
|
|
||||||
if (repeatedTypes) {
|
if (repeatedTypes) {
|
||||||
this.vnApp.showMessage(
|
this.vnApp.showMessage(
|
||||||
this.$translate.instant('The observation type must be unique')
|
this.$translate.instant('The observation type must be unique')
|
||||||
);
|
);
|
||||||
} else if (submitWatcher && !submitObservations) {
|
} else if (canWatcherSubmit && !canObservationsSubmit) {
|
||||||
this.$scope.watcher.submit().then(() => {
|
this.$scope.watcher.submit().then(() => {
|
||||||
this.$state.go('clientCard.addresses.list', {id: this.$state.params.id});
|
this.$state.go('clientCard.addresses.list', {id: this.$state.params.id});
|
||||||
});
|
});
|
||||||
} else if (!submitWatcher && submitObservations) {
|
} else if (!canWatcherSubmit && canObservationsSubmit) {
|
||||||
this._submitObservations(observationsObj).then(() => {
|
this._submitObservations(observationsObj).then(() => {
|
||||||
this.$state.go('clientCard.addresses.list', {id: this.$state.params.id});
|
this.$state.go('clientCard.addresses.list', {id: this.$state.params.id});
|
||||||
});
|
});
|
||||||
} else if (submitWatcher && submitObservations) {
|
} else if (canWatcherSubmit && canObservationsSubmit) {
|
||||||
this.$q.all([this.$scope.watcher.submit(), this._submitObservations(observationsObj)]).then(() => {
|
this.$q.all([this.$scope.watcher.submit(), this._submitObservations(observationsObj)]).then(() => {
|
||||||
this.$state.go('clientCard.addresses.list', {id: this.$state.params.id});
|
this.$state.go('clientCard.addresses.list', {id: this.$state.params.id});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue