diff --git a/@salix/crud/src/client/basic-data/index.js b/@salix/crud/src/client/basic-data/index.js index c9947c1e3..d58e442ef 100644 --- a/@salix/crud/src/client/basic-data/index.js +++ b/@salix/crud/src/client/basic-data/index.js @@ -8,42 +8,51 @@ export const COMPONENT = { bindings: { client: '<' }, - controller: function($http, copyObject, equalsObject, $transitions, $state) { + controller: function($http, copyObject, equalsObject, $transitions, $element) { - var self = this; - + var self = this; var deregister = $transitions.onStart({ }, callback); - this.$onChanges = function (changes) { - if(this.client){ - this.clientOld = copyObject(this.client); + this.$onChanges = function(changes) { + if (this.client) { + this.copyClient(); } - } + }; - this.$onDestroy = function(){ + this.$onDestroy = function() { deregister(); - } + }; $http.get('/client/api/SalesPeople').then( json => this.sales = json.data ); function callback(transition) { - if(!equalsObject(self.client, self.clientOld)){ + if (!equalsObject(self.client, self.clientOld)) { self.state = transition.to().name; - var dialog = document.querySelector('dialog'); + var dialog = $element[0].querySelector('dialog'); dialog.showModal(); return false; } } this.submit = function() { - if(!equalsObject(this.client, this.clientOld)){ + if (!equalsObject(this.client, this.clientOld)) { this.client.modify = "BasicData"; - $http.put('/client/api/Clients', this.client); + $http.put('/client/api/Clients', this.client).then( + json => { + this.client = json.data; + this.copyClient(); + } + ); } }; + + this.copyClient = function() { + this.clientOld = {}; + copyObject(this.client, this.clientOld); + }; } }; -COMPONENT.controller.$inject = ['$http', 'copyObject', 'equalsObject', '$transitions', '$state']; +COMPONENT.controller.$inject = ['$http', 'copyObject', 'equalsObject', '$transitions', '$element']; module.component(NAME, COMPONENT); diff --git a/@salix/crud/src/client/confirm/index.html b/@salix/crud/src/client/confirm/index.html index ed2f19b32..703a0b448 100644 --- a/@salix/crud/src/client/confirm/index.html +++ b/@salix/crud/src/client/confirm/index.html @@ -1,11 +1,11 @@

- Allow this site to collect usage data to improve your experience? + ¿Desea salir sin guardar?

- - + +
\ No newline at end of file diff --git a/@salix/crud/src/client/create/index.html b/@salix/crud/src/client/create/index.html index 650ce5df7..0371f986f 100644 --- a/@salix/crud/src/client/create/index.html +++ b/@salix/crud/src/client/create/index.html @@ -1,20 +1,21 @@
- - - Crear Cliente - - - - - - - - - - - - - - - -
\ No newline at end of file + + + Crear Cliente + + + + + + + + + + + + + + + + + diff --git a/@salix/crud/src/client/create/index.js b/@salix/crud/src/client/create/index.js index c4a4607bf..b7c8ce7f5 100644 --- a/@salix/crud/src/client/create/index.js +++ b/@salix/crud/src/client/create/index.js @@ -5,8 +5,8 @@ export const NAME = "vnClientCreate"; export const COMPONENT = { template: template, controllerAs: "create", - controller: function($http, $state){ - this.submit = function(){ + controller: function($http, $state) { + this.submit = function() { $http.post('/client/api/Clients', this.model).then( json => $state.go('clientCard.basicData',{id: json.data.id}) ); diff --git a/@salix/crud/src/client/fiscal-data/index.html b/@salix/crud/src/client/fiscal-data/index.html index 2b97bee5d..27a70f6cb 100644 --- a/@salix/crud/src/client/fiscal-data/index.html +++ b/@salix/crud/src/client/fiscal-data/index.html @@ -61,4 +61,5 @@ - \ No newline at end of file + + \ No newline at end of file diff --git a/@salix/crud/src/client/fiscal-data/index.js b/@salix/crud/src/client/fiscal-data/index.js index bf8d88fc2..bccda409d 100644 --- a/@salix/crud/src/client/fiscal-data/index.js +++ b/@salix/crud/src/client/fiscal-data/index.js @@ -8,22 +8,60 @@ export const COMPONENT = { bindings: { client: '<' }, - controller: function($http) { + controller: function($http, copyObject, equalsObject, $transitions, $element) { + + var self = this; + var deregister = $transitions.onStart({ }, callback); + $http.get('/client/api/Countries').then( json => this.countries = json.data ); + $http.get('/client/api/Provinces').then( json => this.provinces = json.data ); + $http.get('/client/api/PaymentMethods').then( json => this.payments = json.data ); this.submit = function() { - $http.put('/client/api/Clients', this.client); + if (!equalsObject(this.client, this.clientOld)) { + this.client.modify = "FiscalData"; + $http.put('/client/api/Clients', this.client).then( + json => { + this.client = json.data; + this.copyClient(); + } + ); + } + }; + + this.$onChanges = function(changes) { + if (this.client) { + this.copyClient(); + } + }; + + this.$onDestroy = function() { + deregister(); + }; + + function callback(transition) { + if (!equalsObject(self.client, self.clientOld)) { + self.state = transition.to().name; + var dialog = $element[0].querySelector('dialog'); + dialog.showModal(); + return false; + } + } + + this.copyClient = function() { + this.clientOld = {}; + copyObject(this.client, this.clientOld); }; } }; -COMPONENT.controller.$inject = ['$http']; +COMPONENT.controller.$inject = ['$http', 'copyObject', 'equalsObject', '$transitions', '$element']; module.component(NAME, COMPONENT); diff --git a/@salix/crud/src/client/web-access/index.html b/@salix/crud/src/client/web-access/index.html index ba6696619..df54b3b84 100644 --- a/@salix/crud/src/client/web-access/index.html +++ b/@salix/crud/src/client/web-access/index.html @@ -7,4 +7,5 @@ - \ No newline at end of file + + \ No newline at end of file diff --git a/@salix/crud/src/client/web-access/index.js b/@salix/crud/src/client/web-access/index.js index 04bd3ac12..b123c888d 100644 --- a/@salix/crud/src/client/web-access/index.js +++ b/@salix/crud/src/client/web-access/index.js @@ -8,11 +8,47 @@ export const COMPONENT = { bindings: { client: '<' }, - controller: function($http) { + controller: function($http, copyObject, equalsObject, $transitions, $element) { + + var self = this; + var deregister = $transitions.onStart({ }, callback); + this.submit = function() { - $http.put('/client/api/Clients', this.client); + if (!equalsObject(this.client, this.clientOld)) { + this.client.modify = "WebAccess"; + $http.put('/client/api/Clients', this.client).then( + json => { + this.client = json.data; + this.copyClient(); + } + ); + } + }; + + this.$onChanges = function(changes) { + if (this.client) { + this.copyClient(); + } + }; + + this.$onDestroy = function() { + deregister(); + }; + + function callback(transition) { + if (!equalsObject(self.client, self.clientOld)) { + self.state = transition.to().name; + var dialog = $element[0].querySelector('dialog'); + dialog.showModal(); + return false; + } + } + + this.copyClient = function() { + this.clientOld = {}; + copyObject(this.client, this.clientOld); }; } }; -COMPONENT.controller.$inject = ['$http']; +COMPONENT.controller.$inject = ['$http', 'copyObject', 'equalsObject', '$transitions', '$element']; module.component(NAME, COMPONENT);