46 lines
1.1 KiB
JavaScript
46 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.check();
|
|
this.$.watcher.realSubmit()
|
|
.then(() => this.$.model.save(true))
|
|
.then(() => {
|
|
this.$.watcher.notifySaved();
|
|
this.card.reload();
|
|
this.goToIndex();
|
|
});
|
|
}
|
|
|
|
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'
|
|
}
|
|
});
|