Merge pull request '3075 - Show closure hour from an event' (#717) from 3075-delivery_days_hour into dev
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
Reviewed-on: #717 Reviewed-by: Carlos Jimenez Ruiz <carlosjr@verdnatura.es>
This commit is contained in:
commit
b27b82830f
|
@ -62,6 +62,11 @@
|
||||||
"type": "hasMany",
|
"type": "hasMany",
|
||||||
"model": "ZoneWarehouse",
|
"model": "ZoneWarehouse",
|
||||||
"foreignKey": "zoneFk"
|
"foreignKey": "zoneFk"
|
||||||
|
},
|
||||||
|
"closures": {
|
||||||
|
"type": "hasMany",
|
||||||
|
"model": "ZoneClosure",
|
||||||
|
"foreignKey": "zoneFk"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
<div class="vn-w-md">
|
<div class="vn-w-md">
|
||||||
<vn-zone-calendar
|
<vn-zone-calendar
|
||||||
data="data"
|
data="data"
|
||||||
on-selection="$ctrl.onSelection($event, $events)">
|
on-selection="$ctrl.onSelection($event, $events, $days)">
|
||||||
</vn-zone-calendar>
|
</vn-zone-calendar>
|
||||||
</div>
|
</div>
|
||||||
<vn-side-menu side="right">
|
<vn-side-menu side="right">
|
||||||
|
|
|
@ -65,22 +65,40 @@ class Controller extends Section {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onSelection($event, $events) {
|
onSelection($event, $events, $days) {
|
||||||
if (!$events.length) return;
|
if (!$events.length) return;
|
||||||
|
|
||||||
const zones = [];
|
const day = $days[0];
|
||||||
|
const zonesIds = [];
|
||||||
for (let event of $events)
|
for (let event of $events)
|
||||||
zones.push(event.zoneFk);
|
zonesIds.push(event.zoneFk);
|
||||||
|
|
||||||
this.$.zoneEvents.show($event.target);
|
this.$.zoneEvents.show($event.target);
|
||||||
const zoneModel = this.$.zoneModel;
|
const zoneModel = this.$.zoneModel;
|
||||||
zoneModel.applyFilter({
|
zoneModel.applyFilter({
|
||||||
include: {
|
include: [
|
||||||
|
{
|
||||||
relation: 'agencyMode',
|
relation: 'agencyMode',
|
||||||
scope: {fields: ['name']}
|
scope: {fields: ['name']}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
relation: 'events',
|
||||||
|
scope: {
|
||||||
|
where: {dated: day}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
],
|
||||||
where: {
|
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', () => {
|
it('should call the show() method and then call the applyFilter() method with the expected ids', () => {
|
||||||
const zoneModel = controller.$.zoneModel;
|
const zoneModel = controller.$.zoneModel;
|
||||||
jest.spyOn(controller.$.zoneEvents, 'show');
|
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 event = new Event('click');
|
||||||
const target = document.createElement('div');
|
const target = document.createElement('div');
|
||||||
|
@ -109,12 +113,22 @@ describe('Zone Component vnZoneDeliveryDays', () => {
|
||||||
{zoneFk: 2},
|
{zoneFk: 2},
|
||||||
{zoneFk: 8}
|
{zoneFk: 8}
|
||||||
];
|
];
|
||||||
controller.onSelection(event, events);
|
|
||||||
|
const day = new Date();
|
||||||
|
controller.onSelection(event, events, [day]);
|
||||||
const expectedFilter = {
|
const expectedFilter = {
|
||||||
include: {
|
include: [
|
||||||
|
{
|
||||||
relation: 'agencyMode',
|
relation: 'agencyMode',
|
||||||
scope: {fields: ['name']}
|
scope: {fields: ['name']}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
relation: 'events',
|
||||||
|
scope: {
|
||||||
|
where: {dated: day}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
where: {
|
where: {
|
||||||
id: {inq: [1, 2, 8]}
|
id: {inq: [1, 2, 8]}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue