Merge branch 'dev' into 3070_deprecate_item_niches
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
commit
17a732e811
|
@ -62,6 +62,11 @@
|
|||
"type": "hasMany",
|
||||
"model": "ZoneWarehouse",
|
||||
"foreignKey": "zoneFk"
|
||||
},
|
||||
"closures": {
|
||||
"type": "hasMany",
|
||||
"model": "ZoneClosure",
|
||||
"foreignKey": "zoneFk"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
<div class="vn-w-md">
|
||||
<vn-zone-calendar
|
||||
data="data"
|
||||
on-selection="$ctrl.onSelection($event, $events)">
|
||||
on-selection="$ctrl.onSelection($event, $events, $days)">
|
||||
</vn-zone-calendar>
|
||||
</div>
|
||||
<vn-side-menu side="right">
|
||||
|
|
|
@ -65,22 +65,40 @@ class Controller extends Section {
|
|||
});
|
||||
}
|
||||
|
||||
onSelection($event, $events) {
|
||||
onSelection($event, $events, $days) {
|
||||
if (!$events.length) return;
|
||||
|
||||
const zones = [];
|
||||
const day = $days[0];
|
||||
const zonesIds = [];
|
||||
for (let event of $events)
|
||||
zones.push(event.zoneFk);
|
||||
zonesIds.push(event.zoneFk);
|
||||
|
||||
this.$.zoneEvents.show($event.target);
|
||||
const zoneModel = this.$.zoneModel;
|
||||
zoneModel.applyFilter({
|
||||
include: {
|
||||
relation: 'agencyMode',
|
||||
scope: {fields: ['name']}
|
||||
},
|
||||
include: [
|
||||
{
|
||||
relation: 'agencyMode',
|
||||
scope: {fields: ['name']}
|
||||
},
|
||||
{
|
||||
relation: 'events',
|
||||
scope: {
|
||||
where: {dated: day}
|
||||
}
|
||||
},
|
||||
],
|
||||
where: {
|
||||
id: {inq: zones}
|
||||
id: {inq: zonesIds}
|
||||
}
|
||||
}).then(() => {
|
||||
const data = zoneModel.data;
|
||||
for (let row of data) {
|
||||
const [event] = row.events;
|
||||
if (event && event.hour)
|
||||
row.hour = event.hour;
|
||||
if (event && event.price)
|
||||
row.price = event.price;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -99,7 +99,11 @@ describe('Zone Component vnZoneDeliveryDays', () => {
|
|||
it('should call the show() method and then call the applyFilter() method with the expected ids', () => {
|
||||
const zoneModel = controller.$.zoneModel;
|
||||
jest.spyOn(controller.$.zoneEvents, 'show');
|
||||
jest.spyOn(zoneModel, 'applyFilter');
|
||||
jest.spyOn(zoneModel, 'applyFilter').mockReturnValue(new Promise(resolve => {
|
||||
zoneModel.data = [
|
||||
{id: 1, events: [{price: 25}]}
|
||||
];
|
||||
}));
|
||||
|
||||
const event = new Event('click');
|
||||
const target = document.createElement('div');
|
||||
|
@ -109,12 +113,22 @@ describe('Zone Component vnZoneDeliveryDays', () => {
|
|||
{zoneFk: 2},
|
||||
{zoneFk: 8}
|
||||
];
|
||||
controller.onSelection(event, events);
|
||||
|
||||
const day = new Date();
|
||||
controller.onSelection(event, events, [day]);
|
||||
const expectedFilter = {
|
||||
include: {
|
||||
relation: 'agencyMode',
|
||||
scope: {fields: ['name']}
|
||||
},
|
||||
include: [
|
||||
{
|
||||
relation: 'agencyMode',
|
||||
scope: {fields: ['name']}
|
||||
},
|
||||
{
|
||||
relation: 'events',
|
||||
scope: {
|
||||
where: {dated: day}
|
||||
}
|
||||
}
|
||||
],
|
||||
where: {
|
||||
id: {inq: [1, 2, 8]}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue