salix/modules/client/front/address/edit/index.js

51 lines
1.1 KiB
JavaScript

import ngModule from '../../module';
import Component from 'core/lib/component';
export default class Controller extends Component {
removeObservation(index) {
this.$.watcher.setDirty();
this.$.model.remove(index);
}
cancel() {
this.goToIndex();
}
goToIndex() {
this.$state.go('client.card.address.index');
}
onResponse(response) {
this.address.postalCode = response.code;
}
onSubmit() {
this.$.watcher.submit()
.then(() => this.$.model.save(true))
.then(() => {
this.card.reload();
this.goToIndex();
});
}
showCustomAgent(event) {
if (event.defaultPrevented) return;
event.preventDefault();
this.$.customAgent.show();
}
onCustomAgentAccept() {
return this.$http.post(`CustomsAgents`, this.newCustomsAgent)
.then(res => this.address.customsAgentFk = res.data.id);
}
}
ngModule.component('vnClientAddressEdit', {
template: require('./index.html'),
controller: Controller,
require: {
card: '^vnClientCard'
}
});