diff --git a/client/client/src/address-edit/address-edit.js b/client/client/src/address-edit/address-edit.js index 3046b2733..ef20f68f1 100644 --- a/client/client/src/address-edit/address-edit.js +++ b/client/client/src/address-edit/address-edit.js @@ -66,8 +66,8 @@ export default class Controller { submit() { this._unsetDirtyForm(); - let submitWatcher = this.$scope.watcher.dataChanged(); - let submitObservations; + let canWatcherSubmit = this.$scope.watcher.dataChanged(); + let canObservationsSubmit; let repeatedTypes = false; let types = []; 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) { this.vnApp.showMessage( this.$translate.instant('The observation type must be unique') ); - } else if (submitWatcher && !submitObservations) { + } else if (canWatcherSubmit && !canObservationsSubmit) { this.$scope.watcher.submit().then(() => { this.$state.go('clientCard.addresses.list', {id: this.$state.params.id}); }); - } else if (!submitWatcher && submitObservations) { + } else if (!canWatcherSubmit && canObservationsSubmit) { this._submitObservations(observationsObj).then(() => { 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.$state.go('clientCard.addresses.list', {id: this.$state.params.id}); });