From f7be419bbe30c063ff51d0c10d49fac96fd3db02 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 2 Jun 2022 11:52:53 +0200 Subject: [PATCH] refator: updated fixtures --- db/changes/10470-family/00-zoneHoliday.sql | 11 ++++++----- db/dump/fixtures.sql | 8 +++++--- modules/zone/front/events/index.js | 6 +++--- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/db/changes/10470-family/00-zoneHoliday.sql b/db/changes/10470-family/00-zoneHoliday.sql index 40b38d4c7..6875251f5 100644 --- a/db/changes/10470-family/00-zoneHoliday.sql +++ b/db/changes/10470-family/00-zoneHoliday.sql @@ -1,12 +1,13 @@ CREATE TABLE `vn`.`zoneExclusionGeo` ( + `id` int(11) NOT NULL AUTO_INCREMENT, `zoneExclusionFk` int(11) NOT NULL, `geoFk` int(11) NOT NULL, - PRIMARY KEY (`zoneExclusionFk`,`geoFk`), + PRIMARY KEY (`id`), + UNIQUE KEY `zoneExclusionGeo_UN` (`zoneExclusionFk`,`geoFk`), KEY `zoneExclusionGeo2_FK_1` (`geoFk`), - 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; - + CONSTRAINT `zoneExclusionGeo_FK` FOREIGN KEY (`geoFk`) REFERENCES `zoneGeo` (`id`) ON UPDATE CASCADE, + CONSTRAINT `zoneExclusionGeo_FK_1` FOREIGN KEY (`zoneExclusionFk`) REFERENCES `zoneExclusion` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; DROP PROCEDURE IF EXISTS `vn`.`zone_excludeFromGeo`; DELIMITER $$ diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index d9e0b5e08..ef48e4c38 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -2029,6 +2029,8 @@ INSERT INTO `vn`.`zoneEvent`(`zoneFk`, `type`, `dated`) (1, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=4, 4, 11) - DAYOFWEEK(CURDATE())) DAY)), (1, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=5, 5, 12) - DAYOFWEEK(CURDATE())) DAY)), (1, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=6, 6, 13) - DAYOFWEEK(CURDATE())) DAY)), + (1, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=7, 7, 14) - DAYOFWEEK(CURDATE())) DAY)), + (1, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=8, 8, 15) - DAYOFWEEK(CURDATE())) DAY)), (2, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=2, 2, 9) - DAYOFWEEK(CURDATE())) DAY)), (2, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=3, 3, 10) - DAYOFWEEK(CURDATE())) DAY)), (2, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=4, 4, 11) - DAYOFWEEK(CURDATE())) DAY)), @@ -2578,9 +2580,9 @@ INSERT INTO `vn`.`machineWorker` (`workerFk`, `machineFk`, `inTimed`, `outTimed` (1106, 2, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), DATE_ADD(CURDATE(), INTERVAL +1 DAY)); INSERT INTO `vn`.`zoneExclusion` (`id`, `zoneFk`, `dated`, `created`, `userFk`) -VALUES - (1, 1, DATE_ADD(CURDATE(), INTERVAL + 10 DAY), CURDATE(), 100), - (2, 1, DATE_ADD(CURDATE(), INTERVAL + 12 DAY), CURDATE(), 100); +VALUES + (1, 1, DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=7, 7, 14) - DAYOFWEEK(CURDATE())) DAY), CURDATE(), 100), + (2, 1, DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=8, 8, 15) - DAYOFWEEK(CURDATE())) DAY), CURDATE(), 100); INSERT INTO `vn`.`zoneExclusionGeo` (`zoneExclusionFk`, `geoFk`) VALUES diff --git a/modules/zone/front/events/index.js b/modules/zone/front/events/index.js index 115130f73..ab3f0d766 100644 --- a/modules/zone/front/events/index.js +++ b/modules/zone/front/events/index.js @@ -240,7 +240,7 @@ class Controller extends Section { const params = { zoneFk: parseInt(this.$params.id), date: excludeSelected.dated, - geoFk: geoIds + geoIds: geoIds }; if (this.isNew) @@ -252,9 +252,9 @@ class Controller extends Section { if (geoIds[actualPosition]) geoId = geoIds[actualPosition].id; else geoId = null; - if (geoId) { + if (geoId && geoId == exclusionGeo.geoFk) { const params = { - zoneExclusionFk: excludeSelected.zoneExclusionFk, + zoneExclusionFk: exclusionGeo.zoneExclusionFk, geoFk: geoId }; req = this.$http.put(`ZoneExclusionGeos/${exclusionGeo.id}`, params);