diff --git a/db/changes/10460-mothersDay/00-aclZoneExclusionGeos.sql b/db/changes/10470-family/00-aclZoneExclusionGeos.sql similarity index 100% rename from db/changes/10460-mothersDay/00-aclZoneExclusionGeos.sql rename to db/changes/10470-family/00-aclZoneExclusionGeos.sql diff --git a/db/changes/10460-mothersDay/00-zoneHoliday.sql b/db/changes/10470-family/00-zoneHoliday.sql similarity index 97% rename from db/changes/10460-mothersDay/00-zoneHoliday.sql rename to db/changes/10470-family/00-zoneHoliday.sql index badae1c3e..e89723818 100644 --- a/db/changes/10460-mothersDay/00-zoneHoliday.sql +++ b/db/changes/10470-family/00-zoneHoliday.sql @@ -1,11 +1,11 @@ -CREATE TABLE `vn`.`zoneExclusionGeo` ( +CREATE TABLE `zoneExclusionGeo` ( `zoneExclusionFk` int(11) NOT NULL, `geoFk` int(11) NOT NULL, PRIMARY KEY (`zoneExclusionFk`,`geoFk`), KEY `zoneExclusionGeo2_FK_1` (`geoFk`), - CONSTRAINT `zoneExclusionGeo2_FK` FOREIGN KEY (`zoneExclusionFk`) REFERENCES `zoneExclusion` (`id`) ON UPDATE CASCADE, - CONSTRAINT `zoneExclusionGeo2_FK_1` FOREIGN KEY (`geoFk`) REFERENCES `zoneGeo` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; + CONSTRAINT `zoneExclusionGeo2_FK_1` FOREIGN KEY (`geoFk`) REFERENCES `zoneGeo` (`id`) ON UPDATE CASCADE, + CONSTRAINT `zoneExclusionGeo_FK` FOREIGN KEY (`zoneExclusionFk`) REFERENCES `zoneExclusion` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 DROP PROCEDURE IF EXISTS `vn`.`zone_excludeFromGeo`; diff --git a/modules/zone/front/calendar/index.js b/modules/zone/front/calendar/index.js index bdec1b949..262567a86 100644 --- a/modules/zone/front/calendar/index.js +++ b/modules/zone/front/calendar/index.js @@ -146,11 +146,13 @@ class Controller extends Component { onSelection($event, $days, $type, $weekday) { let $events = []; let $exclusions = []; + let $geoExclusions = []; for (let day of $days) { let stamp = day.getTime(); $events = $events.concat(this.days[stamp] || []); $exclusions = $exclusions.concat(this.exclusions[stamp] || []); + $geoExclusions = $geoExclusions.concat(this.geoExclusions[stamp] || []); } this.emit('selection', { @@ -159,7 +161,8 @@ class Controller extends Component { $type, $weekday, $events, - $exclusions + $exclusions, + $geoExclusions }); } diff --git a/modules/zone/front/events/index.html b/modules/zone/front/events/index.html index 45e2ec671..270f75ec7 100644 --- a/modules/zone/front/events/index.html +++ b/modules/zone/front/events/index.html @@ -1,8 +1,14 @@ + + @@ -201,7 +207,7 @@ + message="{{$ctrl.isNew ? 'Exclusion' : 'Edit exclusion'}}"> - - +
diff --git a/modules/zone/front/events/index.js b/modules/zone/front/events/index.js index 5626a175a..8aafa9e90 100644 --- a/modules/zone/front/events/index.js +++ b/modules/zone/front/events/index.js @@ -61,24 +61,56 @@ class Controller extends Section { : this.$t('Everyday'); } - onSelection(days, type, weekday, events, exclusions) { + onSelection(days, type, weekday, events, exclusions, geoExclusions) { if (this.editMode == 'include') { if (events.length) this.edit(events[0]); else this.create(type, days, weekday); } else { - this.excludeSelected = { - type: 'all', - dated: days[0] - }; - this.exclusions = exclusions; - this.days = days; - - this.$.excludeDialog.show(); + if (geoExclusions.length) + this.editExclusion(geoExclusions); + else if (exclusions.length) + this.editExclusion(exclusions); + else + this.createExclusion(exclusions, days); } } + editExclusion(rows) { + this.isNew = false; + this.exclusions = rows; + this.excludeSelected = angular.copy(rows[0]); + if (this.excludeSelected.geoFk) + this.excludeSelected.type = 'specificLocations'; + else + this.excludeSelected.type = 'all'; + console.log(this.excludeSelected); + // const geos = this.$.model.data || []; + + // for (let geo of geos) { + // for (let row of rows) { + // if (geo.id == row.geoFk) { + // geo.checked = true; + // console.log(geo); + // } + // } + // } + this.$.excludeDialog.show(); + } + + createExclusion(exclusions, days) { + this.isNew = true; + this.excludeSelected = { + type: 'all', + dated: days[0] + }; + this.exclusions = exclusions; + this.days = days; + + this.$.excludeDialog.show(); + } + onEditClick(row, event) { if (event.defaultPrevented) return; this.edit(row); @@ -150,6 +182,8 @@ class Controller extends Section { } onExcludeResponse(response) { + console.log(this.$.model.data); + switch (response) { case 'accept': { let excludeSelected = this.excludeSelected; @@ -267,14 +301,6 @@ class Controller extends Section { return {name: {like: `%${value}%`}}; } } - - onSelection2(value, item) { - if (value == null) - value = undefined; - const params = {geoId: item.id, isIncluded: value}; - const path = `zones/${this.zone.id}/toggleIsIncluded`; - this.$http.post(path, params); - } } Controller.$inject = ['$element', '$scope', 'vnWeekDays'];