44 lines
1000 B
JavaScript
44 lines
1000 B
JavaScript
import ngModule from '../../module';
|
|
|
|
export default class Controller {
|
|
constructor($scope, $state) {
|
|
this.$ = $scope;
|
|
this.$state = $state;
|
|
this.$stateParams = $state.params;
|
|
}
|
|
|
|
removeObservation(index) {
|
|
this.$.watcher.setDirty();
|
|
this.$.model.remove(index);
|
|
}
|
|
|
|
cancel() {
|
|
this.goToIndex();
|
|
}
|
|
|
|
goToIndex() {
|
|
this.$state.go('client.card.address.index');
|
|
}
|
|
|
|
submit() {
|
|
this.$.watcher.check();
|
|
this.$.watcher.realSubmit()
|
|
.then(() => this.$.model.save(true))
|
|
.then(() => {
|
|
this.$.watcher.setPristine();
|
|
this.$.watcher.notifySaved();
|
|
this.card.reload();
|
|
this.goToIndex();
|
|
});
|
|
}
|
|
}
|
|
Controller.$inject = ['$scope', '$state'];
|
|
|
|
ngModule.component('vnClientAddressEdit', {
|
|
template: require('./index.html'),
|
|
controller: Controller,
|
|
require: {
|
|
card: '^vnClientCard'
|
|
}
|
|
});
|