diff --git a/src/components/common/VnBtnSelect.vue b/src/components/common/VnBtnSelect.vue index b0616a6b23a..3d96a55a658 100644 --- a/src/components/common/VnBtnSelect.vue +++ b/src/components/common/VnBtnSelect.vue @@ -14,6 +14,7 @@ defineProps({ hide-dropdown-icon focus-on-mount @update:model-value="promise" + data-cy="vnBtnSelect_select" /> diff --git a/src/components/common/VnDmsList.vue b/src/components/common/VnDmsList.vue index 52dd6ef791b..ed3cadc6bd7 100644 --- a/src/components/common/VnDmsList.vue +++ b/src/components/common/VnDmsList.vue @@ -297,7 +297,7 @@ defineExpose({ ref="dmsRef" :data-key="$props.model" :url="$props.model" - :filter="dmsFilter" + :user-filter="dmsFilter" :order="['dmsFk DESC']" :auto-load="true" @on-fetch="setData" diff --git a/src/components/common/VnModule.vue b/src/components/common/VnModule.vue index 505b3a8b56e..038ee1d60b2 100644 --- a/src/components/common/VnModule.vue +++ b/src/components/common/VnModule.vue @@ -20,16 +20,15 @@ const hasContent = ref(); let observer; onMounted(() => { - if (teleportRef.value) { - const checkContent = () => { - hasContent.value = teleportRef.value.innerHTML.trim() !== ''; - }; + if (!teleportRef.value) return; + const checkContent = () => { + hasContent.value = teleportRef.value?.innerHTML?.trim() !== ''; + }; - observer = new MutationObserver(checkContent); - observer.observe(teleportRef.value, { childList: true, subtree: true }); + observer = new MutationObserver(checkContent); + observer.observe(teleportRef.value, { childList: true, subtree: true }); - checkContent(); - } + checkContent(); }); diff --git a/src/components/common/VnSection.vue b/src/components/common/VnSection.vue index be7a3a1219b..edd8d3dfa98 100644 --- a/src/components/common/VnSection.vue +++ b/src/components/common/VnSection.vue @@ -39,6 +39,10 @@ const $props = defineProps({ type: Boolean, default: true, }, + keepData: { + type: Boolean, + default: true, + }, }); const route = useRoute(); @@ -56,6 +60,7 @@ onBeforeMount(() => { if ($props.dataKey) arrayData = useArrayData($props.dataKey, { searchUrl: 'table', + keepData: $props.keepData, ...$props.arrayDataProps, navigate: $props.redirect, }); diff --git a/src/components/ui/VnPaginate.vue b/src/components/ui/VnPaginate.vue index a2ccd5d92d1..0111366f525 100644 --- a/src/components/ui/VnPaginate.vue +++ b/src/components/ui/VnPaginate.vue @@ -111,6 +111,7 @@ onMounted(async () => { }); onBeforeUnmount(() => { + if (!store.keepData) arrayData.reset(['data']); arrayData.resetPagination(); }); diff --git a/src/composables/useArrayData.js b/src/composables/useArrayData.js index 1a91cc50b50..fd6e3a9b305 100644 --- a/src/composables/useArrayData.js +++ b/src/composables/useArrayData.js @@ -53,6 +53,7 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) { 'searchUrl', 'navigate', 'mapKey', + 'keepData', ]; if (typeof userOptions === 'object') { for (const option in userOptions) { @@ -302,7 +303,7 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) { for (const row of data) { const key = row[store.mapKey]; const val = { ...row, key }; - if (store.map.has(key)) { + if (key && store.map.has(key)) { const { position } = store.map.get(key); val.position = position; store.map.set(key, val); diff --git a/src/stores/useArrayDataStore.js b/src/stores/useArrayDataStore.js index e0d8b792932..8d62fdb4a22 100644 --- a/src/stores/useArrayDataStore.js +++ b/src/stores/useArrayDataStore.js @@ -18,6 +18,7 @@ export const useArrayDataStore = defineStore('arrayDataStore', () => { navigate: null, page: 1, mapKey: 'id', + keepData: false, }; function get(key) { diff --git a/test/cypress/integration/ticket/ticketExpedition.spec.js b/test/cypress/integration/ticket/ticketExpedition.spec.js index d4afd401f9a..d74a122a1dc 100644 --- a/test/cypress/integration/ticket/ticketExpedition.spec.js +++ b/test/cypress/integration/ticket/ticketExpedition.spec.js @@ -16,7 +16,9 @@ describe('Ticket expedtion', () => { cy.wait('@show'); cy.selectRows([1, 2]); - cy.selectOption('[data-cy="change-state"]', 'Perdida'); + + cy.dataCy('change-state').click(); + cy.selectOption('[data-cy="vnBtnSelect_select"]', 'Perdida'); cy.wait('@add'); cy.get(`${tableContent} tr:nth-child(-n+2) ${stateTd}`).each(($el) => {