diff --git a/db/changes/234801/00-zoneIncluded_trigger.sql b/db/changes/234801/00-zoneIncluded_trigger.sql index 521ca2601..4de0416b7 100644 --- a/db/changes/234801/00-zoneIncluded_trigger.sql +++ b/db/changes/234801/00-zoneIncluded_trigger.sql @@ -17,7 +17,8 @@ BEGIN `zoneFk` = NEW.zoneFk, `geoFk` = NEW.geoFk, `userFk` = account.myUser_getId(); - CALL `vn`.`zoneIncluded_checkCollisions`(); + -- CALL `vn`.`zoneIncluded_checkCollisions`(NEW.zoneFk, NEW.geoFk); + END$$ DELIMITER ; @@ -41,7 +42,7 @@ BEGIN `geoFk` = NEW.geoFk, `userFk` = account.myUser_getId(); - CALL `vn`.`zoneIncluded_checkCollisions`(); + -- CALL `vn`.`zoneIncluded_checkCollisions`(); END$$ @@ -67,6 +68,6 @@ BEGIN `geoFk` = OLD.geoFk, `userFk` = account.myUser_getId(); - CALL `vn`.`zoneIncluded_checkCollisions`(); + -- CALL `vn`.`zoneIncluded_checkCollisions`(); END$$ DELIMITER ; diff --git a/db/changes/234801/03-zoneIncluded_procedure_checkCollisions.sql b/db/changes/234801/03-zoneIncluded_procedure_checkCollisions.sql index 84d0e363f..ccfb8f3b8 100644 --- a/db/changes/234801/03-zoneIncluded_procedure_checkCollisions.sql +++ b/db/changes/234801/03-zoneIncluded_procedure_checkCollisions.sql @@ -1,5 +1,7 @@ --- DROP PROCEDURE IF EXISTS `vn`.`zoneIncluded_checkCollisions`; -CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zoneIncluded_checkCollisions`(IN id INT) +DROP PROCEDURE IF EXISTS `vn`.`zoneIncluded_checkCollisions`; +DELIMITER $$ + +CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zoneIncluded_checkCollisions`(IN zi_zone INT, IN zi_geo INT) BEGIN DECLARE done INT DEFAULT 0; DECLARE zic_id, zic_zone, zic_geo, zic_action, zic_userFk INT; @@ -27,4 +29,5 @@ OPEN my_cur; CLOSE my_cur; -END +END$$ +DELIMITER ; diff --git a/db/changes/234801/06-zoneincluded_notification.sql b/db/changes/234801/06-zoneincluded_notification.sql new file mode 100644 index 000000000..53b2a9189 --- /dev/null +++ b/db/changes/234801/06-zoneincluded_notification.sql @@ -0,0 +1,11 @@ +-- Auto-generated SQL script #202311241021 +INSERT INTO util.notification (name,description) + VALUES ('zone-included','An email to notify zoneCollisions'); + +-- Auto-generated SQL script #202311241051 +INSERT INTO util.notificationSubscription (notificationFk,userFk) + SELECT id, account.myUser_getId() FROM util.notification WHERE name= "zone-included" + + +INSERT INTO util.notificationAcl (notificationFk,roleFk) + SELECT id, account.role FROM util.notification WHERE name= "zone-included" diff --git a/modules/zone/back/methods/zone/specs/toggleIsIncluded.spec.js b/modules/zone/back/methods/zone/specs/toggleIsIncluded.spec.js index 746a2d0bd..3e72408cf 100644 --- a/modules/zone/back/methods/zone/specs/toggleIsIncluded.spec.js +++ b/modules/zone/back/methods/zone/specs/toggleIsIncluded.spec.js @@ -1,8 +1,9 @@ const models = require('vn-loopback/server/server').models; const LoopBackContext = require('loopback-context'); - +let conn = null; describe('zone toggleIsIncluded()', () => { beforeAll(async() => { + conn = await models.Item.dataSource.connector; const activeCtx = { accessToken: {userId: 9}, http: { @@ -16,15 +17,23 @@ describe('zone toggleIsIncluded()', () => { }); }); - it('should return the created location with isIncluded true', async() => { + fit('should return the created location with isIncluded true', async() => { const tx = await models.Zone.beginTransaction({}); try { + let toCheck = await conn.executeStmt({sql: ' SELECT * FROM zoneIncludedCheck'}); + + expect(toCheck.length).toEqual(0); const options = {transaction: tx}; let result = await models.Zone.toggleIsIncluded(1, 20, true, options); expect(result.isIncluded).toBeTrue(); + toCheck = await conn.executeStmt({sql: ' SELECT * FROM zoneIncludedCheck'}); + + expect(toCheck.length).not.toEqual(1); + + await conn.executeStmt({sql: 'CALL vn.zoneIncluded_checkCollisions(?, ? )', params: [0, 0]}); await tx.rollback(); } catch (e) { diff --git a/print/templates/email/zone-included/locale/es.yml b/print/templates/email/zone-included/locale/es.yml index 5cf617ba3..57d257663 100644 --- a/print/templates/email/zone-included/locale/es.yml +++ b/print/templates/email/zone-included/locale/es.yml @@ -1,2 +1,2 @@ -subject: Colisión de zona {0} detectada -title: "La localización {0} ha sido registrada en más de un sitio" +subject: Colisión de zona detectada +title: "La zona {0} y localización {1} ha sido registrada en más de un sitio" diff --git a/print/templates/email/zone-included/zone-included.html b/print/templates/email/zone-included/zone-included.html index eafa6513f..76f59e9f9 100644 --- a/print/templates/email/zone-included/zone-included.html +++ b/print/templates/email/zone-included/zone-included.html @@ -1,8 +1,8 @@
-

{{ $t('subject', [zoneSelected]) }}

-

{{ $t('title', [geoSelected]) }}

+

{{ $t('subject') }}

+

{{ $t('title', [zoneSelected,geoSelected]) }}

diff --git a/print/templates/email/zone-included/zone-included.js b/print/templates/email/zone-included/zone-included.js index caac6cfd6..6ed8964b1 100755 --- a/print/templates/email/zone-included/zone-included.js +++ b/print/templates/email/zone-included/zone-included.js @@ -3,14 +3,6 @@ const emailBody = new Component('email-body'); module.exports = { name: 'zone-included', - async serverPrefetch() { - this.zoneIncluded = await this.fetchZoneIncluded(this.id); - }, - methods: { - fetchZoneIncluded(id) { - return this.findOneFromDef('zoneIncluded', [id]); - }, - }, components: { 'email-body': emailBody.build(), },