fix: reactive ancestor projects

This commit is contained in:
Dominik Pschenitschni 2024-11-08 23:26:47 +01:00 committed by konrad
parent 03eff35245
commit 90951d4003
1 changed files with 18 additions and 16 deletions

View File

@ -44,6 +44,24 @@ export const useProjectStore = defineStore('project', () => {
return (id: IProject['id']) => projectsArray.value.filter(p => p.parentProjectId === id)
})
const getAncestors = computed(() => {
return (project: IProject): IProject[] => {
if (typeof project === 'undefined') {
return []
}
if (!project?.parentProjectId) {
return [project]
}
const parentProject = projects.value[project.parentProjectId]
return [
...(parentProject ? getAncestors.value(parentProject) : []),
project,
]
}
})
const findProjectByExactname = computed(() => {
return (name: string) => {
const project = projectsArray.value.find(l => {
@ -201,22 +219,6 @@ export const useProjectStore = defineStore('project', () => {
return loadedProjects
}
function getAncestors(project: IProject): IProject[] {
if (typeof project === 'undefined') {
return []
}
if (!project?.parentProjectId) {
return [project]
}
const parentProject = projects.value[project.parentProjectId]
return [
...(parentProject ? getAncestors(parentProject) : []),
project,
]
}
function setProjectView(view: IProjectView) {
const views = [...projects.value[view.projectId].views]