From 452ba788c983fcb2e1c34046ce590c9ef85abdfb Mon Sep 17 00:00:00 2001 From: Jon Date: Mon, 18 Nov 2024 09:46:34 +0100 Subject: [PATCH 01/17] fix: how only the correct path of the search --- src/pages/Zone/Card/ZoneLocationsTree.vue | 66 +++++++++++++++++------ 1 file changed, 51 insertions(+), 15 deletions(-) diff --git a/src/pages/Zone/Card/ZoneLocationsTree.vue b/src/pages/Zone/Card/ZoneLocationsTree.vue index 6b3934df7..afe3006ea 100644 --- a/src/pages/Zone/Card/ZoneLocationsTree.vue +++ b/src/pages/Zone/Card/ZoneLocationsTree.vue @@ -126,33 +126,69 @@ function getNodeIds(node) { return ids; } +const findNodePath = (node, searchTerm, path = []) => { + if (node.name.toLowerCase().includes(searchTerm.toLowerCase())) { + path.push(node.id); + return path; + } + if (node.childs) { + for (let child of node.childs) { + const resultPath = findNodePath(child, searchTerm, [...path, node.id]); + if (resultPath.length > 0) { + return resultPath; + } + } + } + return []; +}; + +const filterNodes = (nodes, searchTerm) => { + return nodes + .map((node) => { + if (node.name.toLowerCase().includes(searchTerm.toLowerCase())) { + if (node.childs) { + node.childs = filterNodes(node.childs, searchTerm); + } + return node; + } + if (node.childs) { + node.childs = filterNodes(node.childs, searchTerm); + if (node.childs.length > 0) { + return node; + } + } + return null; + }) + .filter((node) => node !== null); +}; + watch(storeData, async (val) => { // Se triggerea cuando se actualiza el store.data, el cual es el resultado del fetch de la searchbar - nodes.value[0].childs = [...val]; - const fetchedNodeKeys = val.flatMap(getNodeIds); - state.set('Tree', [...fetchedNodeKeys]); + const searchTerm = store.userParams?.search || ''; - if (store.userParams?.search === '') { - val.forEach((n) => { - formatNodeSelected(n); - }); - } else { - for (let n of state.get('Tree')) await fetchNodeLeaves(n); - expanded.value = [null, ...fetchedNodeKeys]; - } + const filteredNodes = filterNodes(val, searchTerm); + let nodePath = []; + filteredNodes.forEach((node) => { + nodePath = findNodePath(node, searchTerm); + }); + + const finalFilteredNodes = filteredNodes.filter((node) => nodePath.includes(node.id)); + nodes.value[0].childs = [...finalFilteredNodes]; + const fetchedNodeKeys = finalFilteredNodes.flatMap(getNodeIds); + state.set('Tree', [...fetchedNodeKeys]); + expanded.value = [null, ...fetchedNodeKeys]; previousExpandedNodes.value = new Set(expanded.value); }); const reFetch = async () => { const { data } = await arrayData.fetch({ append: false }); nodes.value = data; + expanded.value = [null]; }; onMounted(async () => { - if (store.userParams?.search && !props.showSearchBar) { - await reFetch(); - return; - } + store.userParams.search = ''; + const stateTree = state.get('Tree'); const tree = stateTree ? [...state.get('Tree')] : [null]; const lastStateTree = state.get('TreeState'); From c2db7be8cd20311d2ae467dd44127c1676fa9a36 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 18 Nov 2024 15:06:09 +0100 Subject: [PATCH 02/17] fix(orderCatalogFilter): fix searchByTag --- src/pages/Order/Card/OrderCatalogFilter.vue | 297 ++++++++------------ 1 file changed, 116 insertions(+), 181 deletions(-) diff --git a/src/pages/Order/Card/OrderCatalogFilter.vue b/src/pages/Order/Card/OrderCatalogFilter.vue index 4c018bbb1..68764c1a5 100644 --- a/src/pages/Order/Card/OrderCatalogFilter.vue +++ b/src/pages/Order/Card/OrderCatalogFilter.vue @@ -1,5 +1,5 @@ From e10ee5e6c77d4dceff48d9eaf0e97a7694461adb Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 20 Nov 2024 09:26:40 +0100 Subject: [PATCH 08/17] test: #8162 fix vnLocation spec --- test/cypress/integration/vnComponent/vnLocation.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cypress/integration/vnComponent/vnLocation.spec.js b/test/cypress/integration/vnComponent/vnLocation.spec.js index 70c88b26f..70a943688 100644 --- a/test/cypress/integration/vnComponent/vnLocation.spec.js +++ b/test/cypress/integration/vnComponent/vnLocation.spec.js @@ -107,7 +107,7 @@ describe('VnLocation', () => { cy.get(inputLocation).should('have.value', postCodeLabel); }); - it('Create postCode', () => { + it.only('Create postCode', () => { const postCode = '1234475'; const province = 'Valencia'; cy.get(createLocationButton).click(); From 226f604f9d1f27b2a9bc9b6bc92cd1a72ee12c50 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 20 Nov 2024 09:37:47 +0100 Subject: [PATCH 09/17] test: #8162 fix vnLocation spec --- test/cypress/integration/vnComponent/vnLocation.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cypress/integration/vnComponent/vnLocation.spec.js b/test/cypress/integration/vnComponent/vnLocation.spec.js index 70a943688..70c88b26f 100644 --- a/test/cypress/integration/vnComponent/vnLocation.spec.js +++ b/test/cypress/integration/vnComponent/vnLocation.spec.js @@ -107,7 +107,7 @@ describe('VnLocation', () => { cy.get(inputLocation).should('have.value', postCodeLabel); }); - it.only('Create postCode', () => { + it('Create postCode', () => { const postCode = '1234475'; const province = 'Valencia'; cy.get(createLocationButton).click(); From 9da04881841c5fc269f7fdeab4ed8f7f91790f0b Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 20 Nov 2024 10:03:23 +0100 Subject: [PATCH 10/17] feat: remove comments --- test/cypress/integration/client/clientList.spec.js | 9 --------- .../integration/vnComponent/vnLocation.spec.js | 13 ------------- test/cypress/support/commands.js | 2 +- 3 files changed, 1 insertion(+), 23 deletions(-) diff --git a/test/cypress/integration/client/clientList.spec.js b/test/cypress/integration/client/clientList.spec.js index 37983cc70..431ac0548 100644 --- a/test/cypress/integration/client/clientList.spec.js +++ b/test/cypress/integration/client/clientList.spec.js @@ -56,11 +56,6 @@ describe('Client list', () => { cy.waitForElement('.q-form'); cy.checkValueSelectForm(1, search); cy.checkValueSelectForm(2, search); - // cy.get('@Open').should('have.been.calledOnceWithExactly', [ - // '/#/ticket/list?table={"clientFk":1110}&createForm={"addressId":10,"clientId":1110}', - // '_blank', - // 'noopener,noreferrer', - // ]); }); it('Client founded create order', () => { const search = 'Jessica Jones'; @@ -70,9 +65,5 @@ describe('Client list', () => { cy.waitForElement('.q-form'); cy.checkValueForm(1, search); cy.checkValueForm(2, search); - // cy.get('@Open').should( - // 'have.been.calledOnceWithExactly', - // '"/#/order/list?table={"clientFk":1110}&createForm={"addressId":10,"clientFk":1110}", "_blank", "noopener,noreferrer"' - // ); }); }); diff --git a/test/cypress/integration/vnComponent/vnLocation.spec.js b/test/cypress/integration/vnComponent/vnLocation.spec.js index 70c88b26f..ef08af679 100644 --- a/test/cypress/integration/vnComponent/vnLocation.spec.js +++ b/test/cypress/integration/vnComponent/vnLocation.spec.js @@ -19,26 +19,17 @@ describe('VnLocation', () => { cy.get(createLocationButton).click(); }); it('should filter provinces based on selected country', () => { - // Select a country cy.selectOption(countrySelector, 'Ecuador'); - // Verify that provinces are filtered cy.get(countrySelector).should('have.length', 1); - - // Verify that towns are filtered cy.get(citySelector).should('have.length', 1); }); it('should filter towns based on selected province', () => { - // Select a country cy.selectOption(countrySelector, 'Ecuador'); - // Verify that provinces are filtered cy.get(provinceSelector).should('have.length', 1); - - // Verify that towns are filtered cy.get(citySelector).should('have.length', 1); }); it('should pass selected country', () => { - // Select a country const country = 'Ecuador'; const province = 'Province five'; @@ -67,13 +58,11 @@ describe('VnLocation', () => { cy.get(locationOptions).should('have.length.at.least', 5); }); it('input filter location as "al"', function () { - // cy.get(inputLocation).click(); cy.get(inputLocation).clear(); cy.get(inputLocation).type('al'); cy.get(locationOptions).should('have.length.at.least', 4); }); it('input filter location as "ecuador"', function () { - // cy.get(inputLocation).click(); cy.get(inputLocation).clear(); cy.get(inputLocation).type('ecuador'); cy.get(locationOptions).should('have.length.at.least', 1); @@ -129,7 +118,6 @@ describe('VnLocation', () => { const province = 'Saskatchew'; cy.get(createLocationButton).click(); cy.get(dialogInputs).eq(0).type(postCode); - // city create button cy.get( `${createForm.prefix} > :nth-child(4) > .q-select > ${createForm.sufix} > :nth-child(2) > .q-icon` ).click(); @@ -138,7 +126,6 @@ describe('VnLocation', () => { cy.get('#q-portal--dialog--3 .q-btn--standard').click(); cy.get('#q-portal--dialog--1 .q-btn--standard').click(); cy.waitForElement('.q-form'); - checkVnLocation(postCode, province); }); diff --git a/test/cypress/support/commands.js b/test/cypress/support/commands.js index d4b2486e7..add41db57 100755 --- a/test/cypress/support/commands.js +++ b/test/cypress/support/commands.js @@ -294,7 +294,7 @@ Cypress.Commands.add('checkNotification', (text) => { throw new Error(`Notification not found: "${text}"`); }); }); -// :nth-child(2) > .q-field > .q-field__inner > .q-field__control > .q-field__control-container + Cypress.Commands.add('checkValueForm', (id, search) => { cy.get( `.grid-create > :nth-child(${id}) > .q-field__inner > .q-field__control > .q-field__control-container > .q-field__native > .q-field__input` From deb6467af8ed5072dc714cc459ca036b3803302e Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 20 Nov 2024 10:05:10 +0100 Subject: [PATCH 11/17] feat: remove comments --- test/cypress/support/commands.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cypress/support/commands.js b/test/cypress/support/commands.js index add41db57..1765b9043 100755 --- a/test/cypress/support/commands.js +++ b/test/cypress/support/commands.js @@ -297,7 +297,7 @@ Cypress.Commands.add('checkNotification', (text) => { Cypress.Commands.add('checkValueForm', (id, search) => { cy.get( - `.grid-create > :nth-child(${id}) > .q-field__inner > .q-field__control > .q-field__control-container > .q-field__native > .q-field__input` + `.grid-create > :nth-child(${id}) > .q-field__inner > .q-field__control > .q-field__control-container > .q-field__native > .q-field__input` ).should('have.value', search); }); From d6aedad38e49ee64b2a6b2f49a107b3b5975a67d Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 20 Nov 2024 10:07:03 +0100 Subject: [PATCH 12/17] perf: use const in VnLocation --- test/cypress/integration/vnComponent/vnLocation.spec.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/cypress/integration/vnComponent/vnLocation.spec.js b/test/cypress/integration/vnComponent/vnLocation.spec.js index ef08af679..aeb938c6f 100644 --- a/test/cypress/integration/vnComponent/vnLocation.spec.js +++ b/test/cypress/integration/vnComponent/vnLocation.spec.js @@ -19,13 +19,15 @@ describe('VnLocation', () => { cy.get(createLocationButton).click(); }); it('should filter provinces based on selected country', () => { - cy.selectOption(countrySelector, 'Ecuador'); + const country = 'Ecuador'; + cy.selectOption(countrySelector, country); cy.get(countrySelector).should('have.length', 1); cy.get(citySelector).should('have.length', 1); }); it('should filter towns based on selected province', () => { - cy.selectOption(countrySelector, 'Ecuador'); + const country = 'Ecuador'; + cy.selectOption(countrySelector, country); cy.get(provinceSelector).should('have.length', 1); cy.get(citySelector).should('have.length', 1); }); From abd79283ff907b0896acee009115ea38af3967b5 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 20 Nov 2024 13:38:22 +0100 Subject: [PATCH 13/17] fix(CatalogFilterValueDialog): from dev and fix --- .../Order/Card/CatalogFilterValueDialog.vue | 38 ++++++------- src/pages/Order/Card/OrderCatalog.vue | 56 ++++++++++++++++--- src/pages/Order/Card/OrderCatalogFilter.vue | 23 +++++--- 3 files changed, 79 insertions(+), 38 deletions(-) diff --git a/src/pages/Order/Card/CatalogFilterValueDialog.vue b/src/pages/Order/Card/CatalogFilterValueDialog.vue index 120e2fb72..2cc6c74d3 100644 --- a/src/pages/Order/Card/CatalogFilterValueDialog.vue +++ b/src/pages/Order/Card/CatalogFilterValueDialog.vue @@ -59,15 +59,6 @@ const getSelectedTagValues = async (tag) => { diff --git a/src/pages/Order/Card/OrderCatalog.vue b/src/pages/Order/Card/OrderCatalog.vue index b13e8661d..a266fc3d4 100644 --- a/src/pages/Order/Card/OrderCatalog.vue +++ b/src/pages/Order/Card/OrderCatalog.vue @@ -1,30 +1,57 @@