From 61d41fb687580387976a1b15d6c1dd2d64f5aa54 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Wed, 19 Apr 2023 08:54:58 +0200 Subject: [PATCH 01/13] refs #5507 --- front/salix/routes.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/front/salix/routes.js b/front/salix/routes.js index f32c143ef..28e227d15 100644 --- a/front/salix/routes.js +++ b/front/salix/routes.js @@ -1,8 +1,8 @@ import ngModule from './module'; import getMainRoute from 'core/lib/get-main-route'; -config.$inject = ['$stateProvider', '$urlRouterProvider']; -function config($stateProvider, $urlRouterProvider) { +config.$inject = ['$stateProvider', '$urlRouterProvider', 'vnConfig']; +function config($stateProvider, $urlRouterProvider, vnConfig) { $urlRouterProvider .otherwise('/'); @@ -10,6 +10,7 @@ function config($stateProvider, $urlRouterProvider) { .state('layout', { abstract: true, template: '', + resolve: () => vnConfig.initialize() }) .state('outLayout', { abstract: true, From ded8e0e141d2a8612ec5c0f64ae6b4243cd0d8a2 Mon Sep 17 00:00:00 2001 From: alexandre Date: Wed, 10 May 2023 13:22:53 +0200 Subject: [PATCH 02/13] refs #5137 added trigger, template and test --- db/changes/232001/.gitkeep | 0 db/changes/232001/00-printer.sql | 3 + db/dump/fixtures.sql | 3 + modules/shelving/back/models/sector.json | 4 +- .../methods/operator/spec/operator.spec.js | 63 +++++++++++++++++++ modules/worker/back/models/operator.js | 30 +++++++++ modules/worker/back/models/operator.json | 6 +- .../assets/css/import.js | 11 ++++ .../not-main-printer-configured/locale/en.yml | 3 + .../not-main-printer-configured/locale/es.yml | 3 + .../not-main-printer-configured.html | 8 +++ .../not-main-printer-configured.js | 27 ++++++++ 12 files changed, 156 insertions(+), 5 deletions(-) delete mode 100644 db/changes/232001/.gitkeep create mode 100644 db/changes/232001/00-printer.sql create mode 100644 modules/worker/back/methods/operator/spec/operator.spec.js create mode 100644 modules/worker/back/models/operator.js create mode 100644 print/templates/email/not-main-printer-configured/assets/css/import.js create mode 100644 print/templates/email/not-main-printer-configured/locale/en.yml create mode 100644 print/templates/email/not-main-printer-configured/locale/es.yml create mode 100644 print/templates/email/not-main-printer-configured/not-main-printer-configured.html create mode 100755 print/templates/email/not-main-printer-configured/not-main-printer-configured.js diff --git a/db/changes/232001/.gitkeep b/db/changes/232001/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/db/changes/232001/00-printer.sql b/db/changes/232001/00-printer.sql new file mode 100644 index 000000000..6280c2c6d --- /dev/null +++ b/db/changes/232001/00-printer.sql @@ -0,0 +1,3 @@ +ALTER TABLE `vn`.`sector` DROP COLUMN `printerFk`; +ALTER TABLE `vn`.`sector` ADD COLUMN `mainPrinterFk` tinyint(3) unsigned; +ALTER TABLE `vn`.`sector` ADD CONSTRAINT sector_FK_1 FOREIGN KEY (mainPrinterFk) REFERENCES vn.printer(id) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index e69974d08..79924292e 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -179,6 +179,8 @@ INSERT INTO `vn`.`printer` (`id`, `name`, `path`, `isLabeler`, `sectorFk`, `ipAd (2, 'printer2', 'path2', 1, 1 , NULL), (4, 'printer4', 'path4', 0, NULL, '10.1.10.4'); +UPDATE `vn`.`sector` SET mainPrinterFk = 1 WHERE id = 1; + INSERT INTO `vn`.`worker`(`id`, `code`, `firstName`, `lastName`, `userFk`,`bossFk`, `phone`, `sectorFk`, `labelerFk`) VALUES (1106, 'LGN', 'David Charles', 'Haller', 1106, 19, 432978106, NULL, NULL), @@ -2719,6 +2721,7 @@ INSERT INTO `util`.`notification` (`id`, `name`, `description`) VALUES (1, 'print-email', 'notification fixture one'), (2, 'invoice-electronic', 'A electronic invoice has been generated'), + (3, 'not-main-printer-configured', 'A printer distinct than main has been configured'), (4, 'supplier-pay-method-update', 'A supplier pay method has been updated'); INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`) diff --git a/modules/shelving/back/models/sector.json b/modules/shelving/back/models/sector.json index 0dc502cd0..47d66bd8d 100644 --- a/modules/shelving/back/models/sector.json +++ b/modules/shelving/back/models/sector.json @@ -56,7 +56,7 @@ "type": "number", "required": false }, - "printerFk": { + "mainPrinterFk": { "type": "number", "required": false }, @@ -69,4 +69,4 @@ "required": true } } -} \ No newline at end of file +} diff --git a/modules/worker/back/methods/operator/spec/operator.spec.js b/modules/worker/back/methods/operator/spec/operator.spec.js new file mode 100644 index 000000000..5f099040a --- /dev/null +++ b/modules/worker/back/methods/operator/spec/operator.spec.js @@ -0,0 +1,63 @@ +const models = require('vn-loopback/server/server').models; + +describe('Operator', () => { + const authorFk = 9; + const sectorId = 1; + const mainPrinter = 1; + const notificationName = 'not-main-printer-configured'; + const operator = { + workerFk: 1, + trainFk: 1, + itemPackingTypeFk: 'H', + warehouseFk: 1, + sectorFk: sectorId + }; + + async function createOperator(labelerFk, options) { + operator.labelerFk = labelerFk; + await models.Operator.create(operator, options); + return models.NotificationQueue.findOne({ + where: { + notificationFk: notificationName + } + }, options); + } + + it('should create notification when configured a not main printer in the sector', async() => { + const tx = await models.Operator.beginTransaction({}); + + try { + const options = {transaction: tx, accessToken: {userId: authorFk}}; + const notificationQueue = await createOperator(2, options); + const params = JSON.parse(notificationQueue.params); + + expect(notificationQueue.notificationFk).toEqual(notificationName); + expect(notificationQueue.authorFk).toEqual(authorFk); + expect(params.labeler).toContain('2'); + expect(params.sector).toContain('1'); + expect(params.mainPrinter).toContain('1'); + expect(params.worker).toContain('9'); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('should not create notification when configured the main printer in the sector', async() => { + const tx = await models.Operator.beginTransaction({}); + + try { + const options = {transaction: tx, accessToken: {userId: authorFk}}; + const notificationQueue = await createOperator(mainPrinter, options); + + expect(notificationQueue).toEqual(null); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); +}); diff --git a/modules/worker/back/models/operator.js b/modules/worker/back/models/operator.js new file mode 100644 index 000000000..d2887111c --- /dev/null +++ b/modules/worker/back/models/operator.js @@ -0,0 +1,30 @@ +module.exports = function(Self) { + Self.observe('after save', async function(ctx) { + const instance = ctx.instance; + const models = Self.app.models; + const options = ctx.options; + + if (!instance.sectorFk || !instance.labelerFk) return; + const sector = await models.Sector.findById(instance.sectorFk, { + fields: ['description', 'mainPrinterFk'] + }, options); + if (sector.mainPrinterFk && sector.mainPrinterFk != instance.labelerFk) { + const userId = ctx.options.accessToken.userId; + const user = await models.VnUser.findById(userId, {fields: ['nickname']}, options); + const labeler = await models.Printer.findById(instance.labelerFk, {fields: ['name']}, options); + const mainPrinter = await models.Printer.findById(sector.mainPrinterFk, {fields: ['name']}, options); + await models.NotificationQueue.create({ + notificationFk: 'not-main-printer-configured', + authorFk: userId, + params: JSON.stringify( + { + 'labeler': `#${instance.labelerFk} ${labeler.name}`, + 'sector': `#${instance.sectorFk} ${sector.description}`, + 'mainPrinter': `#${sector.mainPrinterFk} ${mainPrinter.name}`, + 'worker': `#${userId} ${user.nickname}` + } + ) + }, options); + } + }); +}; diff --git a/modules/worker/back/models/operator.json b/modules/worker/back/models/operator.json index db8a8c451..9433a0fd5 100644 --- a/modules/worker/back/models/operator.json +++ b/modules/worker/back/models/operator.json @@ -27,10 +27,10 @@ "type": "number", "required": true }, - "sectorFk ": { + "sectorFk": { "type": "number" }, - "labelerFk ": { + "labelerFk": { "type": "number" } }, @@ -41,4 +41,4 @@ "foreignKey": "sectorFk" } } -} \ No newline at end of file +} diff --git a/print/templates/email/not-main-printer-configured/assets/css/import.js b/print/templates/email/not-main-printer-configured/assets/css/import.js new file mode 100644 index 000000000..4b4bb7086 --- /dev/null +++ b/print/templates/email/not-main-printer-configured/assets/css/import.js @@ -0,0 +1,11 @@ +const Stylesheet = require(`vn-print/core/stylesheet`); + +const path = require('path'); +const vnPrintPath = path.resolve('print'); + +module.exports = new Stylesheet([ + `${vnPrintPath}/common/css/spacing.css`, + `${vnPrintPath}/common/css/misc.css`, + `${vnPrintPath}/common/css/layout.css`, + `${vnPrintPath}/common/css/email.css`]) + .mergeStyles(); diff --git a/print/templates/email/not-main-printer-configured/locale/en.yml b/print/templates/email/not-main-printer-configured/locale/en.yml new file mode 100644 index 000000000..5da9d2595 --- /dev/null +++ b/print/templates/email/not-main-printer-configured/locale/en.yml @@ -0,0 +1,3 @@ +subject: Not main printer configured +title: Not main printer configured +description: Printer {0} has been configured in sector {1} (the main printer for that sector is {2}). Ask the worker {3} diff --git a/print/templates/email/not-main-printer-configured/locale/es.yml b/print/templates/email/not-main-printer-configured/locale/es.yml new file mode 100644 index 000000000..a8b207a54 --- /dev/null +++ b/print/templates/email/not-main-printer-configured/locale/es.yml @@ -0,0 +1,3 @@ +subject: Configurada impresora no principal +title: Configurada impresora no principal +description: Se ha configurado la impresora {0} en el sector {1} (la impresora principal de ese sector es la {2}). Preguntar al trabajador {3}. diff --git a/print/templates/email/not-main-printer-configured/not-main-printer-configured.html b/print/templates/email/not-main-printer-configured/not-main-printer-configured.html new file mode 100644 index 000000000..06ab6d0b0 --- /dev/null +++ b/print/templates/email/not-main-printer-configured/not-main-printer-configured.html @@ -0,0 +1,8 @@ + +
+
+

