Delivery days fixes
gitea/salix/dev This commit looks good
Details
gitea/salix/dev This commit looks good
Details
This commit is contained in:
parent
e499d44018
commit
c47f3137c1
|
@ -16,7 +16,7 @@ BEGIN
|
|||
* @param vPostCode The postcode or %NULL to use the province
|
||||
*/
|
||||
DECLARE vGeoFk INT;
|
||||
|
||||
|
||||
IF vPostCode IS NOT NULL THEN
|
||||
SELECT p.geoFk INTO vGeoFk
|
||||
FROM postCode p
|
||||
|
@ -37,11 +37,11 @@ BEGIN
|
|||
WHERE z.agencyModeFk != vAgencyModeFk;
|
||||
END IF;
|
||||
|
||||
SELECT e.`type`, e.dated, e.`started`, e.`ended`, e.weekDays
|
||||
SELECT e.zoneFk, e.`type`, e.dated, e.`started`, e.`ended`, e.weekDays
|
||||
FROM tmp.zone t
|
||||
JOIN zoneEvent e ON e.zoneFk = t.id;
|
||||
|
||||
SELECT DISTINCT e.dated
|
||||
SELECT e.zoneFk, e.dated
|
||||
FROM tmp.zone t
|
||||
JOIN zoneExclusion e ON e.zoneFk = t.id;
|
||||
|
||||
|
|
|
@ -62,12 +62,15 @@ class Controller extends Component {
|
|||
return date && new Date(date).setHours(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
this.exclusionsMap = {};
|
||||
this.exclusions = {};
|
||||
let exclusions = value.exclusions;
|
||||
|
||||
if (exclusions) {
|
||||
for (let exclusion of exclusions)
|
||||
this.exclusionsMap[toStamp(exclusion.dated)] = exclusion;
|
||||
for (let exclusion of exclusions) {
|
||||
let stamp = toStamp(exclusion.dated);
|
||||
if (!this.exclusions[stamp]) this.exclusions[stamp] = [];
|
||||
this.exclusions[stamp].push(exclusion);
|
||||
}
|
||||
}
|
||||
|
||||
let events = value.events;
|
||||
|
@ -98,6 +101,7 @@ class Controller extends Component {
|
|||
let stamp = day.getTime();
|
||||
let wday = day.getDay();
|
||||
let dayEvents = [];
|
||||
let exclusions = this.exclusions[stamp] || [];
|
||||
|
||||
if (this.events) {
|
||||
for (let event of this.events) {
|
||||
|
@ -114,46 +118,46 @@ class Controller extends Component {
|
|||
break;
|
||||
}
|
||||
|
||||
if (match)
|
||||
if (match && !exclusions.find(e => e.zoneFk == event.zoneFk))
|
||||
dayEvents.push(event);
|
||||
}
|
||||
}
|
||||
|
||||
let exclusion = this.exclusionsMap[stamp];
|
||||
|
||||
if (dayEvents.length || exclusion) {
|
||||
let dayData = {};
|
||||
if (dayEvents.length) dayData.events = dayEvents;
|
||||
if (exclusion) dayData.exclusion = exclusion;
|
||||
this.days[stamp] = dayData;
|
||||
}
|
||||
if (dayEvents.length)
|
||||
this.days[stamp] = dayEvents;
|
||||
|
||||
day.setDate(day.getDate() + 1);
|
||||
}
|
||||
}
|
||||
|
||||
onSelection($days, $type, $weekday) {
|
||||
let $data = [];
|
||||
let $events = [];
|
||||
let $exclusions = [];
|
||||
|
||||
for (let day of $days) {
|
||||
let dayData = this.days[day.getTime()];
|
||||
if (dayData) $data.push(dayData);
|
||||
let stamp = day.getTime();
|
||||
$events = $events.concat(this.days[stamp] || []);
|
||||
$exclusions = $exclusions.concat(this.exclusions[stamp] || []);
|
||||
}
|
||||
|
||||
this.emit('selection', {
|
||||
$days,
|
||||
$type,
|
||||
$weekday,
|
||||
$data
|
||||
$events,
|
||||
$exclusions
|
||||
});
|
||||
}
|
||||
|
||||
hasEvents(day) {
|
||||
return this.days[day.getTime()] != null;
|
||||
let stamp = day.getTime();
|
||||
return this.days[stamp] || this.exclusions[stamp];
|
||||
}
|
||||
|
||||
getClass(day) {
|
||||
let dayData = this.days[day.getTime()];
|
||||
return dayData && dayData.exclusion ? 'excluded' : '';
|
||||
let stamp = day.getTime();
|
||||
return this.exclusions[stamp] && !this.days[stamp]
|
||||
? 'excluded' : '';
|
||||
}
|
||||
}
|
||||
Controller.$inject = ['$element', '$scope', 'vnWeekDays'];
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<vn-zone-calendar
|
||||
id="calendar"
|
||||
data="data"
|
||||
on-selection="$ctrl.onSelection($days, $type, $weekday, $data)"
|
||||
on-selection="$ctrl.onSelection($days, $type, $weekday, $events, $exclusions)"
|
||||
class="vn-w-md">
|
||||
</vn-zone-calendar>
|
||||
<vn-side-menu side="right">
|
||||
|
|
|
@ -36,22 +36,14 @@ class Controller extends Section {
|
|||
: this.$t('Everyday');
|
||||
}
|
||||
|
||||
onSelection(days, type, weekday, data) {
|
||||
onSelection(days, type, weekday, events, exclusions) {
|
||||
console.log(events, exclusions);
|
||||
if (this.editMode == 'include') {
|
||||
let dayData = data[0] || {};
|
||||
let event = dayData.events && dayData.events[0];
|
||||
|
||||
if (event)
|
||||
this.edit(event);
|
||||
if (events.length)
|
||||
this.edit(events[0]);
|
||||
else
|
||||
this.create(days, type, weekday);
|
||||
} else {
|
||||
let exclusions = [];
|
||||
for (let dayData of data) {
|
||||
if (dayData.exclusion)
|
||||
exclusions.push(dayData.exclusion.id);
|
||||
}
|
||||
|
||||
if (exclusions.length)
|
||||
this.exclusionDelete(exclusions);
|
||||
else
|
||||
|
@ -155,16 +147,16 @@ class Controller extends Section {
|
|||
.then(() => this.refresh());
|
||||
}
|
||||
|
||||
exclusionDelete(ids) {
|
||||
let promises = [];
|
||||
exclusionDelete(exclusions) {
|
||||
let reqs = [];
|
||||
|
||||
for (let id of ids) {
|
||||
promises.push(
|
||||
this.$http.delete(`${this.exclusionsPath}/${id}`)
|
||||
);
|
||||
for (let exclusion of exclusions) {
|
||||
if (!exclusion.id) continue;
|
||||
let path = `${this.exclusionsPath}/${exclusion.id}`;
|
||||
reqs.push(this.$http.delete(path));
|
||||
}
|
||||
|
||||
this.$q.all(promises)
|
||||
this.$q.all(reqs)
|
||||
.then(() => this.refresh());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue