fix(views): move to new project view when moving tasks
This commit is contained in:
parent
2dfb3a6379
commit
bc34a33922
@ -1,12 +1,14 @@
|
|||||||
import {computed, shallowRef, watchEffect, h, type VNode} from 'vue'
|
import {computed, h, shallowRef, type VNode, watchEffect} from 'vue'
|
||||||
import {useRoute, useRouter} from 'vue-router'
|
import {useRoute, useRouter} from 'vue-router'
|
||||||
import {useBaseStore} from '@/stores/base'
|
import {useBaseStore} from '@/stores/base'
|
||||||
|
import {useProjectStore} from '@/stores/projects'
|
||||||
|
|
||||||
export function useRouteWithModal() {
|
export function useRouteWithModal() {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const backdropView = computed(() => route.fullPath && window.history.state.backdropView)
|
const backdropView = computed(() => route.fullPath && window.history.state.backdropView)
|
||||||
const baseStore = useBaseStore()
|
const baseStore = useBaseStore()
|
||||||
|
const projectStore = useProjectStore()
|
||||||
|
|
||||||
const routeWithModal = computed(() => {
|
const routeWithModal = computed(() => {
|
||||||
return backdropView.value
|
return backdropView.value
|
||||||
@ -60,12 +62,23 @@ export function useRouteWithModal() {
|
|||||||
// If the current project was changed because the user moved the currently opened task while coming from kanban,
|
// If the current project was changed because the user moved the currently opened task while coming from kanban,
|
||||||
// we need to reflect that change in the route when they close the task modal.
|
// we need to reflect that change in the route when they close the task modal.
|
||||||
// The last route is only available as resolved string, therefore we need to use a regex for matching here
|
// The last route is only available as resolved string, therefore we need to use a regex for matching here
|
||||||
const kanbanRouteMatch = new RegExp('\\/projects\\/\\d+\\/kanban', 'g')
|
const routeMatch = new RegExp('\\/projects\\/\\d+\\/(\\d+)', 'g')
|
||||||
const kanbanRouter = {name: 'project.kanban', params: {projectId: baseStore.currentProject?.id}}
|
const match = routeMatch.exec(historyState.value.back)
|
||||||
if (kanbanRouteMatch.test(historyState.value.back)
|
if (match !== null && baseStore.currentProject) {
|
||||||
&& baseStore.currentProject
|
let viewId: string | number = match[1]
|
||||||
&& historyState.value.back !== router.resolve(kanbanRouter).fullPath) {
|
|
||||||
router.push(kanbanRouter)
|
if (!viewId) {
|
||||||
|
viewId = projectStore.projects[baseStore.currentProject?.id].views[0]?.id
|
||||||
|
}
|
||||||
|
|
||||||
|
const newRoute = {
|
||||||
|
name: 'project.view',
|
||||||
|
params: {
|
||||||
|
projectId: baseStore.currentProject?.id,
|
||||||
|
viewId,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
router.push(newRoute)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user