diff --git a/src/composables/useArrayData.js b/src/composables/useArrayData.js index 1f4234a00..c13c4f9a6 100644 --- a/src/composables/useArrayData.js +++ b/src/composables/useArrayData.js @@ -104,12 +104,14 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) { store.hasMoreData = limit && response.data.length >= limit; - processData(response.data, { map: !!store.mapKey, append }); - if (!append && !isDialogOpened()) updateRouter && updateStateParams(); - + if (!append && !isDialogOpened() && updateRouter) { + if (updateStateParams(response.data)?.redirect) return; + } store.isLoading = false; canceller = null; + processData(response.data, { map: !!store.mapKey, append }); + return response; } @@ -239,7 +241,7 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) { if (Object.values(store.userParams).length) await fetch({}); } - function updateStateParams() { + function updateStateParams(data) { if (!route?.path) return; const newUrl = { path: route.path, query: { ...(route.query ?? {}) } }; if (store?.searchUrl) @@ -256,15 +258,15 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) { const { path } = matches.at(-1); const to = - store?.data?.length === 1 - ? path.replace(/\/(list|:id)|-list/, `/${store.data[0].id}`) + data?.length === 1 + ? path.replace(/\/(list|:id)|-list/, `/${data[0].id}`) : path.replace(/:id.*/, ''); if (route.path != to) { const pushUrl = { path: to }; if (to.endsWith('/list') || to.endsWith('/')) pushUrl.query = newUrl.query; - return router.push(pushUrl); + return router.push(pushUrl) && { redirect: true }; } } diff --git a/src/filters/toDateHourMin.js b/src/filters/toDateHourMin.js index 2b6995c01..c813840cb 100644 --- a/src/filters/toDateHourMin.js +++ b/src/filters/toDateHourMin.js @@ -1,5 +1,6 @@ export default function toDateHourMin(date) { - const dateHour = new Date(date).toLocaleDateString('es-ES', { + if (!date) return date; + return new Date(date).toLocaleDateString('es-ES', { timeZone: 'Europe/Madrid', year: 'numeric', month: '2-digit', @@ -7,5 +8,4 @@ export default function toDateHourMin(date) { hour: '2-digit', minute: '2-digit', }); - return dateHour; } diff --git a/src/filters/toDateHourMinSec.js b/src/filters/toDateHourMinSec.js index cfc9506fb..51df725e4 100644 --- a/src/filters/toDateHourMinSec.js +++ b/src/filters/toDateHourMinSec.js @@ -1,5 +1,6 @@ export default function toDateHourMinSec(date) { - const dateHour = new Date(date).toLocaleDateString('es-ES', { + if (!date) return date; + return new Date(date).toLocaleDateString('es-ES', { timeZone: 'Europe/Madrid', year: 'numeric', month: '2-digit', @@ -8,5 +9,4 @@ export default function toDateHourMinSec(date) { minute: '2-digit', second: '2-digit', }); - return dateHour; } diff --git a/src/pages/Supplier/Card/SupplierSummary.vue b/src/pages/Supplier/Card/SupplierSummary.vue index 5892811e6..b658ca5fb 100644 --- a/src/pages/Supplier/Card/SupplierSummary.vue +++ b/src/pages/Supplier/Card/SupplierSummary.vue @@ -39,6 +39,7 @@ const getUrl = (section) => `#/supplier/${entityId.value}/${section}`; :url="`Suppliers/${entityId}/getSummary`" @on-fetch="(data) => setData(data)" data-key="SupplierSummary" + module-name="Supplier" >