comprobación modificación consignatario

This commit is contained in:
nelo 2017-01-18 10:50:51 +01:00
parent 2694b14c53
commit 28451aced9
1 changed files with 20 additions and 4 deletions

View File

@ -5,10 +5,13 @@ export const NAME = 'vnClientAddressesDataEdit';
export const COMPONENT = {
template: template,
controllerAs: 'addressData',
controller: function($http, $stateParams) {
controller: function($http, $stateParams, copyObject, equalsObject) {
this.address = {};
$http.get(`/client/api/Addresses/${$stateParams.addressId}`).then(
json => this.address = json.data
json => {
this.address = json.data;
this.copyAddress();
 }
);
$http.get('/client/api/Agencies').then(
json => this.agencies = json.data
@ -18,10 +21,23 @@ export const COMPONENT = {
);
this.submit = function() {
$http.put('/client/api/Addresses', this.address);
if (!equalsObject(this.address, this.addressOld)) {
$http.put('/client/api/Addresses', this.address).then(
json => {
this.address = json.data;
this.copyAddress();
}
);
}
};
this.copyAddress = () => {
this.addressOld = {};
copyObject(this.address, this.addressOld);
};
}
};
COMPONENT.controller.$inject = ['$http', '$stateParams'];
COMPONENT.controller.$inject = ['$http', '$stateParams', 'copyObject', 'equalsObject'];
module.component(NAME, COMPONENT);