{{ $t('title') }}

+

+
+
+
diff --git a/print/templates/email/not-main-printer-configured/not-main-printer-configured.js b/print/templates/email/not-main-printer-configured/not-main-printer-configured.js new file mode 100755 index 000000000..2c3e3521a --- /dev/null +++ b/print/templates/email/not-main-printer-configured/not-main-printer-configured.js @@ -0,0 +1,27 @@ +const Component = require(`vn-print/core/component`); +const emailBody = new Component('email-body'); + +module.exports = { + name: 'not-main-printer-configured', + components: { + 'email-body': emailBody.build(), + }, + props: { + labeler: { + type: String, + required: true + }, + sector: { + type: String, + required: true + }, + mainPrinter: { + type: String, + required: true + }, + worker: { + type: String, + required: true + } + } +}; From 62d0af25d3504ed399292b4cf34f6c08aa70416d Mon Sep 17 00:00:00 2001 From: alexandre Date: Tue, 16 May 2023 13:31:22 +0200 Subject: [PATCH 03/13] refs #5642 uncommented tests --- .../05-ticket/01-sale/02_edit_sale.spec.js | 2 +- e2e/paths/05-ticket/21_future.spec.js | 91 +++++++++---------- e2e/paths/05-ticket/22_advance.spec.js | 63 +++++++------ 3 files changed, 77 insertions(+), 79 deletions(-) diff --git a/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js b/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js index 2c9646708..a87e00543 100644 --- a/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js +++ b/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js @@ -316,7 +316,7 @@ describe('Ticket Edit sale path', () => { it('should confirm the transfered quantity is the correct one', async() => { const result = await page.waitToGetProperty(selectors.ticketSales.secondSaleQuantityCell, 'innerText'); - expect(result).toContain('10'); + expect(result).toContain('20'); }); it('should go back to the original ticket sales section', async() => { diff --git a/e2e/paths/05-ticket/21_future.spec.js b/e2e/paths/05-ticket/21_future.spec.js index 82525c1db..1a101e9f1 100644 --- a/e2e/paths/05-ticket/21_future.spec.js +++ b/e2e/paths/05-ticket/21_future.spec.js @@ -1,8 +1,7 @@ import selectors from '../../helpers/selectors.js'; import getBrowser from '../../helpers/puppeteer'; -// 'https:// redmine.verdnatura.es/issues/5642' -xdescribe('Ticket Future path', () => { +describe('Ticket Future path', () => { let browser; let page; let httpRequest; @@ -45,67 +44,67 @@ xdescribe('Ticket Future path', () => { expect(message.text).toContain('originDated is a required argument'); }); - // it('should search with the required data', async() => { - // await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - // await page.waitToClick(selectors.ticketFuture.submit); + it('should search with the required data', async() => { + await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); + await page.waitToClick(selectors.ticketFuture.submit); - // expect(httpRequest).toBeDefined(); - // }); + expect(httpRequest).toBeDefined(); + }); - // it('should search with the origin IPT', async() => { - // await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); + it('should search with the origin IPT', async() => { + await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - // await page.autocompleteSearch(selectors.ticketFuture.ipt, 'H'); - // await page.waitToClick(selectors.ticketFuture.submit); + await page.autocompleteSearch(selectors.ticketFuture.ipt, 'H'); + await page.waitToClick(selectors.ticketFuture.submit); - // expect(httpRequest).toContain('ipt=H'); - // }); + expect(httpRequest).toContain('ipt=H'); + }); - // it('should search with the destination IPT', async() => { - // await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); + it('should search with the destination IPT', async() => { + await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - // await page.clearInput(selectors.ticketFuture.ipt); + await page.clearInput(selectors.ticketFuture.ipt); - // await page.autocompleteSearch(selectors.ticketFuture.futureIpt, 'H'); - // await page.waitToClick(selectors.ticketFuture.submit); + await page.autocompleteSearch(selectors.ticketFuture.futureIpt, 'H'); + await page.waitToClick(selectors.ticketFuture.submit); - // expect(httpRequest).toContain('futureIpt=H'); - // }); + expect(httpRequest).toContain('futureIpt=H'); + }); - // it('should search with the origin grouped state', async() => { - // await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); + it('should search with the origin grouped state', async() => { + await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - // await page.clearInput(selectors.ticketFuture.futureIpt); + await page.clearInput(selectors.ticketFuture.futureIpt); - // await page.autocompleteSearch(selectors.ticketFuture.state, 'Free'); - // await page.waitToClick(selectors.ticketFuture.submit); + await page.autocompleteSearch(selectors.ticketFuture.state, 'Free'); + await page.waitToClick(selectors.ticketFuture.submit); - // expect(httpRequest).toContain('state=FREE'); - // }); + expect(httpRequest).toContain('state=FREE'); + }); - // it('should search with the destination grouped state', async() => { - // await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); + it('should search with the destination grouped state', async() => { + await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - // await page.clearInput(selectors.ticketFuture.state); + await page.clearInput(selectors.ticketFuture.state); - // await page.autocompleteSearch(selectors.ticketFuture.futureState, 'Free'); - // await page.waitToClick(selectors.ticketFuture.submit); + await page.autocompleteSearch(selectors.ticketFuture.futureState, 'Free'); + await page.waitToClick(selectors.ticketFuture.submit); - // expect(httpRequest).toContain('futureState=FREE'); + expect(httpRequest).toContain('futureState=FREE'); - // await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - // await page.clearInput(selectors.ticketFuture.futureState); - // await page.waitToClick(selectors.ticketFuture.submit); - // }); + await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); + await page.clearInput(selectors.ticketFuture.futureState); + await page.waitToClick(selectors.ticketFuture.submit); + }); - // it('should check the three last tickets and move to the future', async() => { - // await page.waitForNumberOfElements(selectors.ticketFuture.searchResult, 4); - // await page.waitToClick(selectors.ticketFuture.multiCheck); - // await page.waitToClick(selectors.ticketFuture.firstCheck); - // await page.waitToClick(selectors.ticketFuture.moveButton); - // await page.waitToClick(selectors.globalItems.acceptButton); - // const message = await page.waitForSnackbar(); + it('should check the three last tickets and move to the future', async() => { + await page.waitForNumberOfElements(selectors.ticketFuture.searchResult, 4); + await page.waitToClick(selectors.ticketFuture.multiCheck); + await page.waitToClick(selectors.ticketFuture.firstCheck); + await page.waitToClick(selectors.ticketFuture.moveButton); + await page.waitToClick(selectors.globalItems.acceptButton); + const message = await page.waitForSnackbar(); - // expect(message.text).toContain('Tickets moved successfully!'); - // }); + expect(message.text).toContain('Tickets moved successfully!'); + }); }); diff --git a/e2e/paths/05-ticket/22_advance.spec.js b/e2e/paths/05-ticket/22_advance.spec.js index f27120b3b..d845219c5 100644 --- a/e2e/paths/05-ticket/22_advance.spec.js +++ b/e2e/paths/05-ticket/22_advance.spec.js @@ -1,8 +1,7 @@ import selectors from '../../helpers/selectors.js'; import getBrowser from '../../helpers/puppeteer'; -// 'https:// redmine.verdnatura.es/issues/5642' -xdescribe('Ticket Advance path', () => { +describe('Ticket Advance path', () => { let browser; let page; let httpRequest; @@ -46,43 +45,43 @@ xdescribe('Ticket Advance path', () => { expect(message.text).toContain('dateFuture is a required argument'); }); - // it('should search with the required data', async() => { - // await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); - // await page.waitToClick(selectors.ticketAdvance.submit); + it('should search with the required data', async() => { + await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); + await page.waitToClick(selectors.ticketAdvance.submit); - // expect(httpRequest).toBeDefined(); - // }); + expect(httpRequest).toBeDefined(); + }); - // it('should search with the origin IPT', async() => { - // await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); - // await page.autocompleteSearch(selectors.ticketAdvance.futureIpt, 'H'); - // await page.waitToClick(selectors.ticketAdvance.submit); + it('should search with the origin IPT', async() => { + await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); + await page.autocompleteSearch(selectors.ticketAdvance.futureIpt, 'H'); + await page.waitToClick(selectors.ticketAdvance.submit); - // expect(httpRequest).toContain('futureIpt=H'); + expect(httpRequest).toContain('futureIpt=H'); - // await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); - // await page.clearInput(selectors.ticketAdvance.futureIpt); - // await page.waitToClick(selectors.ticketAdvance.submit); - // }); + await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); + await page.clearInput(selectors.ticketAdvance.futureIpt); + await page.waitToClick(selectors.ticketAdvance.submit); + }); - // it('should search with the destination IPT', async() => { - // await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); - // await page.autocompleteSearch(selectors.ticketAdvance.ipt, 'H'); - // await page.waitToClick(selectors.ticketAdvance.submit); + it('should search with the destination IPT', async() => { + await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); + await page.autocompleteSearch(selectors.ticketAdvance.ipt, 'H'); + await page.waitToClick(selectors.ticketAdvance.submit); - // expect(httpRequest).toContain('ipt=H'); + expect(httpRequest).toContain('ipt=H'); - // await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); - // await page.clearInput(selectors.ticketAdvance.ipt); - // await page.waitToClick(selectors.ticketAdvance.submit); - // }); + await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); + await page.clearInput(selectors.ticketAdvance.ipt); + await page.waitToClick(selectors.ticketAdvance.submit); + }); - // it('should check the first ticket and move to the present', async() => { - // await page.waitToClick(selectors.ticketAdvance.firstCheck); - // await page.waitToClick(selectors.ticketAdvance.moveButton); - // await page.waitToClick(selectors.ticketAdvance.acceptButton); - // const message = await page.waitForSnackbar(); + it('should check the first ticket and move to the present', async() => { + await page.waitToClick(selectors.ticketAdvance.firstCheck); + await page.waitToClick(selectors.ticketAdvance.moveButton); + await page.waitToClick(selectors.ticketAdvance.acceptButton); + const message = await page.waitForSnackbar(); - // expect(message.text).toContain('Tickets moved successfully!'); - // }); + expect(message.text).toContain('Tickets moved successfully!'); + }); }); From ca9d76db77a54e9929be16079eeff7e54958bdf7 Mon Sep 17 00:00:00 2001 From: alexandre Date: Thu, 18 May 2023 14:47:41 +0200 Subject: [PATCH 04/13] refs #5137 moved sql --- db/changes/232201/.gitkeep | 0 db/changes/{232001 => 232201}/00-printer.sql | 0 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 db/changes/232201/.gitkeep rename db/changes/{232001 => 232201}/00-printer.sql (100%) diff --git a/db/changes/232201/.gitkeep b/db/changes/232201/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/db/changes/232001/00-printer.sql b/db/changes/232201/00-printer.sql similarity index 100% rename from db/changes/232001/00-printer.sql rename to db/changes/232201/00-printer.sql From a7363ce2a4e5d0461ea460aa1d7e13d89b8107bd Mon Sep 17 00:00:00 2001 From: alexandre Date: Thu, 25 May 2023 11:23:33 +0200 Subject: [PATCH 05/13] refs #5507 added service --- front/core/services/index.js | 1 - front/salix/components/user-popover/index.js | 2 -- front/salix/index.js | 1 + front/salix/routes.js | 8 +++++--- front/{core => salix}/services/config.js | 0 front/salix/services/index.js | 1 + 6 files changed, 7 insertions(+), 6 deletions(-) rename front/{core => salix}/services/config.js (100%) create mode 100644 front/salix/services/index.js diff --git a/front/core/services/index.js b/front/core/services/index.js index 867a13df0..f61ad125e 100644 --- a/front/core/services/index.js +++ b/front/core/services/index.js @@ -5,7 +5,6 @@ import './auth'; import './token'; import './modules'; import './interceptor'; -import './config'; import './week-days'; import './report'; import './email'; diff --git a/front/salix/components/user-popover/index.js b/front/salix/components/user-popover/index.js index 6cc47db7d..1d88137ff 100644 --- a/front/salix/components/user-popover/index.js +++ b/front/salix/components/user-popover/index.js @@ -20,8 +20,6 @@ class Controller { name: config.languages[code] ? config.languages[code] : code }); } - - vnConfig.initialize(); } set lang(value) { diff --git a/front/salix/index.js b/front/salix/index.js index 2488ef9b6..cac169405 100644 --- a/front/salix/index.js +++ b/front/salix/index.js @@ -3,3 +3,4 @@ import './routes'; import './components'; import './styles'; import 'vn-loopback/server/boot/date'; +import './services'; diff --git a/front/salix/routes.js b/front/salix/routes.js index 28e227d15..4cc72ec95 100644 --- a/front/salix/routes.js +++ b/front/salix/routes.js @@ -1,8 +1,8 @@ import ngModule from './module'; import getMainRoute from 'core/lib/get-main-route'; -config.$inject = ['$stateProvider', '$urlRouterProvider', 'vnConfig']; -function config($stateProvider, $urlRouterProvider, vnConfig) { +config.$inject = ['$stateProvider', '$urlRouterProvider']; +function config($stateProvider, $urlRouterProvider) { $urlRouterProvider .otherwise('/'); @@ -10,7 +10,9 @@ function config($stateProvider, $urlRouterProvider, vnConfig) { .state('layout', { abstract: true, template: '', - resolve: () => vnConfig.initialize() + resolve: { + config: ['vnConfig', vnConfig => vnConfig.initialize()] + } }) .state('outLayout', { abstract: true, diff --git a/front/core/services/config.js b/front/salix/services/config.js similarity index 100% rename from front/core/services/config.js rename to front/salix/services/config.js diff --git a/front/salix/services/index.js b/front/salix/services/index.js new file mode 100644 index 000000000..c791e6492 --- /dev/null +++ b/front/salix/services/index.js @@ -0,0 +1 @@ +import './config'; From be06a65a45dd8050ec4d0edf9d37c3e0d070202b Mon Sep 17 00:00:00 2001 From: alexandre Date: Fri, 26 May 2023 11:53:32 +0200 Subject: [PATCH 06/13] refs #5507 fixed e2e --- .../01-salix/03_smartTable_searchBar_integrations.spec.js | 2 +- e2e/paths/04-item/13_fixedPrice.spec.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/e2e/paths/01-salix/03_smartTable_searchBar_integrations.spec.js b/e2e/paths/01-salix/03_smartTable_searchBar_integrations.spec.js index c4f091d1f..526afa140 100644 --- a/e2e/paths/01-salix/03_smartTable_searchBar_integrations.spec.js +++ b/e2e/paths/01-salix/03_smartTable_searchBar_integrations.spec.js @@ -64,6 +64,6 @@ describe('SmartTable SearchBar integration', () => { await page.reload({ waitUntil: 'networkidle2' }); - await page.waitForTextInField(selectors.itemFixedPrice.firstItemID, '13'); + await page.waitForTextInField(selectors.itemFixedPrice.firstItemID, '3'); }); }); diff --git a/e2e/paths/04-item/13_fixedPrice.spec.js b/e2e/paths/04-item/13_fixedPrice.spec.js index 37c4401b0..f36138e18 100644 --- a/e2e/paths/04-item/13_fixedPrice.spec.js +++ b/e2e/paths/04-item/13_fixedPrice.spec.js @@ -88,7 +88,8 @@ describe('Item fixed prices path', () => { it('should reload the section and check the created price has the expected ID', async() => { await page.goto(`http://localhost:5000/#!/item/fixed-price`); - + await page.autocompleteSearch($.warehouseFilter, 'Warehouse one'); + await page.click($.chip); const result = await page.waitToGetProperty($.fourthItemID, 'value'); expect(result).toContain('13'); From 1ed8000be963c101867397e8804035a15af8e15c Mon Sep 17 00:00:00 2001 From: alexandre Date: Mon, 29 May 2023 09:58:49 +0200 Subject: [PATCH 07/13] refs #5642 e2es refactored --- e2e/paths/05-ticket/21_future.spec.js | 17 +++-------------- e2e/paths/05-ticket/22_advance.spec.js | 12 ++---------- 2 files changed, 5 insertions(+), 24 deletions(-) diff --git a/e2e/paths/05-ticket/21_future.spec.js b/e2e/paths/05-ticket/21_future.spec.js index 1a101e9f1..c854dcbaf 100644 --- a/e2e/paths/05-ticket/21_future.spec.js +++ b/e2e/paths/05-ticket/21_future.spec.js @@ -21,7 +21,7 @@ describe('Ticket Future path', () => { await browser.close(); }); - it('should show errors snackbar because of the required data', async() => { + it('should search with required data, check three last tickets and move to the future', async() => { await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); await page.clearInput(selectors.ticketFuture.warehouseFk); await page.waitToClick(selectors.ticketFuture.submit); @@ -42,25 +42,19 @@ describe('Ticket Future path', () => { message = await page.waitForSnackbar(); expect(message.text).toContain('originDated is a required argument'); - }); - it('should search with the required data', async() => { await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); await page.waitToClick(selectors.ticketFuture.submit); expect(httpRequest).toBeDefined(); - }); - it('should search with the origin IPT', async() => { await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); await page.autocompleteSearch(selectors.ticketFuture.ipt, 'H'); await page.waitToClick(selectors.ticketFuture.submit); expect(httpRequest).toContain('ipt=H'); - }); - it('should search with the destination IPT', async() => { await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); await page.clearInput(selectors.ticketFuture.ipt); @@ -69,9 +63,7 @@ describe('Ticket Future path', () => { await page.waitToClick(selectors.ticketFuture.submit); expect(httpRequest).toContain('futureIpt=H'); - }); - it('should search with the origin grouped state', async() => { await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); await page.clearInput(selectors.ticketFuture.futureIpt); @@ -80,9 +72,7 @@ describe('Ticket Future path', () => { await page.waitToClick(selectors.ticketFuture.submit); expect(httpRequest).toContain('state=FREE'); - }); - it('should search with the destination grouped state', async() => { await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); await page.clearInput(selectors.ticketFuture.state); @@ -93,17 +83,16 @@ describe('Ticket Future path', () => { expect(httpRequest).toContain('futureState=FREE'); await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); + await page.clearInput(selectors.ticketFuture.state); await page.clearInput(selectors.ticketFuture.futureState); await page.waitToClick(selectors.ticketFuture.submit); - }); - it('should check the three last tickets and move to the future', async() => { await page.waitForNumberOfElements(selectors.ticketFuture.searchResult, 4); await page.waitToClick(selectors.ticketFuture.multiCheck); await page.waitToClick(selectors.ticketFuture.firstCheck); await page.waitToClick(selectors.ticketFuture.moveButton); await page.waitToClick(selectors.globalItems.acceptButton); - const message = await page.waitForSnackbar(); + message = await page.waitForSnackbar(); expect(message.text).toContain('Tickets moved successfully!'); }); diff --git a/e2e/paths/05-ticket/22_advance.spec.js b/e2e/paths/05-ticket/22_advance.spec.js index d845219c5..0e5b5e0c3 100644 --- a/e2e/paths/05-ticket/22_advance.spec.js +++ b/e2e/paths/05-ticket/22_advance.spec.js @@ -21,7 +21,7 @@ describe('Ticket Advance path', () => { await browser.close(); }); - it('should show errors snackbar because of the required data', async() => { + it('should search with the required data, check the first ticket and move to the present', async() => { await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); await page.clearInput(selectors.ticketAdvance.warehouseFk); @@ -43,16 +43,12 @@ describe('Ticket Advance path', () => { message = await page.waitForSnackbar(); expect(message.text).toContain('dateFuture is a required argument'); - }); - it('should search with the required data', async() => { await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); await page.waitToClick(selectors.ticketAdvance.submit); expect(httpRequest).toBeDefined(); - }); - it('should search with the origin IPT', async() => { await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); await page.autocompleteSearch(selectors.ticketAdvance.futureIpt, 'H'); await page.waitToClick(selectors.ticketAdvance.submit); @@ -62,9 +58,7 @@ describe('Ticket Advance path', () => { await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); await page.clearInput(selectors.ticketAdvance.futureIpt); await page.waitToClick(selectors.ticketAdvance.submit); - }); - it('should search with the destination IPT', async() => { await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); await page.autocompleteSearch(selectors.ticketAdvance.ipt, 'H'); await page.waitToClick(selectors.ticketAdvance.submit); @@ -74,13 +68,11 @@ describe('Ticket Advance path', () => { await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); await page.clearInput(selectors.ticketAdvance.ipt); await page.waitToClick(selectors.ticketAdvance.submit); - }); - it('should check the first ticket and move to the present', async() => { await page.waitToClick(selectors.ticketAdvance.firstCheck); await page.waitToClick(selectors.ticketAdvance.moveButton); await page.waitToClick(selectors.ticketAdvance.acceptButton); - const message = await page.waitForSnackbar(); + message = await page.waitForSnackbar(); expect(message.text).toContain('Tickets moved successfully!'); }); From 059467a383b09b176d4ef02b2ff97d9d0a9fbba5 Mon Sep 17 00:00:00 2001 From: alexandre Date: Mon, 29 May 2023 12:55:20 +0200 Subject: [PATCH 08/13] refs #5137 sql moved to template --- modules/worker/back/models/operator.js | 14 +++++----- .../not-main-printer-configured/locale/en.yml | 2 +- .../not-main-printer-configured/locale/es.yml | 2 +- .../not-main-printer-configured.html | 2 +- .../not-main-printer-configured.js | 26 ++++++++++++------- .../sql/printer.sql | 3 +++ .../sql/sector.sql | 3 +++ .../sql/worker.sql | 3 +++ 8 files changed, 34 insertions(+), 21 deletions(-) create mode 100644 print/templates/email/not-main-printer-configured/sql/printer.sql create mode 100644 print/templates/email/not-main-printer-configured/sql/sector.sql create mode 100644 print/templates/email/not-main-printer-configured/sql/worker.sql diff --git a/modules/worker/back/models/operator.js b/modules/worker/back/models/operator.js index d2887111c..e9b590fa6 100644 --- a/modules/worker/back/models/operator.js +++ b/modules/worker/back/models/operator.js @@ -5,23 +5,21 @@ module.exports = function(Self) { const options = ctx.options; if (!instance.sectorFk || !instance.labelerFk) return; + const sector = await models.Sector.findById(instance.sectorFk, { - fields: ['description', 'mainPrinterFk'] + fields: ['mainPrinterFk'] }, options); + if (sector.mainPrinterFk && sector.mainPrinterFk != instance.labelerFk) { const userId = ctx.options.accessToken.userId; - const user = await models.VnUser.findById(userId, {fields: ['nickname']}, options); - const labeler = await models.Printer.findById(instance.labelerFk, {fields: ['name']}, options); - const mainPrinter = await models.Printer.findById(sector.mainPrinterFk, {fields: ['name']}, options); await models.NotificationQueue.create({ notificationFk: 'not-main-printer-configured', authorFk: userId, params: JSON.stringify( { - 'labeler': `#${instance.labelerFk} ${labeler.name}`, - 'sector': `#${instance.sectorFk} ${sector.description}`, - 'mainPrinter': `#${sector.mainPrinterFk} ${mainPrinter.name}`, - 'worker': `#${userId} ${user.nickname}` + 'labelerId': instance.labelerFk, + 'sectorId': instance.sectorFk, + 'workerId': userId } ) }, options); diff --git a/print/templates/email/not-main-printer-configured/locale/en.yml b/print/templates/email/not-main-printer-configured/locale/en.yml index 5da9d2595..2a3051145 100644 --- a/print/templates/email/not-main-printer-configured/locale/en.yml +++ b/print/templates/email/not-main-printer-configured/locale/en.yml @@ -1,3 +1,3 @@ subject: Not main printer configured title: Not main printer configured -description: Printer {0} has been configured in sector {1} (the main printer for that sector is {2}). Ask the worker {3} +description: 'Printer #{0} {1} has been configured in sector #{2} {3} (the main printer for that sector is #{4} {5}). Ask the worker {6}.' diff --git a/print/templates/email/not-main-printer-configured/locale/es.yml b/print/templates/email/not-main-printer-configured/locale/es.yml index a8b207a54..b6fe5f9a0 100644 --- a/print/templates/email/not-main-printer-configured/locale/es.yml +++ b/print/templates/email/not-main-printer-configured/locale/es.yml @@ -1,3 +1,3 @@ subject: Configurada impresora no principal title: Configurada impresora no principal -description: Se ha configurado la impresora {0} en el sector {1} (la impresora principal de ese sector es la {2}). Preguntar al trabajador {3}. +description: 'Se ha configurado la impresora #{0} {1} en el sector #{2} {3} (la impresora principal de ese sector es la #{4} {5}). Preguntar al trabajador {6}.' diff --git a/print/templates/email/not-main-printer-configured/not-main-printer-configured.html b/print/templates/email/not-main-printer-configured/not-main-printer-configured.html index 06ab6d0b0..1e9ffed7a 100644 --- a/print/templates/email/not-main-printer-configured/not-main-printer-configured.html +++ b/print/templates/email/not-main-printer-configured/not-main-printer-configured.html @@ -2,7 +2,7 @@

