2017-06-03 11:01:47 +00:00
|
|
|
import ngModule from '../module';
|
2017-01-31 13:13:06 +00:00
|
|
|
|
2017-06-03 11:01:47 +00:00
|
|
|
export default class Controller {
|
2019-07-08 12:07:09 +00:00
|
|
|
constructor($scope, $state, $http, $translate, vnApp) {
|
2017-06-03 11:01:47 +00:00
|
|
|
this.$ = $scope;
|
2017-02-07 11:58:25 +00:00
|
|
|
this.$state = $state;
|
2019-06-13 11:08:11 +00:00
|
|
|
this.$http = $http;
|
2019-07-08 12:07:09 +00:00
|
|
|
this.$translate = $translate;
|
|
|
|
this.vnApp = vnApp;
|
2017-02-07 11:58:25 +00:00
|
|
|
this.client = {
|
|
|
|
active: true
|
2017-01-31 13:13:06 +00:00
|
|
|
};
|
|
|
|
}
|
2019-06-13 11:08:11 +00:00
|
|
|
|
2019-07-08 12:07:09 +00:00
|
|
|
get postcodeSelection() {
|
|
|
|
return this._postcodeSelection;
|
|
|
|
}
|
|
|
|
|
|
|
|
set postcodeSelection(selection) {
|
|
|
|
this._postcodeSelection = selection;
|
|
|
|
|
|
|
|
if (!selection) return;
|
|
|
|
|
|
|
|
const town = selection.town;
|
2019-06-13 11:08:11 +00:00
|
|
|
const province = town.province;
|
|
|
|
const country = province.country;
|
|
|
|
|
2019-07-08 12:07:09 +00:00
|
|
|
this.client.city = town.name;
|
2019-06-13 11:08:11 +00:00
|
|
|
this.client.provinceFk = province.id;
|
|
|
|
this.client.countryFk = country.id;
|
|
|
|
}
|
|
|
|
|
2019-07-08 12:07:09 +00:00
|
|
|
onResponse(response) {
|
|
|
|
this.client.postcode = response.code;
|
|
|
|
}
|
|
|
|
|
2017-02-07 11:58:25 +00:00
|
|
|
onSubmit() {
|
2019-07-08 12:07:09 +00:00
|
|
|
return this.$.watcher.submit().then(
|
2018-05-23 12:26:51 +00:00
|
|
|
json => this.$state.go('client.card.basicData', {id: json.data.id})
|
2017-02-07 11:58:25 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2019-07-08 12:07:09 +00:00
|
|
|
Controller.$inject = ['$scope', '$state', '$http', '$translate', 'vnApp'];
|
2017-01-31 13:13:06 +00:00
|
|
|
|
2017-06-03 11:01:47 +00:00
|
|
|
ngModule.component('vnClientCreate', {
|
2018-05-23 12:26:51 +00:00
|
|
|
template: require('./index.html'),
|
2017-02-07 11:58:25 +00:00
|
|
|
controller: Controller
|
2017-06-03 11:01:47 +00:00
|
|
|
});
|