From 93d7aee127873d7e43e4ee13234ee7b24a1c3f40 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 1 Jul 2024 17:25:20 +0200 Subject: [PATCH] chore: refs #7652 fix redirection --- src/components/common/VnCard.vue | 2 +- src/components/ui/CardDescriptor.vue | 2 +- src/composables/useArrayData.js | 16 ++++++++-------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/components/common/VnCard.vue b/src/components/common/VnCard.vue index 8be7b9221..c81bcd8e2 100644 --- a/src/components/common/VnCard.vue +++ b/src/components/common/VnCard.vue @@ -46,7 +46,7 @@ if (props.baseUrl) { onBeforeRouteUpdate(async (to, from) => { if (to.params.id !== from.params.id) { arrayData.store.url = `${props.baseUrl}/${to.params.id}`; - await arrayData.fetch({ append: false }); + await arrayData.fetch({ append: false, updateRouter: false }); } }); } diff --git a/src/components/ui/CardDescriptor.vue b/src/components/ui/CardDescriptor.vue index f3860ea46..3f1f0a00c 100644 --- a/src/components/ui/CardDescriptor.vue +++ b/src/components/ui/CardDescriptor.vue @@ -82,7 +82,7 @@ async function getData() { function getValueFromPath(path) { if (!path) return; - const keys = path.split('.'); + const keys = path.toString().split('.'); let current = entity.value; for (let i = 0; i < keys.length; i++) { diff --git a/src/composables/useArrayData.js b/src/composables/useArrayData.js index f8412f33a..b40699bbb 100644 --- a/src/composables/useArrayData.js +++ b/src/composables/useArrayData.js @@ -198,13 +198,6 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) { function updateStateParams() { const newUrl = { path: route.path, query: { ...(route.query ?? {}) } }; newUrl.query[store.searchUrl] = JSON.stringify(store.currentFilter); - const { matched: matches } = router.currentRoute.value; - const { path } = matches.at(-1); - - const to = - store?.data?.length === 1 - ? path.replace(/\/(list|:id)|-list/, `/${store.data[0].id}`) - : path.replace(/:id.*/, ''); if (store.navigate) { const { customRouteRedirectName, searchText } = store.navigate; @@ -213,6 +206,13 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) { name: customRouteRedirectName, params: { id: searchText }, }); + const { matched: matches } = router.currentRoute.value; + const { path } = matches.at(-1); + + const to = + store?.data?.length === 1 + ? path.replace(/\/(list|:id)|-list/, `/${store.data[0].id}`) + : path.replace(/:id.*/, ''); if (route.path != to) { const pushUrl = { path: to }; @@ -223,7 +223,7 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) { } } - if (store.currentFilter?.search) router.replace({ ...newUrl, path: to }); + router.replace(newUrl); } const totalRows = computed(() => (store.data && store.data.length) || 0);