#5858 - zoneCollisions #1853

Merged
jsegarra merged 78 commits from 5858-zone_Collisions into dev 2024-03-15 12:36:38 +00:00
7 changed files with 36 additions and 20 deletions
Showing only changes of commit 4383ebd7f1 - Show all commits

View File

@ -17,7 +17,8 @@ BEGIN
`zoneFk` = NEW.zoneFk, `zoneFk` = NEW.zoneFk,
`geoFk` = NEW.geoFk, `geoFk` = NEW.geoFk,
`userFk` = account.myUser_getId(); `userFk` = account.myUser_getId();
CALL `vn`.`zoneIncluded_checkCollisions`(); -- CALL `vn`.`zoneIncluded_checkCollisions`(NEW.zoneFk, NEW.geoFk);
END$$ END$$
DELIMITER ; DELIMITER ;
@ -41,7 +42,7 @@ BEGIN
`geoFk` = NEW.geoFk, `geoFk` = NEW.geoFk,
`userFk` = account.myUser_getId(); `userFk` = account.myUser_getId();
CALL `vn`.`zoneIncluded_checkCollisions`(); -- CALL `vn`.`zoneIncluded_checkCollisions`();
END$$ END$$
@ -67,6 +68,6 @@ BEGIN
`geoFk` = OLD.geoFk, `geoFk` = OLD.geoFk,
`userFk` = account.myUser_getId(); `userFk` = account.myUser_getId();
CALL `vn`.`zoneIncluded_checkCollisions`(); -- CALL `vn`.`zoneIncluded_checkCollisions`();
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -1,5 +1,7 @@
-- DROP PROCEDURE IF EXISTS `vn`.`zoneIncluded_checkCollisions`; DROP PROCEDURE IF EXISTS `vn`.`zoneIncluded_checkCollisions`;
CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zoneIncluded_checkCollisions`(IN id INT) DELIMITER $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zoneIncluded_checkCollisions`(IN zi_zone INT, IN zi_geo INT)
BEGIN BEGIN
DECLARE done INT DEFAULT 0; DECLARE done INT DEFAULT 0;
DECLARE zic_id, zic_zone, zic_geo, zic_action, zic_userFk INT; DECLARE zic_id, zic_zone, zic_geo, zic_action, zic_userFk INT;
@ -27,4 +29,5 @@ OPEN my_cur;
CLOSE my_cur; CLOSE my_cur;
END END$$
DELIMITER ;

View File

@ -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"

View File

@ -1,8 +1,9 @@
const models = require('vn-loopback/server/server').models; const models = require('vn-loopback/server/server').models;
const LoopBackContext = require('loopback-context'); const LoopBackContext = require('loopback-context');
let conn = null;
describe('zone toggleIsIncluded()', () => { describe('zone toggleIsIncluded()', () => {
beforeAll(async() => { beforeAll(async() => {
conn = await models.Item.dataSource.connector;
const activeCtx = { const activeCtx = {
accessToken: {userId: 9}, accessToken: {userId: 9},
http: { 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({}); const tx = await models.Zone.beginTransaction({});
try { try {
let toCheck = await conn.executeStmt({sql: ' SELECT * FROM zoneIncludedCheck'});
expect(toCheck.length).toEqual(0);
const options = {transaction: tx}; const options = {transaction: tx};
let result = await models.Zone.toggleIsIncluded(1, 20, true, options); let result = await models.Zone.toggleIsIncluded(1, 20, true, options);
expect(result.isIncluded).toBeTrue(); 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(); await tx.rollback();
} catch (e) { } catch (e) {

View File

@ -1,2 +1,2 @@
subject: Colisión de zona {0} detectada subject: Colisión de zona detectada
title: "La localización {0} ha sido registrada en más de un sitio" title: "La zona {0} y localización {1} ha sido registrada en más de un sitio"

View File

@ -1,8 +1,8 @@
<email-body v-bind="$props"> <email-body v-bind="$props">
<div class="grid-row"> <div class="grid-row">
<div class="grid-block vn-pa-ml"> <div class="grid-block vn-pa-ml">
<h1>{{ $t('subject', [zoneSelected]) }}</h1> <h1>{{ $t('subject') }}</h1>
<p>{{ $t('title', [geoSelected]) }}</p> <p>{{ $t('title', [zoneSelected,geoSelected]) }}</p>
</div> </div>
</div> </div>
</email-body> </email-body>

View File

@ -3,14 +3,6 @@ const emailBody = new Component('email-body');
module.exports = { module.exports = {
name: 'zone-included', name: 'zone-included',
async serverPrefetch() {
this.zoneIncluded = await this.fetchZoneIncluded(this.id);
},
methods: {
fetchZoneIncluded(id) {
return this.findOneFromDef('zoneIncluded', [id]);
},
},
components: { components: {
'email-body': emailBody.build(), 'email-body': emailBody.build(),
}, },