From 4e1c43eb4df7aa003f3353c194263de2dca1932c Mon Sep 17 00:00:00 2001 From: alexandre Date: Tue, 17 Jan 2023 10:01:49 +0100 Subject: [PATCH 1/6] refs #4945 nombre temporal removed --- e2e/helpers/selectors.js | 3 ++- e2e/paths/04-item/07_create.spec.js | 11 ++++++++++- e2e/paths/04-item/10_item_log.spec.js | 10 +++++----- modules/item/back/methods/item/new.js | 17 ++++++++++++----- .../item/back/methods/item/specs/new.spec.js | 7 ++++--- modules/item/front/create/index.html | 16 ++++++++++++++-- modules/item/front/create/index.js | 4 +++- 7 files changed, 50 insertions(+), 18 deletions(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index b8f0813ed..04f2d4569 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -428,6 +428,7 @@ export default { }, itemCreateView: { temporalName: 'vn-item-create vn-textfield[ng-model="$ctrl.item.provisionalName"]', + priority: 'vn-input-number[ng-model="$ctrl.item.priority"]', type: 'vn-autocomplete[ng-model="$ctrl.item.typeFk"]', intrastat: 'vn-autocomplete[ng-model="$ctrl.item.intrastatFk"]', origin: 'vn-autocomplete[ng-model="$ctrl.item.originFk"]', @@ -521,7 +522,7 @@ export default { }, itemLog: { anyLineCreated: 'vn-item-log > vn-log vn-tbody > vn-tr', - fifthLineCreatedProperty: 'vn-item-log > vn-log vn-tbody > vn-tr:nth-child(5) table tr:nth-child(3) td.after', + fourthLineCreatedProperty: 'vn-item-log > vn-log vn-tbody > vn-tr:nth-child(4) table tr:nth-child(3) td.after', }, ticketSummary: { header: 'vn-ticket-summary > vn-card > h5', diff --git a/e2e/paths/04-item/07_create.spec.js b/e2e/paths/04-item/07_create.spec.js index 0820f2db7..8319a8dff 100644 --- a/e2e/paths/04-item/07_create.spec.js +++ b/e2e/paths/04-item/07_create.spec.js @@ -36,11 +36,20 @@ describe('Item Create', () => { await page.waitForState('item.create'); }); - it('should create the Infinity Gauntlet item', async() => { + it('should throw an error when insert an invalid priority', async() => { await page.write(selectors.itemCreateView.temporalName, 'Infinity Gauntlet'); await page.autocompleteSearch(selectors.itemCreateView.type, 'Crisantemo'); await page.autocompleteSearch(selectors.itemCreateView.intrastat, 'Coral y materiales similares'); await page.autocompleteSearch(selectors.itemCreateView.origin, 'Holand'); + await page.overwrite(selectors.itemCreateView.priority, '100'); + await page.waitToClick(selectors.itemCreateView.createButton); + const message = await page.waitForSnackbar(); + + expect(message.text).toContain('Valid priorities'); + }); + + it('should create the Infinity Gauntlet item', async() => { + await page.overwrite(selectors.itemCreateView.priority, '2'); await page.waitToClick(selectors.itemCreateView.createButton); const message = await page.waitForSnackbar(); diff --git a/e2e/paths/04-item/10_item_log.spec.js b/e2e/paths/04-item/10_item_log.spec.js index 2a885fe6f..f3ff6001c 100644 --- a/e2e/paths/04-item/10_item_log.spec.js +++ b/e2e/paths/04-item/10_item_log.spec.js @@ -48,17 +48,17 @@ describe('Item log path', () => { await page.accessToSection('item.card.log'); }); - it(`should confirm the log is showing 5 entries`, async() => { + it(`should confirm the log is showing 4 entries`, async() => { await page.waitForSelector(selectors.itemLog.anyLineCreated); const anyLineCreatedCount = await page.countElement(selectors.itemLog.anyLineCreated); - expect(anyLineCreatedCount).toEqual(5); + expect(anyLineCreatedCount).toEqual(4); }); it(`should confirm the log is showing the intrastat for the created item`, async() => { - const fifthLineCreatedProperty = await page - .waitToGetProperty(selectors.itemLog.fifthLineCreatedProperty, 'innerText'); + const fourthLineCreatedProperty = await page + .waitToGetProperty(selectors.itemLog.fourthLineCreatedProperty, 'innerText'); - expect(fifthLineCreatedProperty).toEqual('Coral y materiales similares'); + expect(fourthLineCreatedProperty).toEqual('Coral y materiales similares'); }); }); diff --git a/modules/item/back/methods/item/new.js b/modules/item/back/methods/item/new.js index fae37836f..b84072a8a 100644 --- a/modules/item/back/methods/item/new.js +++ b/modules/item/back/methods/item/new.js @@ -37,7 +37,9 @@ module.exports = Self => { 'typeFk', 'intrastatFk', 'originFk', - 'relevancy' + 'relevancy', + 'priority', + 'tag' ]; for (const key in params) { @@ -46,10 +48,14 @@ module.exports = Self => { } try { + const validPriorities = new Set([1, 2, 3]); + if (!validPriorities.has(params.priority)) + throw new UserError(`Valid priorities: ${[...validPriorities]}`); + const provisionalName = params.provisionalName; delete params.provisionalName; - const itemType = await models.ItemType.findById(params.typeFk, myOptions); + const itemType = await models.ItemType.findById(params.typeFk, {fields: ['isLaid']}, myOptions); params.isLaid = itemType.isLaid; @@ -63,13 +69,14 @@ module.exports = Self => { await Self.rawSql(query, null, myOptions); - let nameTag = await models.Tag.findOne({where: {name: 'Nombre temporal'}}); + const nameTag = await models.Tag.findById(params.tag, {fields: ['id']}, myOptions); let newTags = []; - newTags.push({itemFk: item.id, tagFk: nameTag.id, value: provisionalName, priority: '2'}); + newTags.push({itemFk: item.id, tagFk: nameTag.id, value: provisionalName, priority: item.priority}); typeTags.forEach(typeTag => { - newTags.push({itemFk: item.id, tagFk: typeTag.tagFk, value: '', priority: typeTag.priority}); + if (nameTag.id != typeTag.tagFk) + newTags.push({itemFk: item.id, tagFk: typeTag.tagFk, value: '', priority: typeTag.priority}); }); await models.ItemTag.create(newTags, myOptions); diff --git a/modules/item/back/methods/item/specs/new.spec.js b/modules/item/back/methods/item/specs/new.spec.js index 7364faa7d..e34ab2cf5 100644 --- a/modules/item/back/methods/item/specs/new.spec.js +++ b/modules/item/back/methods/item/specs/new.spec.js @@ -11,7 +11,8 @@ describe('item new()', () => { originFk: 1, provisionalName: 'planta', typeFk: 2, - relevancy: 0 + priority: 2, + tag: 1 }; let item = await models.Item.new(itemParams, options); @@ -20,7 +21,7 @@ describe('item new()', () => { item.isLaid = itemType.isLaid; - const temporalNameTag = await models.Tag.findOne({where: {name: 'Nombre temporal'}}, options); + const temporalNameTag = await models.Tag.findById(itemParams.tag, {fields: ['id']}, options); const temporalName = await models.ItemTag.findOne({ where: { @@ -31,7 +32,7 @@ describe('item new()', () => { item = await models.Item.findById(item.id, null, options); - itemType = await models.ItemType.findById(item.typeFk, options); + itemType = await models.ItemType.findById(item.typeFk, {fields: ['isLaid']}, options); item.isLaid = itemType.isLaid; diff --git a/modules/item/front/create/index.html b/modules/item/front/create/index.html index 6deaab1cd..806d0cb62 100644 --- a/modules/item/front/create/index.html +++ b/modules/item/front/create/index.html @@ -16,10 +16,22 @@ + + + + Date: Wed, 18 Jan 2023 13:14:49 +0100 Subject: [PATCH 2/6] refs #4945 added defaultTag, validPriorities, defaultPriority in itemConfig --- .../230201/00-validPriorities_ItemConfig.sql | 8 ++++++++ db/dump/fixtures.sql | 4 ++++ e2e/helpers/selectors.js | 2 +- e2e/paths/04-item/10_item_log.spec.js | 10 +++++----- modules/item/back/methods/item/new.js | 7 +++---- modules/item/back/models/item-config.json | 18 +++++++++++++++++- modules/item/front/create/index.js | 19 ++++++++++++++----- 7 files changed, 52 insertions(+), 16 deletions(-) create mode 100644 db/changes/230201/00-validPriorities_ItemConfig.sql diff --git a/db/changes/230201/00-validPriorities_ItemConfig.sql b/db/changes/230201/00-validPriorities_ItemConfig.sql new file mode 100644 index 000000000..2e22352fe --- /dev/null +++ b/db/changes/230201/00-validPriorities_ItemConfig.sql @@ -0,0 +1,8 @@ +ALTER TABLE `vn`.`itemConfig` ADD defaultTag INT DEFAULT 56 NOT NULL; +ALTER TABLE `vn`.`itemConfig` ADD CONSTRAINT itemConfig_FK FOREIGN KEY (defaultTag) REFERENCES vn.tag(id); +ALTER TABLE `vn`.`itemConfig` ADD validPriorities varchar(50) DEFAULT '[1,2,3]' NOT NULL; +ALTER TABLE `vn`.`itemConfig` ADD defaultPriority INT DEFAULT 2 NOT NULL; + +INSERT INTO `salix`.`ACL` +(model, property, accessType, permission, principalType, principalId) +VALUES('ItemConfig', '*', 'READ', 'ALLOW', 'ROLE', 'buyer'); diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index fba094ef4..5d6849cef 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -2719,6 +2719,10 @@ INSERT INTO `vn`.`collection` (`id`, `created`, `workerFk`, `stateFk`, `itemPack VALUES (3, util.VN_NOW(), 1107, 5, NULL, 0, 0, 1, NULL, NULL); +INSERT INTO `vn`.`itemConfig` (`id`, `isItemTagTriggerDisabled`, `monthToDeactivate`, `wasteRecipients`, `validPriorities`, `defaultPriority`, `defaultTag`) + VALUES + (0, 0, 24, '', '[1,2,3]', 2, 56); + INSERT INTO `vn`.`ticketCollection` (`ticketFk`, `collectionFk`, `created`, `level`, `wagon`, `smartTagFk`, `usedShelves`, `itemCount`, `liters`) VALUES (9, 3, util.VN_NOW(), NULL, 0, NULL, NULL, NULL, NULL); diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 04f2d4569..c2ad63484 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -522,7 +522,7 @@ export default { }, itemLog: { anyLineCreated: 'vn-item-log > vn-log vn-tbody > vn-tr', - fourthLineCreatedProperty: 'vn-item-log > vn-log vn-tbody > vn-tr:nth-child(4) table tr:nth-child(3) td.after', + fifthLineCreatedProperty: 'vn-item-log > vn-log vn-tbody > vn-tr:nth-child(5) table tr:nth-child(2) td.after', }, ticketSummary: { header: 'vn-ticket-summary > vn-card > h5', diff --git a/e2e/paths/04-item/10_item_log.spec.js b/e2e/paths/04-item/10_item_log.spec.js index f3ff6001c..2a885fe6f 100644 --- a/e2e/paths/04-item/10_item_log.spec.js +++ b/e2e/paths/04-item/10_item_log.spec.js @@ -48,17 +48,17 @@ describe('Item log path', () => { await page.accessToSection('item.card.log'); }); - it(`should confirm the log is showing 4 entries`, async() => { + it(`should confirm the log is showing 5 entries`, async() => { await page.waitForSelector(selectors.itemLog.anyLineCreated); const anyLineCreatedCount = await page.countElement(selectors.itemLog.anyLineCreated); - expect(anyLineCreatedCount).toEqual(4); + expect(anyLineCreatedCount).toEqual(5); }); it(`should confirm the log is showing the intrastat for the created item`, async() => { - const fourthLineCreatedProperty = await page - .waitToGetProperty(selectors.itemLog.fourthLineCreatedProperty, 'innerText'); + const fifthLineCreatedProperty = await page + .waitToGetProperty(selectors.itemLog.fifthLineCreatedProperty, 'innerText'); - expect(fourthLineCreatedProperty).toEqual('Coral y materiales similares'); + expect(fifthLineCreatedProperty).toEqual('Coral y materiales similares'); }); }); diff --git a/modules/item/back/methods/item/new.js b/modules/item/back/methods/item/new.js index b84072a8a..0057cb50f 100644 --- a/modules/item/back/methods/item/new.js +++ b/modules/item/back/methods/item/new.js @@ -37,7 +37,6 @@ module.exports = Self => { 'typeFk', 'intrastatFk', 'originFk', - 'relevancy', 'priority', 'tag' ]; @@ -48,9 +47,9 @@ module.exports = Self => { } try { - const validPriorities = new Set([1, 2, 3]); - if (!validPriorities.has(params.priority)) - throw new UserError(`Valid priorities: ${[...validPriorities]}`); + const itemConfig = await models.ItemConfig.findOne({fields: ['validPriorities']}, myOptions); + if (!itemConfig.validPriorities.includes(params.priority)) + throw new UserError(`Valid priorities: ${[...itemConfig.validPriorities]}`); const provisionalName = params.provisionalName; delete params.provisionalName; diff --git a/modules/item/back/models/item-config.json b/modules/item/back/models/item-config.json index 364879986..36d25e0bb 100644 --- a/modules/item/back/models/item-config.json +++ b/modules/item/back/models/item-config.json @@ -16,6 +16,22 @@ "wasteRecipients": { "type": "string", "description": "Buyers waste report recipients" + }, + "validPriorities": { + "type": "array" + }, + "defaultPriority": { + "type": "int" + }, + "defaultTag": { + "type": "int" + } + }, + "relations": { + "tag": { + "type": "belongsTo", + "model": "Tag", + "foreignKey": "defaultTag" } } -} \ No newline at end of file +} diff --git a/modules/item/front/create/index.js b/modules/item/front/create/index.js index c3082ffd7..c9a121cd4 100644 --- a/modules/item/front/create/index.js +++ b/modules/item/front/create/index.js @@ -4,11 +4,20 @@ import Section from 'salix/components/section'; class Controller extends Section { constructor($element, $) { super($element, $); - this.item = { - relevancy: 0, - priority: 2, - tag: 1 - }; + this.fetchDefaultPriorityTag(); + } + + fetchDefaultPriorityTag() { + const filter = {fields: ['defaultPriority', 'defaultTag'], limit: 1}; + this.$http.get(`ItemConfigs`, {filter}) + .then(res => { + if (res.data) { + this.item = { + priority: res.data[0].defaultPriority, + tag: res.data[0].defaultTag + }; + } + }); } onSubmit() { From 89a7aa58877fb420a6ee0453b3e18a0320b40282 Mon Sep 17 00:00:00 2001 From: alexandre Date: Wed, 18 Jan 2023 14:51:03 +0100 Subject: [PATCH 3/6] refs #4945 refresh structure --- db/dump/structure.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/db/dump/structure.sql b/db/dump/structure.sql index 4626279e4..772d6055d 100644 --- a/db/dump/structure.sql +++ b/db/dump/structure.sql @@ -80203,3 +80203,4 @@ USE `vncontrol`; -- Dump completed on 2022-11-21 7:57:28 + From a3b580e27d43511c2a29e6aaccf07c7c0c97402e Mon Sep 17 00:00:00 2001 From: alexandre Date: Fri, 20 Jan 2023 08:01:19 +0100 Subject: [PATCH 4/6] refs #4945 item.relevancy comment --- db/changes/230201/00-validPriorities_ItemConfig.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/db/changes/230201/00-validPriorities_ItemConfig.sql b/db/changes/230201/00-validPriorities_ItemConfig.sql index 2e22352fe..a793997d0 100644 --- a/db/changes/230201/00-validPriorities_ItemConfig.sql +++ b/db/changes/230201/00-validPriorities_ItemConfig.sql @@ -2,6 +2,7 @@ ALTER TABLE `vn`.`itemConfig` ADD defaultTag INT DEFAULT 56 NOT NULL; ALTER TABLE `vn`.`itemConfig` ADD CONSTRAINT itemConfig_FK FOREIGN KEY (defaultTag) REFERENCES vn.tag(id); ALTER TABLE `vn`.`itemConfig` ADD validPriorities varchar(50) DEFAULT '[1,2,3]' NOT NULL; ALTER TABLE `vn`.`itemConfig` ADD defaultPriority INT DEFAULT 2 NOT NULL; +ALTER TABLE `vn`.`item` MODIFY COLUMN relevancy tinyint(1) DEFAULT 0 NOT NULL COMMENT 'La web ordena de forma descendiente por este campo para mostrar los artículos'; INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId) From a473d3a6f9809848449abb43295ebe682b0da303 Mon Sep 17 00:00:00 2001 From: alexandre Date: Fri, 20 Jan 2023 12:01:13 +0100 Subject: [PATCH 5/6] refs #4945 changed input-number for autocomplete --- e2e/helpers/selectors.js | 2 +- e2e/paths/04-item/07_create.spec.js | 4 ++-- modules/item/front/create/index.html | 12 +++++++----- modules/item/front/create/index.js | 11 ++++++++--- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index a8131a458..e9d9d0580 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -428,7 +428,7 @@ export default { }, itemCreateView: { temporalName: 'vn-item-create vn-textfield[ng-model="$ctrl.item.provisionalName"]', - priority: 'vn-input-number[ng-model="$ctrl.item.priority"]', + priority: 'vn-autocomplete[ng-model="$ctrl.item.priority"]', type: 'vn-autocomplete[ng-model="$ctrl.item.typeFk"]', intrastat: 'vn-autocomplete[ng-model="$ctrl.item.intrastatFk"]', origin: 'vn-autocomplete[ng-model="$ctrl.item.originFk"]', diff --git a/e2e/paths/04-item/07_create.spec.js b/e2e/paths/04-item/07_create.spec.js index 8319a8dff..33324cdba 100644 --- a/e2e/paths/04-item/07_create.spec.js +++ b/e2e/paths/04-item/07_create.spec.js @@ -41,7 +41,7 @@ describe('Item Create', () => { await page.autocompleteSearch(selectors.itemCreateView.type, 'Crisantemo'); await page.autocompleteSearch(selectors.itemCreateView.intrastat, 'Coral y materiales similares'); await page.autocompleteSearch(selectors.itemCreateView.origin, 'Holand'); - await page.overwrite(selectors.itemCreateView.priority, '100'); + await page.clearInput(selectors.itemCreateView.priority); await page.waitToClick(selectors.itemCreateView.createButton); const message = await page.waitForSnackbar(); @@ -49,7 +49,7 @@ describe('Item Create', () => { }); it('should create the Infinity Gauntlet item', async() => { - await page.overwrite(selectors.itemCreateView.priority, '2'); + await page.autocompleteSearch(selectors.itemCreateView.priority, '2'); await page.waitToClick(selectors.itemCreateView.createButton); const message = await page.waitForSnackbar(); diff --git a/modules/item/front/create/index.html b/modules/item/front/create/index.html index 806d0cb62..15e212250 100644 --- a/modules/item/front/create/index.html +++ b/modules/item/front/create/index.html @@ -16,22 +16,24 @@ - - + ng-model="$ctrl.item.priority" + show-field="priority" + value-field="priority"> + { if (res.data) { + const dataRow = res.data[0]; + dataRow.validPriorities.forEach(priority => { + this.validPriorities.push({priority}); + }); this.item = { - priority: res.data[0].defaultPriority, - tag: res.data[0].defaultTag + priority: dataRow.defaultPriority, + tag: dataRow.defaultTag }; } }); From 30885a499ee19016ec87dc55609fc2a83b35d608 Mon Sep 17 00:00:00 2001 From: jgallego Date: Sat, 21 Jan 2023 07:29:27 +0100 Subject: [PATCH 6/6] link --- print/templates/email/printer-setup/locale/es.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/print/templates/email/printer-setup/locale/es.yml b/print/templates/email/printer-setup/locale/es.yml index 77a3a7299..7361e5ed3 100644 --- a/print/templates/email/printer-setup/locale/es.yml +++ b/print/templates/email/printer-setup/locale/es.yml @@ -8,8 +8,8 @@ description: https://www.youtube.com/watch?v=qhb0kgQF3o8. También necesitarás el QLabel, el programa para imprimir las cintas. - downloadFrom: Puedes descargarlo desde este enlace https://godex.s3-accelerate.amazonaws.com/gGnOPoojkP6vC1lgmrbEqQ.file?v01 + downloadFrom: Puedes descargarlo desde este enlace https://cdn.verdnatura.es/public/QLabel_IV_V1.37_Install_en.exe downloadDriver: En este enlace puedes descargar el driver de la impresora https://es.seagullscientific.com/support/downloads/drivers/godex/download/ sections: