0
0
Fork 0

feat: refs #6893 replace id & redirect to Card or list

This commit is contained in:
Jorge Penadés 2024-03-26 09:11:53 +01:00
parent b46760116f
commit a0dcd6aee1
1 changed files with 10 additions and 4 deletions

View File

@ -97,12 +97,18 @@ async function search() {
const { matched: matches } = currentRoute.value; const { matched: matches } = currentRoute.value;
const { path } = matches.at(-1); const { path } = matches.at(-1);
const [, moduleName] = path.split('/');
let targetUrl = path.replace(':id', searchText.value); if (!store.data.length || store.data.length > 1)
if (path.endsWith('/list') && store.data.length === 1) return push({ path: `/${moduleName}/list` });
targetUrl = targetUrl.replace('/list', `/${store.data[0].id}/summary`);
await push(targetUrl); const targetId = store.data[0].id;
let targetUrl;
if (path.endsWith('/list')) targetUrl = path.replace('/list', `/${targetId}/summary`);
else if (path.includes(':id')) targetUrl = path.replace(':id', targetId);
await push({ path: targetUrl });
} }
</script> </script>