fix: don't set the current project when setting a project
This commit is contained in:
parent
c30dcff451
commit
31b7c1f217
@ -14,7 +14,7 @@
|
|||||||
<BaseButton
|
<BaseButton
|
||||||
:to="{ name: 'project.index', params: { projectId: project.id} }"
|
:to="{ name: 'project.index', params: { projectId: project.id} }"
|
||||||
class="list-menu-link"
|
class="list-menu-link"
|
||||||
:class="{'router-link-exact-active': currentProject.id === project.id}"
|
:class="{'router-link-exact-active': currentProject?.id === project.id}"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
v-if="!canCollapse || childProjects?.length === 0"
|
v-if="!canCollapse || childProjects?.length === 0"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
<MenuButton class="menu-button" />
|
<MenuButton class="menu-button" />
|
||||||
|
|
||||||
<div v-if="currentProject.id" class="project-title-wrapper">
|
<div v-if="currentProject?.id" class="project-title-wrapper">
|
||||||
<h1 class="project-title">{{ currentProject.title === '' ? $t('misc.loading') : getProjectTitle(currentProject) }}
|
<h1 class="project-title">{{ currentProject.title === '' ? $t('misc.loading') : getProjectTitle(currentProject) }}
|
||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ import { useAuthStore } from '@/stores/auth'
|
|||||||
const baseStore = useBaseStore()
|
const baseStore = useBaseStore()
|
||||||
const currentProject = computed(() => baseStore.currentProject)
|
const currentProject = computed(() => baseStore.currentProject)
|
||||||
const background = computed(() => baseStore.background)
|
const background = computed(() => baseStore.background)
|
||||||
const canWriteCurrentProject = computed(() => baseStore.currentProject.maxRight > Rights.READ)
|
const canWriteCurrentProject = computed(() => baseStore.currentProject?.maxRight > Rights.READ)
|
||||||
const menuActive = computed(() => baseStore.menuActive)
|
const menuActive = computed(() => baseStore.menuActive)
|
||||||
|
|
||||||
const authStore = useAuthStore()
|
const authStore = useAuthStore()
|
||||||
|
@ -9,9 +9,9 @@
|
|||||||
<Logo class="logo" v-if="logoVisible"/>
|
<Logo class="logo" v-if="logoVisible"/>
|
||||||
<h1
|
<h1
|
||||||
:class="{'m-0': !logoVisible}"
|
:class="{'m-0': !logoVisible}"
|
||||||
:style="{ 'opacity': currentProject.title === '' ? '0': '1' }"
|
:style="{ 'opacity': currentProject?.title === '' ? '0': '1' }"
|
||||||
class="title">
|
class="title">
|
||||||
{{ currentProject.title === '' ? $t('misc.loading') : currentProject.title }}
|
{{ currentProject?.title === '' ? $t('misc.loading') : currentProject?.title }}
|
||||||
</h1>
|
</h1>
|
||||||
<div class="box has-text-left view">
|
<div class="box has-text-left view">
|
||||||
<router-view/>
|
<router-view/>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
:class="{ 'is-loading': projectService.loading, 'is-archived': currentProject.isArchived}"
|
:class="{ 'is-loading': projectService.loading, 'is-archived': currentProject?.isArchived}"
|
||||||
class="loader-container"
|
class="loader-container"
|
||||||
>
|
>
|
||||||
<div class="switch-view-container">
|
<div class="switch-view-container">
|
||||||
@ -45,7 +45,7 @@
|
|||||||
<slot name="header" />
|
<slot name="header" />
|
||||||
</div>
|
</div>
|
||||||
<CustomTransition name="fade">
|
<CustomTransition name="fade">
|
||||||
<Message variant="warning" v-if="currentProject.isArchived" class="mb-4">
|
<Message variant="warning" v-if="currentProject?.isArchived" class="mb-4">
|
||||||
{{ $t('project.archivedMessage') }}
|
{{ $t('project.archivedMessage') }}
|
||||||
</Message>
|
</Message>
|
||||||
</CustomTransition>
|
</CustomTransition>
|
||||||
@ -98,7 +98,7 @@ const currentProject = computed(() => {
|
|||||||
maxRight: null,
|
maxRight: null,
|
||||||
} : baseStore.currentProject
|
} : baseStore.currentProject
|
||||||
})
|
})
|
||||||
useTitle(() => currentProject.value.id ? getProjectTitle(currentProject.value) : '')
|
useTitle(() => currentProject.value?.id ? getProjectTitle(currentProject.value) : '')
|
||||||
|
|
||||||
// watchEffect would be called every time the prop would get a value assigned, even if that value was the same as before.
|
// watchEffect would be called every time the prop would get a value assigned, even if that value was the same as before.
|
||||||
// This resulted in loading and setting the project multiple times, even when navigating away from it.
|
// This resulted in loading and setting the project multiple times, even when navigating away from it.
|
||||||
@ -118,7 +118,7 @@ watch(
|
|||||||
(
|
(
|
||||||
projectIdToLoad === loadedProjectId.value ||
|
projectIdToLoad === loadedProjectId.value ||
|
||||||
typeof projectIdToLoad === 'undefined' ||
|
typeof projectIdToLoad === 'undefined' ||
|
||||||
projectIdToLoad === currentProject.value.id
|
projectIdToLoad === currentProject.value?.id
|
||||||
)
|
)
|
||||||
&& typeof currentProject.value !== 'undefined' && currentProject.value.maxRight !== null
|
&& typeof currentProject.value !== 'undefined' && currentProject.value.maxRight !== null
|
||||||
) {
|
) {
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<ColorBubble
|
<ColorBubble
|
||||||
v-if="showProjectColor && projectColor !== '' && currentProject.id !== task.projectId"
|
v-if="showProjectColor && projectColor !== '' && currentProject?.id !== task.projectId"
|
||||||
:color="projectColor"
|
:color="projectColor"
|
||||||
class="mr-1"
|
class="mr-1"
|
||||||
/>
|
/>
|
||||||
@ -104,7 +104,7 @@
|
|||||||
</progress>
|
</progress>
|
||||||
|
|
||||||
<router-link
|
<router-link
|
||||||
v-if="!showProject && currentProject.id !== task.projectId && project"
|
v-if="!showProject && currentProject?.id !== task.projectId && project"
|
||||||
:to="{ name: 'project.list', params: { projectId: task.projectId } }"
|
:to="{ name: 'project.list', params: { projectId: task.projectId } }"
|
||||||
class="task-project"
|
class="task-project"
|
||||||
v-tooltip="$t('task.detail.belongsToProject', {project: project.title})"
|
v-tooltip="$t('task.detail.belongsToProject', {project: project.title})"
|
||||||
|
@ -40,7 +40,7 @@ export function getSavedFilterIdFromProjectId(projectId: IProject['id']) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function isSavedFilter(project: IProject) {
|
export function isSavedFilter(project: IProject) {
|
||||||
return getSavedFilterIdFromProjectId(project.id) > 0
|
return getSavedFilterIdFromProjectId(project?.id) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class SavedFilterService extends AbstractService<ISavedFilter> {
|
export default class SavedFilterService extends AbstractService<ISavedFilter> {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import {watch, reactive, shallowReactive, unref, toRefs, readonly, ref, computed} from 'vue'
|
import {watch, reactive, shallowReactive, unref, toRefs, readonly, ref, computed, watchEffect} from 'vue'
|
||||||
import {acceptHMRUpdate, defineStore} from 'pinia'
|
import {acceptHMRUpdate, defineStore} from 'pinia'
|
||||||
import {useI18n} from 'vue-i18n'
|
import {useI18n} from 'vue-i18n'
|
||||||
import {useRouter} from 'vue-router'
|
import {useRouter} from 'vue-router'
|
||||||
@ -44,6 +44,8 @@ export const useProjectStore = defineStore('project', () => {
|
|||||||
return (id: IProject['id']) => projectsArray.value.filter(p => p.parentProjectId === id)
|
return (id: IProject['id']) => projectsArray.value.filter(p => p.parentProjectId === id)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
watchEffect(() => baseStore.setCurrentProject(projects.value[baseStore.currentProject?.id] || null))
|
||||||
|
|
||||||
const findProjectByExactname = computed(() => {
|
const findProjectByExactname = computed(() => {
|
||||||
return (name: string) => {
|
return (name: string) => {
|
||||||
const project = Object.values(projects.value).find(l => {
|
const project = Object.values(projects.value).find(l => {
|
||||||
@ -70,10 +72,6 @@ export const useProjectStore = defineStore('project', () => {
|
|||||||
function setProject(project: IProject) {
|
function setProject(project: IProject) {
|
||||||
projects.value[project.id] = project
|
projects.value[project.id] = project
|
||||||
update(project)
|
update(project)
|
||||||
|
|
||||||
if (baseStore.currentProject?.id === project.id) {
|
|
||||||
baseStore.setCurrentProject(project)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function setProjects(newProjects: IProject[]) {
|
function setProjects(newProjects: IProject[]) {
|
||||||
|
@ -75,7 +75,7 @@ const GanttChart = createAsyncComponent(() => import('@/components/tasks/GanttCh
|
|||||||
const props = defineProps<{route: RouteLocationNormalized}>()
|
const props = defineProps<{route: RouteLocationNormalized}>()
|
||||||
|
|
||||||
const baseStore = useBaseStore()
|
const baseStore = useBaseStore()
|
||||||
const canWrite = computed(() => baseStore.currentProject.maxRight > RIGHTS.READ)
|
const canWrite = computed(() => baseStore.currentProject?.maxRight > RIGHTS.READ)
|
||||||
|
|
||||||
const {route} = toRefs(props)
|
const {route} = toRefs(props)
|
||||||
const {
|
const {
|
||||||
|
@ -330,7 +330,7 @@ const bucketDraggableComponentData = computed(() => ({
|
|||||||
],
|
],
|
||||||
}))
|
}))
|
||||||
|
|
||||||
const canWrite = computed(() => baseStore.currentProject.maxRight > Rights.READ)
|
const canWrite = computed(() => baseStore.currentProject?.maxRight > Rights.READ)
|
||||||
const project = computed(() => baseStore.currentProject)
|
const project = computed(() => baseStore.currentProject)
|
||||||
|
|
||||||
const buckets = computed(() => kanbanStore.buckets)
|
const buckets = computed(() => kanbanStore.buckets)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user