2019-09-25 18:06:42 +00:00
|
|
|
import ngModule from '../module';
|
2019-11-14 13:37:18 +00:00
|
|
|
import Section from 'salix/components/section';
|
2019-09-25 18:06:42 +00:00
|
|
|
import './style.scss';
|
|
|
|
|
2019-11-14 13:37:18 +00:00
|
|
|
class Controller extends Section {
|
|
|
|
$onInit() {
|
2021-07-01 10:08:48 +00:00
|
|
|
this.setParams();
|
2019-09-25 18:06:42 +00:00
|
|
|
}
|
|
|
|
|
2020-03-26 16:41:40 +00:00
|
|
|
$postLink() {
|
|
|
|
this.deliveryMethodFk = 'delivery';
|
|
|
|
}
|
2021-07-01 10:08:48 +00:00
|
|
|
|
|
|
|
setParams() {
|
|
|
|
const hasParams = this.$params.deliveryMethodFk || this.$params.geoFk || this.$params.agencyModeFk;
|
|
|
|
if (hasParams) {
|
|
|
|
if (this.$params.deliveryMethodFk)
|
|
|
|
this.deliveryMethodFk = this.$params.deliveryMethodFk;
|
|
|
|
|
|
|
|
if (this.$params.geoFk)
|
|
|
|
this.geoFk = this.$params.geoFk;
|
|
|
|
|
|
|
|
if (this.$params.agencyModeFk)
|
|
|
|
this.agencyModeFk = this.$params.agencyModeFk;
|
|
|
|
|
|
|
|
this.fetchData();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fetchData() {
|
|
|
|
const params = {
|
|
|
|
deliveryMethodFk: this.deliveryMethodFk,
|
|
|
|
geoFk: this.geoFk,
|
|
|
|
agencyModeFk: this.agencyModeFk
|
|
|
|
};
|
2020-01-08 12:27:43 +00:00
|
|
|
this.$.data = null;
|
2021-07-01 10:08:48 +00:00
|
|
|
this.$http.get(`Zones/getEvents`, {params})
|
2020-01-08 12:27:43 +00:00
|
|
|
.then(res => {
|
|
|
|
let data = res.data;
|
|
|
|
this.$.data = data;
|
|
|
|
if (!data.events.length)
|
|
|
|
this.vnApp.showMessage(this.$t('No service for the specified zone'));
|
2021-07-01 10:08:48 +00:00
|
|
|
|
|
|
|
this.$state.go(this.$state.current.name, params);
|
2020-01-08 12:27:43 +00:00
|
|
|
});
|
2019-09-25 18:06:42 +00:00
|
|
|
}
|
2020-02-26 06:02:03 +00:00
|
|
|
|
2020-03-24 16:32:30 +00:00
|
|
|
get deliveryMethodFk() {
|
2020-03-26 16:41:40 +00:00
|
|
|
return this._deliveryMethodFk;
|
2020-03-24 16:32:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
set deliveryMethodFk(value) {
|
2020-03-26 16:41:40 +00:00
|
|
|
this._deliveryMethodFk = value;
|
2021-07-01 10:08:48 +00:00
|
|
|
|
2020-03-24 16:32:30 +00:00
|
|
|
let filter;
|
2021-07-01 10:08:48 +00:00
|
|
|
|
|
|
|
if (value === 'pickUp')
|
2020-03-24 16:32:30 +00:00
|
|
|
filter = {where: {code: 'PICKUP'}};
|
2021-07-01 10:08:48 +00:00
|
|
|
else
|
2020-03-26 16:41:40 +00:00
|
|
|
filter = {where: {code: {inq: ['DELIVERY', 'AGENCY']}}};
|
|
|
|
|
|
|
|
this.$http.get(`DeliveryMethods`, {filter}).then(res => {
|
2021-07-01 10:08:48 +00:00
|
|
|
const deliveryMethods = res.data.map(deliveryMethod => deliveryMethod.id);
|
2020-03-24 16:32:30 +00:00
|
|
|
this.agencyFilter = {deliveryMethodFk: {inq: deliveryMethods}};
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-08-30 12:14:21 +00:00
|
|
|
onSelection($event, $events, $days) {
|
2020-02-26 06:02:03 +00:00
|
|
|
if (!$events.length) return;
|
|
|
|
|
2021-08-30 12:14:21 +00:00
|
|
|
const day = $days[0];
|
|
|
|
const zonesIds = [];
|
2020-02-26 06:02:03 +00:00
|
|
|
for (let event of $events)
|
2021-08-30 12:14:21 +00:00
|
|
|
zonesIds.push(event.zoneFk);
|
2020-02-26 06:02:03 +00:00
|
|
|
|
|
|
|
this.$.zoneEvents.show($event.target);
|
2022-03-04 11:24:01 +00:00
|
|
|
|
|
|
|
const params = {
|
|
|
|
zonesId: zonesIds,
|
|
|
|
date: day
|
|
|
|
};
|
|
|
|
|
|
|
|
this.$http.post(`Zones/getZoneClosing`, params)
|
2022-03-07 07:02:59 +00:00
|
|
|
.then(res => this.zoneClosing = res.data);
|
2020-02-26 06:02:03 +00:00
|
|
|
}
|
2020-03-26 08:07:17 +00:00
|
|
|
|
2020-04-25 09:50:04 +00:00
|
|
|
preview(zone) {
|
2020-03-26 08:07:17 +00:00
|
|
|
this.selectedZone = zone;
|
|
|
|
this.$.summary.show();
|
|
|
|
}
|
2019-09-25 18:06:42 +00:00
|
|
|
}
|
|
|
|
|
2020-07-24 12:22:30 +00:00
|
|
|
ngModule.vnComponent('vnZoneDeliveryDays', {
|
2019-09-25 18:06:42 +00:00
|
|
|
template: require('./index.html'),
|
|
|
|
controller: Controller
|
|
|
|
});
|