fix(views): always redirect to the first view when none was specified
This commit is contained in:
parent
8206cc8767
commit
974c9cdd21
@ -25,25 +25,34 @@ const currentView = computed(() => {
|
|||||||
return project?.views.find(v => v.id === viewId)
|
return project?.views.find(v => v.id === viewId)
|
||||||
})
|
})
|
||||||
|
|
||||||
watch(
|
function redirectToFirstViewIfNecessary() {
|
||||||
() => viewId,
|
|
||||||
() => {
|
|
||||||
if (viewId === 0) {
|
if (viewId === 0) {
|
||||||
// Ideally, we would do that in the router redirect, but we the projects (and therefore, the views)
|
// Ideally, we would do that in the router redirect, but the projects (and therefore, the views)
|
||||||
// are not always loaded then.
|
// are not always loaded then.
|
||||||
const viewId = projectStore.projects[projectId].views[0].id
|
const firstViewId = projectStore.projects[projectId]?.views[0].id
|
||||||
|
if (firstViewId) {
|
||||||
router.replace({
|
router.replace({
|
||||||
name: 'project.view',
|
name: 'project.view',
|
||||||
params: {
|
params: {
|
||||||
projectId,
|
projectId,
|
||||||
viewId,
|
viewId: firstViewId,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => viewId,
|
||||||
|
redirectToFirstViewIfNecessary,
|
||||||
{immediate: true},
|
{immediate: true},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => projectStore.projects[projectId],
|
||||||
|
redirectToFirstViewIfNecessary,
|
||||||
|
)
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user