{{ $t('title') }}

-

+

diff --git a/print/templates/email/not-main-printer-configured/not-main-printer-configured.js b/print/templates/email/not-main-printer-configured/not-main-printer-configured.js index 2c3e3521a..c381991fa 100755 --- a/print/templates/email/not-main-printer-configured/not-main-printer-configured.js +++ b/print/templates/email/not-main-printer-configured/not-main-printer-configured.js @@ -3,24 +3,30 @@ const emailBody = new Component('email-body'); module.exports = { name: 'not-main-printer-configured', + async serverPrefetch() { + this.sector = await this.findOneFromDef('sector', [this.sectorId]); + + if (!this.sector) + throw new Error('Something went wrong'); + + this.labeler = await this.findOneFromDef('printer', [this.labelerId]); + this.mainPrinter = await this.findOneFromDef('printer', [this.sector.mainPrinterFk]); + this.worker = await this.findOneFromDef('worker', [this.workerId]); + }, components: { 'email-body': emailBody.build(), }, props: { - labeler: { - type: String, + labelerId: { + type: Number, required: true }, - sector: { - type: String, + sectorId: { + type: Number, required: true }, - mainPrinter: { - type: String, - required: true - }, - worker: { - type: String, + workerId: { + type: Number, required: true } } diff --git a/print/templates/email/not-main-printer-configured/sql/printer.sql b/print/templates/email/not-main-printer-configured/sql/printer.sql new file mode 100644 index 000000000..265818129 --- /dev/null +++ b/print/templates/email/not-main-printer-configured/sql/printer.sql @@ -0,0 +1,3 @@ +SELECT id, name + FROM vn.printer + WHERE id = ? diff --git a/print/templates/email/not-main-printer-configured/sql/sector.sql b/print/templates/email/not-main-printer-configured/sql/sector.sql new file mode 100644 index 000000000..5d54eeeb9 --- /dev/null +++ b/print/templates/email/not-main-printer-configured/sql/sector.sql @@ -0,0 +1,3 @@ +SELECT id, description, mainPrinterFk + FROM vn.sector + WHERE id = ? diff --git a/print/templates/email/not-main-printer-configured/sql/worker.sql b/print/templates/email/not-main-printer-configured/sql/worker.sql new file mode 100644 index 000000000..0c7327851 --- /dev/null +++ b/print/templates/email/not-main-printer-configured/sql/worker.sql @@ -0,0 +1,3 @@ +SELECT nickname + FROM account.user + WHERE id = ? From ba850415be822aa7aabd3f2283d605efd48185a1 Mon Sep 17 00:00:00 2001 From: alexandre Date: Mon, 29 May 2023 12:56:54 +0200 Subject: [PATCH 09/13] refs #5137 moved sql --- db/changes/{232201 => 232401}/00-printer.sql | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename db/changes/{232201 => 232401}/00-printer.sql (100%) diff --git a/db/changes/232201/00-printer.sql b/db/changes/232401/00-printer.sql similarity index 100% rename from db/changes/232201/00-printer.sql rename to db/changes/232401/00-printer.sql From 138f03d89173033b0073307a07866e81218f631b Mon Sep 17 00:00:00 2001 From: alexandre Date: Tue, 30 May 2023 11:34:53 +0200 Subject: [PATCH 10/13] refs #5137 fix back test --- modules/worker/back/methods/operator/spec/operator.spec.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/modules/worker/back/methods/operator/spec/operator.spec.js b/modules/worker/back/methods/operator/spec/operator.spec.js index 5f099040a..1253be474 100644 --- a/modules/worker/back/methods/operator/spec/operator.spec.js +++ b/modules/worker/back/methods/operator/spec/operator.spec.js @@ -33,10 +33,9 @@ describe('Operator', () => { expect(notificationQueue.notificationFk).toEqual(notificationName); expect(notificationQueue.authorFk).toEqual(authorFk); - expect(params.labeler).toContain('2'); - expect(params.sector).toContain('1'); - expect(params.mainPrinter).toContain('1'); - expect(params.worker).toContain('9'); + expect(params.labelerId).toEqual(2); + expect(params.sectorId).toEqual(1); + expect(params.workerId).toEqual(9); await tx.rollback(); } catch (e) { From bda1ed41ae5ad9563d2b7c8d434378244c3082d4 Mon Sep 17 00:00:00 2001 From: alexandre Date: Tue, 6 Jun 2023 14:14:31 +0200 Subject: [PATCH 11/13] refs #5507 vnConfig moved to core --- front/{salix => core}/services/config.js | 0 front/core/services/index.js | 1 + front/salix/index.js | 1 - front/salix/services/index.js | 1 - 4 files changed, 1 insertion(+), 2 deletions(-) rename front/{salix => core}/services/config.js (100%) delete mode 100644 front/salix/services/index.js diff --git a/front/salix/services/config.js b/front/core/services/config.js similarity index 100% rename from front/salix/services/config.js rename to front/core/services/config.js diff --git a/front/core/services/index.js b/front/core/services/index.js index f61ad125e..867a13df0 100644 --- a/front/core/services/index.js +++ b/front/core/services/index.js @@ -5,6 +5,7 @@ import './auth'; import './token'; import './modules'; import './interceptor'; +import './config'; import './week-days'; import './report'; import './email'; diff --git a/front/salix/index.js b/front/salix/index.js index cac169405..2488ef9b6 100644 --- a/front/salix/index.js +++ b/front/salix/index.js @@ -3,4 +3,3 @@ import './routes'; import './components'; import './styles'; import 'vn-loopback/server/boot/date'; -import './services'; diff --git a/front/salix/services/index.js b/front/salix/services/index.js deleted file mode 100644 index c791e6492..000000000 --- a/front/salix/services/index.js +++ /dev/null @@ -1 +0,0 @@ -import './config'; From 16ad0829671db9fa21bd6e011976f0cf786055f2 Mon Sep 17 00:00:00 2001 From: alexandre Date: Wed, 7 Jun 2023 07:36:30 +0200 Subject: [PATCH 12/13] back fixed --- modules/entry/back/methods/entry/specs/addFromBuy.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/entry/back/methods/entry/specs/addFromBuy.spec.js b/modules/entry/back/methods/entry/specs/addFromBuy.spec.js index b6ed475b3..d2b79c601 100644 --- a/modules/entry/back/methods/entry/specs/addFromBuy.spec.js +++ b/modules/entry/back/methods/entry/specs/addFromBuy.spec.js @@ -4,9 +4,9 @@ describe('entry addFromBuy()', () => { const ctx = {req: {accessToken: {userId: 18}}}; it('should change the printedStickers of an existent buy', async() => { - const id = 1; + const id = 2; const item = 1; - const buy = 1; + const buy = 2; const tx = await models.Entry.beginTransaction({}); const options = {transaction: tx}; From 3805812aba9a7ce12fd2a3a85bd49398c02c6a8b Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 7 Jun 2023 07:43:44 +0200 Subject: [PATCH 13/13] fix: backTest --- modules/entry/back/methods/entry/addFromBuy.js | 2 +- modules/entry/back/methods/entry/specs/addFromBuy.spec.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/entry/back/methods/entry/addFromBuy.js b/modules/entry/back/methods/entry/addFromBuy.js index a40dd3412..f7e1b637e 100644 --- a/modules/entry/back/methods/entry/addFromBuy.js +++ b/modules/entry/back/methods/entry/addFromBuy.js @@ -48,7 +48,7 @@ module.exports = Self => { try { let buy = await models.Buy.findOne({where: {entryFk: args.id}}, myOptions); if (buy) - await buy.updateAttribute('printedStickers', args.printedStickers); + await buy.updateAttribute('printedStickers', args.printedStickers, myOptions); else { const userConfig = await models.UserConfig.findById(userId, {fields: ['warehouseFk']}, myOptions); await Self.rawSql( diff --git a/modules/entry/back/methods/entry/specs/addFromBuy.spec.js b/modules/entry/back/methods/entry/specs/addFromBuy.spec.js index d2b79c601..b6ed475b3 100644 --- a/modules/entry/back/methods/entry/specs/addFromBuy.spec.js +++ b/modules/entry/back/methods/entry/specs/addFromBuy.spec.js @@ -4,9 +4,9 @@ describe('entry addFromBuy()', () => { const ctx = {req: {accessToken: {userId: 18}}}; it('should change the printedStickers of an existent buy', async() => { - const id = 2; + const id = 1; const item = 1; - const buy = 2; + const buy = 1; const tx = await models.Entry.beginTransaction({}); const options = {transaction: tx};