47 lines
1.2 KiB
JavaScript
47 lines
1.2 KiB
JavaScript
import ngModule from '../module';
|
|
import Section from 'salix/components/section';
|
|
import './style.scss';
|
|
|
|
class Controller extends Section {
|
|
$onInit() {
|
|
this.$.params = {};
|
|
}
|
|
|
|
onSubmit() {
|
|
this.$.data = null;
|
|
this.$http.get(`Zones/getEvents`, {params: this.$.params})
|
|
.then(res => {
|
|
let data = res.data;
|
|
this.$.data = data;
|
|
if (!data.events.length)
|
|
this.vnApp.showMessage(this.$t('No service for the specified zone'));
|
|
});
|
|
}
|
|
|
|
onSelection($event, $events) {
|
|
if (!$events.length) return;
|
|
|
|
const zones = [];
|
|
for (let event of $events)
|
|
zones.push(event.zoneFk);
|
|
|
|
this.$.zoneEvents.show($event.target);
|
|
const zoneIndex = this.$.zoneIndex;
|
|
const zoneModel = zoneIndex.$scope.model;
|
|
zoneModel.applyFilter({
|
|
include: {
|
|
relation: 'agencyMode',
|
|
scope: {fields: ['name']}
|
|
},
|
|
where: {
|
|
id: {inq: zones}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
ngModule.component('vnZoneDeliveryDays', {
|
|
template: require('./index.html'),
|
|
controller: Controller
|
|
});
|