chore: refs #7652 fix redirection
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Jorge Penadés 2024-07-01 17:25:20 +02:00
parent cc187cfeab
commit 93d7aee127
3 changed files with 10 additions and 10 deletions

View File

@ -46,7 +46,7 @@ if (props.baseUrl) {
onBeforeRouteUpdate(async (to, from) => { onBeforeRouteUpdate(async (to, from) => {
if (to.params.id !== from.params.id) { if (to.params.id !== from.params.id) {
arrayData.store.url = `${props.baseUrl}/${to.params.id}`; arrayData.store.url = `${props.baseUrl}/${to.params.id}`;
await arrayData.fetch({ append: false }); await arrayData.fetch({ append: false, updateRouter: false });
} }
}); });
} }

View File

@ -82,7 +82,7 @@ async function getData() {
function getValueFromPath(path) { function getValueFromPath(path) {
if (!path) return; if (!path) return;
const keys = path.split('.'); const keys = path.toString().split('.');
let current = entity.value; let current = entity.value;
for (let i = 0; i < keys.length; i++) { for (let i = 0; i < keys.length; i++) {

View File

@ -198,13 +198,6 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
function updateStateParams() { function updateStateParams() {
const newUrl = { path: route.path, query: { ...(route.query ?? {}) } }; const newUrl = { path: route.path, query: { ...(route.query ?? {}) } };
newUrl.query[store.searchUrl] = JSON.stringify(store.currentFilter); 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) { if (store.navigate) {
const { customRouteRedirectName, searchText } = store.navigate; const { customRouteRedirectName, searchText } = store.navigate;
@ -213,6 +206,13 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
name: customRouteRedirectName, name: customRouteRedirectName,
params: { id: searchText }, 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) { if (route.path != to) {
const pushUrl = { 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); const totalRows = computed(() => (store.data && store.data.length) || 0);