{
+ selectedCategoryFk.value = getParamWhere(route, 'categoryFk');
+ selectedTypeFk.value = getParamWhere(route, 'typeFk');
+});
+
const resetCategory = (params, search) => {
selectedCategoryFk.value = null;
typeList.value = null;
params.categoryFk = null;
params.typeFk = null;
arrayData.store.userFilter = null;
- removeTagGroupParam(params, search);
+ removeTagGroupParam(search);
};
const selectCategory = (params, category, search) => {
if (params.categoryFk === category?.id) {
resetCategory(params, search);
- params.categoryFk = null;
- } else {
- selectedCategoryFk.value = category?.id;
- params.categoryFk = category?.id;
- params.typeFk = null;
- selectedTypeFk.value = null;
- loadTypes(category?.id);
+ return;
}
+ selectedCategoryFk.value = category?.id;
+ params.categoryFk = category?.id;
+ params.typeFk = null;
+ selectedTypeFk.value = null;
+ loadTypes(category?.id);
search();
};
@@ -115,13 +120,23 @@ const applyTags = (tagInfo, params, search) => {
search();
};
-const removeTagGroupParam = (params, search, valIndex = null) => {
- if (!valIndex) {
- params.tagGroups = null;
- search();
+async function onSearchByTag(value) {
+ if (!value.target.value) return;
+ if (!currentParams.value?.tagGroups) {
+ currentParams.value.tagGroups = [];
+ }
+
+ currentParams.value.tagGroups.push({
+ values: [{ value: value.target.value }],
+ });
+ searchByTag.value = null;
+}
+
+const removeTagGroupParam = (search, valIndex) => {
+ if (!valIndex && valIndex !== 0) {
+ currentParams.value.tagGroups = null;
} else {
- params.tagGroups.splice(valIndex, 1);
- search();
+ currentParams.value.tagGroups.splice(valIndex, 1);
}
};
@@ -142,6 +157,12 @@ const getCategoryClass = (category, params) => {
}
};
+const clearFilter = (key) => {
+ if (key === 'categoryFk') {
+ resetCategory();
+ }
+};
+
function addOrder(value, field, params) {
let { orderBy } = params;
orderBy = JSON.parse(orderBy);
@@ -157,7 +178,7 @@ onMounted(() => {
-
+
{
:expr-builder="exprBuilder"
:custom-tags="['tagGroups', 'categoryFk']"
:redirect="false"
- search-url="params"
+ @remove="clearFilter"
+ v-model="currentParams"
>
@@ -188,7 +210,7 @@ onMounted(() => {
@remove="
customTag.label === 'categoryFk'
? resetCategory(params, searchFn)
- : removeTagGroupParam(params, searchFn, valIndex)
+ : removeTagGroupParam(searchFn, valIndex)
"
>
@@ -288,46 +310,39 @@ onMounted(() => {
-
-
-
+ onSearchByTag(val, params)"
>
-
+
applyTags($event, params, searchFn)
+ ($event) => applyTags($event, currentParams, searchFn)
"
/>
-
+
diff --git a/src/pages/Zone/Card/ZoneCard.vue b/src/pages/Zone/Card/ZoneCard.vue
index 8ad25b80f..a470cd5bd 100644
--- a/src/pages/Zone/Card/ZoneCard.vue
+++ b/src/pages/Zone/Card/ZoneCard.vue
@@ -24,7 +24,6 @@ function notIsLocations(ifIsFalse, ifIsTrue) {
:descriptor="ZoneDescriptor"
:filter-panel="notIsLocations(ZoneFilterPanel, undefined)"
:search-data-key="notIsLocations('ZoneList', undefined)"
- :custom-url="`Zones/${route.params?.id}/getLeaves`"
:searchbar-props="{
url: notIsLocations('Zones', 'ZoneLocations'),
label: notIsLocations(t('list.searchZone'), t('list.searchLocation')),
diff --git a/src/pages/Zone/Card/ZoneLocationsTree.vue b/src/pages/Zone/Card/ZoneLocationsTree.vue
index b0a97b2f6..23a37ef7c 100644
--- a/src/pages/Zone/Card/ZoneLocationsTree.vue
+++ b/src/pages/Zone/Card/ZoneLocationsTree.vue
@@ -39,8 +39,7 @@ const url = computed(() => `Zones/${route.params.id}/getLeaves`);
const arrayData = useArrayData(datakey, {
url: url.value,
});
-const { store } = arrayData;
-const storeData = computed(() => store.data);
+const store = arrayData.store;
const defaultNode = {
id: null,
@@ -66,8 +65,20 @@ const onNodeExpanded = async (nodeKeysArray) => {
if (!nodeKeysSet.has(null)) return;
const wasExpanded = !previousExpandedNodes.value.has(lastNodeKey);
- if (wasExpanded) await fetchNodeLeaves(lastNodeKey);
- else {
+ if (wasExpanded && treeRef.value) {
+ const node = treeRef.value?.getNodeByKey(lastNodeKey);
+ const params = { parentId: node.id };
+ const response = await axios.get(`Zones/${route.params.id}/getLeaves`, {
+ params,
+ });
+ if (response.data) {
+ node.childs = response.data.map((n) => {
+ if (n.sons > 0) n.childs = [{}];
+ return n;
+ });
+ }
+ await fetchNodeLeaves(lastNodeKey, true);
+ } else {
const difference = new Set(
[...previousExpandedNodes.value].filter((x) => !nodeKeysSet.has(x))
);
@@ -83,41 +94,21 @@ const formatNodeSelected = (node) => {
if (node.selected === 1) node.selected = true;
else if (node.selected === 0) node.selected = false;
- if (node.childs && node.childs.length > 0) {
- expanded.value.push(node.id);
-
- node.childs.forEach((childNode) => {
- formatNodeSelected(childNode);
- });
- }
-
if (node.sons > 0 && !node.childs) node.childs = [{}];
};
const fetchNodeLeaves = async (nodeKey) => {
- try {
- const node = treeRef.value?.getNodeByKey(nodeKey);
- if (!node || node.sons === 0) return;
+ if (!treeRef.value) return;
+ const node = treeRef.value?.getNodeByKey(nodeKey);
+ if (node.selected === 1) node.selected = true;
+ else if (node.selected === 0) node.selected = false;
+ if (!node || node.sons === 0) return;
- const params = { parentId: node.id };
- const response = await axios.get(`Zones/${route.params.id}/getLeaves`, {
- params,
- });
- if (response.data) {
- node.childs = response.data.map((n) => {
- formatNodeSelected(n);
- return n;
- });
- }
-
- state.set('Tree', node);
- } catch (err) {
- console.error('Error fetching department leaves', err);
- throw new Error();
- }
+ state.set('Tree', node);
};
function getNodeIds(node) {
+ if (!node) return [];
let ids = [];
if (node.id) ids.push(node.id);
@@ -128,60 +119,46 @@ function getNodeIds(node) {
return ids;
}
-watch(storeData, async (val) => {
- // Se triggerea cuando se actualiza el store.data, el cual es el resultado del fetch de la searchbar
- if (!nodes.value[0]) nodes.value = [defaultNode];
- nodes.value[0].childs = [...val];
- const fetchedNodeKeys = val.flatMap(getNodeIds);
- state.set('Tree', [...fetchedNodeKeys]);
+watch(
+ () => store.data,
+ async (val) => {
+ if (!val) return;
+ // // Se triggerea cuando se actualiza el store.data, el cual es el resultado del fetch de la searchbar
+ if (!nodes.value[0]) nodes.value = [defaultNode];
+ nodes.value[0].childs = [...val];
+ const fetchedNodeKeys = val.flatMap(getNodeIds);
+ state.set('Tree', [...fetchedNodeKeys]);
- if (store.userParams?.search === '') {
- val.forEach((n) => {
- formatNodeSelected(n);
- });
- } else {
- for (let n of state.get('Tree')) await fetchNodeLeaves(n);
- expanded.value = [null, ...fetchedNodeKeys];
- }
- previousExpandedNodes.value = new Set(expanded.value);
-});
+ if (!store.userParams?.search) {
+ val.forEach((n) => {
+ formatNodeSelected(n);
+ });
+ store.data = null;
+ expanded.value = [null];
+ } else {
+ for (let n of state.get('Tree')) {
+ await fetchNodeLeaves(n);
+ }
+ expanded.value = [null, ...fetchedNodeKeys];
+ }
+ previousExpandedNodes.value = new Set(expanded.value);
+ },
+ { immediate: true }
+);
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;
- }
- const stateTree = state.get('Tree');
- const tree = stateTree ? [...state.get('Tree')] : [null];
- const lastStateTree = state.get('TreeState');
- if (tree) {
- for (let n of tree) {
- await fetchNodeLeaves(n);
- }
-
- if (lastStateTree) {
- tree.push(lastStateTree);
- await fetchNodeLeaves(lastStateTree);
- }
- }
-
- setTimeout(() => {
- if (lastStateTree) {
- document.getElementById(lastStateTree).scrollIntoView();
- }
- }, 1000);
-
- expanded.value.unshift(null);
- previousExpandedNodes.value = new Set(expanded.value);
+ if (store.userParams?.search) await arrayData.fetch({});
});
onUnmounted(() => {
state.set('Tree', undefined);
+ arrayData.destroy();
});
diff --git a/test/cypress/integration/client/clientList.spec.js b/test/cypress/integration/client/clientList.spec.js
index 93e53b9f6..431ac0548 100644
--- a/test/cypress/integration/client/clientList.spec.js
+++ b/test/cypress/integration/client/clientList.spec.js
@@ -6,7 +6,11 @@ describe('Client list', () => {
cy.visit('/#/customer/list', {
timeout: 5000,
onBeforeLoad(win) {
- cy.stub(win, 'open');
+ cy.stub(win, 'open')
+ .callsFake((url) => {
+ return win.open.wrappedMethod.call(win, url, '_self');
+ })
+ .as('Open');
},
});
});
@@ -20,9 +24,9 @@ describe('Client list', () => {
'Web user': { val: 'user_test_1' },
Street: { val: 'C/ STREET 1' },
Email: { val: 'user.test@1.com' },
- 'Business type': { val: 'Otros', type: 'select' },
- 'Sales person': { val: 'salesboss', type: 'select' },
+ 'Sales person': { val: 'employee', type: 'select' },
Location: { val: '46000, Valencia(Province one), EspaƱa', type: 'select' },
+ 'Business type': { val: 'Otros', type: 'select' },
};
cy.fillInForm(data);
@@ -47,17 +51,19 @@ describe('Client list', () => {
it('Client founded create ticket', () => {
const search = 'Jessica Jones';
cy.searchByLabel('Name', search);
- cy.clickButtonsDescriptor(2);
+ cy.openActionDescriptor('Create ticket');
cy.waitForElement('#formModel');
cy.waitForElement('.q-form');
- cy.checkValueForm(1, search);
+ cy.checkValueSelectForm(1, search);
+ cy.checkValueSelectForm(2, search);
});
it('Client founded create order', () => {
const search = 'Jessica Jones';
cy.searchByLabel('Name', search);
- cy.clickButtonsDescriptor(4);
+ cy.openActionDescriptor('New order');
cy.waitForElement('#formModel');
cy.waitForElement('.q-form');
+ cy.checkValueForm(1, search);
cy.checkValueForm(2, search);
});
});
diff --git a/test/cypress/integration/vnComponent/vnLocation.spec.js b/test/cypress/integration/vnComponent/vnLocation.spec.js
index 924b16adc..aeb938c6f 100644
--- a/test/cypress/integration/vnComponent/vnLocation.spec.js
+++ b/test/cypress/integration/vnComponent/vnLocation.spec.js
@@ -7,6 +7,9 @@ describe('VnLocation', () => {
prefix: '.q-dialog__inner > .column > #formModel > .q-card',
sufix: ' .q-field__inner > .q-field__control',
};
+ const countrySelector = `${createForm.prefix} > :nth-child(5) > :nth-child(3) > ${createForm.sufix}`;
+ const provinceSelector = `${createForm.prefix} > :nth-child(5) > :nth-child(2) > ${createForm.sufix}`;
+ const citySelector = `${createForm.prefix} > :nth-child(4) > :nth-child(2) > ${createForm.sufix}`;
describe('CreateFormDialog ', () => {
beforeEach(() => {
cy.viewport(1280, 720);
@@ -16,46 +19,23 @@ describe('VnLocation', () => {
cy.get(createLocationButton).click();
});
it('should filter provinces based on selected country', () => {
- // Select a country
- cy.selectOption(
- `${createForm.prefix} > :nth-child(5) > .q-field:nth-child(5)> ${createForm.sufix}`,
- 'Ecuador'
- );
- // Verify that provinces are filtered
- cy.get(
- `${createForm.prefix} > :nth-child(5) > .q-field:nth-child(3)> ${createForm.sufix}`
- ).should('have.length', 1);
-
- // Verify that towns are filtered
- cy.get(
- `${createForm.prefix} > :nth-child(4) > .q-field:nth-child(3)> ${createForm.sufix}`
- ).should('have.length', 1);
+ 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', () => {
- // Select a country
- cy.selectOption(
- `${createForm.prefix} > :nth-child(5) > .q-field:nth-child(3)> ${createForm.sufix}`,
- 'Ecuador'
- );
- // Verify that provinces are filtered
- cy.get(
- `${createForm.prefix} > :nth-child(5) > .q-field:nth-child(3)> ${createForm.sufix}`
- ).should('have.length', 1);
-
- // Verify that towns are filtered
- cy.get(
- `${createForm.prefix} > :nth-child(4) > .q-field:nth-child(3)> ${createForm.sufix}`
- ).should('have.length', 1);
+ const country = 'Ecuador';
+ cy.selectOption(countrySelector, country);
+ cy.get(provinceSelector).should('have.length', 1);
+ cy.get(citySelector).should('have.length', 1);
});
it('should pass selected country', () => {
- // Select a country
const country = 'Ecuador';
const province = 'Province five';
- cy.selectOption(
- `${createForm.prefix} > :nth-child(5) > .q-field:nth-child(5)> ${createForm.sufix}`,
- country
- );
+
+ cy.selectOption(countrySelector, country);
cy.selectOption(
`${createForm.prefix} > :nth-child(4) > .q-select > ${createForm.sufix}`,
province
@@ -80,13 +60,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);
@@ -142,7 +120,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();
@@ -151,7 +128,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 b8c1d3988..728342304 100755
--- a/test/cypress/support/commands.js
+++ b/test/cypress/support/commands.js
@@ -297,13 +297,13 @@ 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);
});
Cypress.Commands.add('checkValueSelectForm', (id, search) => {
cy.get(
- `.grid-create > :nth-child(${id}) > .q-field > .q-field__inner > .q-field__control > .q-field__control-container>.q-field__native>.q-field__input`
+ `.grid-create > :nth-child(${id}) > .q-field > .q-field__inner > .q-field__control > .q-field__control-container > .q-field__native > .q-field__input`
).should('have.value', search);
});