salix/modules/zone/front/summary/index.js

66 lines
1.6 KiB
JavaScript
Raw Normal View History

2018-12-04 12:18:27 +00:00
import ngModule from '../module';
2019-11-15 06:35:51 +00:00
import Component from 'core/lib/component';
2018-09-25 07:28:55 +00:00
2019-11-15 06:35:51 +00:00
class Controller extends Component {
2019-11-25 07:35:34 +00:00
constructor($element, $, $httpParamSerializer) {
super($element, $);
this.$httpParamSerializer = $httpParamSerializer;
}
2018-09-25 07:28:55 +00:00
get zone() {
return this._zone;
}
set zone(value) {
this._zone = value;
if (!value) return;
this.getSummary();
2019-11-25 07:35:34 +00:00
this.getWarehouses();
2018-09-25 07:28:55 +00:00
}
getSummary() {
2019-11-25 07:35:34 +00:00
const params = {
filter: {
include: {
relation: 'agencyMode',
fields: ['name']
},
where: {
id: this.zone.id
}
}
2019-01-21 10:45:53 +00:00
};
2019-11-25 07:35:34 +00:00
const serializedParams = this.$httpParamSerializer(params);
this.$http.get(`Zones/findOne?${serializedParams}`).then(res => {
this.summary = res.data;
});
}
getWarehouses() {
const params = {
filter: {
include: {
relation: 'warehouse',
fields: ['name']
}
}
};
const serializedParams = this.$httpParamSerializer(params);
this.$http.get(`Zones/${this.zone.id}/warehouses?${serializedParams}`).then(res => {
this.zoneWarehouses = res.data;
2018-09-25 07:28:55 +00:00
});
}
}
2019-11-25 07:35:34 +00:00
Controller.$inject = ['$element', '$scope', '$httpParamSerializer'];
2018-09-25 07:28:55 +00:00
ngModule.component('vnZoneSummary', {
template: require('./index.html'),
controller: Controller,
bindings: {
zone: '<'
}
});