2018-11-30 10:45:17 +00:00
|
|
|
import ngModule from '../module';
|
2020-03-17 14:18:02 +00:00
|
|
|
import Section from 'salix/components/section';
|
2018-11-30 10:45:17 +00:00
|
|
|
import './style.scss';
|
|
|
|
|
2020-03-17 14:18:02 +00:00
|
|
|
class Controller extends Section {
|
|
|
|
constructor($element, $) {
|
|
|
|
super($element, $);
|
2019-02-06 13:56:36 +00:00
|
|
|
let isDirty = false;
|
2020-03-17 14:18:02 +00:00
|
|
|
this.$.$watch('$ctrl.selection', newValue => {
|
2019-02-06 13:56:36 +00:00
|
|
|
if (newValue) {
|
2020-03-17 14:18:02 +00:00
|
|
|
this.$.addressModel.where = {clientFk: newValue.id};
|
|
|
|
this.$.addressModel.refresh();
|
2019-02-06 13:56:36 +00:00
|
|
|
if (isDirty)
|
2019-02-15 12:26:49 +00:00
|
|
|
this.order.addressFk = newValue.defaultAddressFk;
|
2019-02-06 13:56:36 +00:00
|
|
|
isDirty = true;
|
|
|
|
} else {
|
2020-03-17 14:18:02 +00:00
|
|
|
this.$.addressModel.clear();
|
2019-02-06 13:56:36 +00:00
|
|
|
if (isDirty)
|
2019-02-15 12:26:49 +00:00
|
|
|
this.order.addressFk = null;
|
2019-02-06 13:56:36 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-30 10:45:17 +00:00
|
|
|
ngModule.component('vnOrderBasicData', {
|
2019-02-06 13:56:36 +00:00
|
|
|
controller: Controller,
|
2018-11-30 10:45:17 +00:00
|
|
|
template: require('./index.html'),
|
|
|
|
bindings: {
|
|
|
|
order: '<'
|
|
|
|
}
|
|
|
|
});
|