comprobación modificación consignatario
This commit is contained in:
parent
2694b14c53
commit
28451aced9
|
@ -5,10 +5,13 @@ export const NAME = 'vnClientAddressesDataEdit';
|
||||||
export const COMPONENT = {
|
export const COMPONENT = {
|
||||||
template: template,
|
template: template,
|
||||||
controllerAs: 'addressData',
|
controllerAs: 'addressData',
|
||||||
controller: function($http, $stateParams) {
|
controller: function($http, $stateParams, copyObject, equalsObject) {
|
||||||
this.address = {};
|
this.address = {};
|
||||||
$http.get(`/client/api/Addresses/${$stateParams.addressId}`).then(
|
$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(
|
$http.get('/client/api/Agencies').then(
|
||||||
json => this.agencies = json.data
|
json => this.agencies = json.data
|
||||||
|
@ -18,10 +21,23 @@ export const COMPONENT = {
|
||||||
);
|
);
|
||||||
|
|
||||||
this.submit = function() {
|
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);
|
module.component(NAME, COMPONENT);
|
||||||
|
|
Loading…
Reference in New Issue