fix(projects): make sure the project hierarchy is properly updated when moving projects between parents
This commit is contained in:
parent
be2a38b48e
commit
f7629c28f4
@ -72,7 +72,19 @@ export const useProjectStore = defineStore('project', () => {
|
|||||||
// if the project is a child project, we need to also set it in the parent
|
// if the project is a child project, we need to also set it in the parent
|
||||||
if (project.parentProjectId) {
|
if (project.parentProjectId) {
|
||||||
const parent = projects.value[project.parentProjectId]
|
const parent = projects.value[project.parentProjectId]
|
||||||
parent.childProjects = parent.childProjects?.map(p => p.id === project.id ? project : p)
|
let foundProject = false
|
||||||
|
parent.childProjects = parent.childProjects?.map(p => {
|
||||||
|
if(p.id === project.id) {
|
||||||
|
foundProject = true
|
||||||
|
return project
|
||||||
|
}
|
||||||
|
|
||||||
|
return p
|
||||||
|
})
|
||||||
|
// If we hit this, the project now has a new parent project which it did not have before
|
||||||
|
if (!foundProject) {
|
||||||
|
parent.childProjects.push(project)
|
||||||
|
}
|
||||||
setProject(parent, false)
|
setProject(parent, false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user