From 945a1b30493b50aabf65826d89f9f33c8536f10a Mon Sep 17 00:00:00 2001 From: Carlos Jimenez <=> Date: Fri, 16 Mar 2018 15:08:36 +0100 Subject: [PATCH] corrected bug on all htmls using crud --- .../client/src/address-edit/address-edit.html | 8 ++++ .../client/src/address-edit/address-edit.js | 38 +++++++++++-------- .../src/components/textfield/textfield.html | 6 +-- client/item/src/barcode/item-barcode.js | 3 ++ client/item/src/niche/item-niche.html | 12 +++++- client/item/src/niche/item-niche.js | 3 ++ client/item/src/tags/item-tags.html | 8 ++++ 7 files changed, 57 insertions(+), 21 deletions(-) diff --git a/client/client/src/address-edit/address-edit.html b/client/client/src/address-edit/address-edit.html index ba83368eb..cc50c1060 100644 --- a/client/client/src/address-edit/address-edit.html +++ b/client/client/src/address-edit/address-edit.html @@ -54,6 +54,7 @@ + + 0 || observationsObj.create.length > 0 || observationsObj.delete.length > 0; + canSubmitObservations = 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 (canWatcherSubmit && !canObservationsSubmit) { + } else if (canSubmitWatcher && !canSubmitObservations) { this.$scope.watcher.submit().then(() => { this.$state.go('clientCard.addresses.list', {id: this.$state.params.id}); }); - } else if (!canWatcherSubmit && canObservationsSubmit) { + } else if (!canSubmitWatcher && canSubmitObservations) { this._submitObservations(observationsObj).then(() => { this.$state.go('clientCard.addresses.list', {id: this.$state.params.id}); }); - } else if (canWatcherSubmit && canObservationsSubmit) { + } else if (canSubmitWatcher && canSubmitObservations) { this.$q.all([this.$scope.watcher.submit(), this._submitObservations(observationsObj)]).then(() => { this.$state.go('clientCard.addresses.list', {id: this.$state.params.id}); }); @@ -113,7 +115,7 @@ export default class Controller { this._unsetDirtyForm(); } - $onInit() { + _getAddressNotes() { let filter = { where: {addressFk: this.address.id}, include: {relation: 'observationType'} @@ -121,10 +123,14 @@ export default class Controller { this.$http.get(`/client/api/AddressObservations?filter=${JSON.stringify(filter)}`).then(res => { this.observations = res.data; res.data.forEach(item => { - this.observationsOld[item.id] = Object.assign({}, item); + this.oldObservations[item.id] = Object.assign({}, item); }); }); } + + $onInit() { + this._getAddressNotes(); + } } Controller.$inject = ['$state', '$scope', '$http', '$q', '$translate', 'vnApp']; diff --git a/client/core/src/components/textfield/textfield.html b/client/core/src/components/textfield/textfield.html index 43599186b..7f39ccf64 100644 --- a/client/core/src/components/textfield/textfield.html +++ b/client/core/src/components/textfield/textfield.html @@ -1,8 +1,8 @@ -
- + ng-blur="$ctrl.hasFocus = false"/>
{ @@ -30,11 +31,13 @@ export default class Controller { this.$scope.form.$setDirty(); } } + _unsetDirtyForm() { if (this.$scope.form) { this.$scope.form.$setPristine(); } } + _equalBarcodes(oldBarcode, newBarcode) { return oldBarcode.id === newBarcode.id && oldBarcode.code === newBarcode.code; } diff --git a/client/item/src/niche/item-niche.html b/client/item/src/niche/item-niche.html index ae30034db..068eedb41 100644 --- a/client/item/src/niche/item-niche.html +++ b/client/item/src/niche/item-niche.html @@ -8,7 +8,8 @@ Item Niches + + { this.niches = response.data; this.setOldNiches(response); @@ -95,6 +97,7 @@ export default class Controller { create: [], update: [] }; + this.niches.forEach(niche => { let isNewNiche = !niche.id; diff --git a/client/item/src/tags/item-tags.html b/client/item/src/tags/item-tags.html index 318a5dec7..c92a13292 100644 --- a/client/item/src/tags/item-tags.html +++ b/client/item/src/tags/item-tags.html @@ -8,6 +8,7 @@ Item tags + +