fix: move parent project child id mutation to store
This commit is contained in:
parent
6e095436e9
commit
26e3d42ed5
@ -92,12 +92,6 @@ async function saveProjectPosition(e: SortableEvent) {
|
|||||||
projectAfter !== null ? projectAfter.position : null,
|
projectAfter !== null ? projectAfter.position : null,
|
||||||
)
|
)
|
||||||
|
|
||||||
if (project.parentProjectId !== parentProjectId && project.parentProjectId > 0) {
|
|
||||||
const parentProject = projectStore.getProjectById(project.parentProjectId)
|
|
||||||
const childProjectIndex = parentProject.childProjectIds.findIndex(pId => pId === project.id)
|
|
||||||
parentProject.childProjectIds.splice(childProjectIndex, 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// create a copy of the project in order to not violate pinia manipulation
|
// create a copy of the project in order to not violate pinia manipulation
|
||||||
await projectStore.updateProject({
|
await projectStore.updateProject({
|
||||||
|
@ -112,6 +112,15 @@ export const useProjectStore = defineStore('project', () => {
|
|||||||
async function updateProject(project: IProject) {
|
async function updateProject(project: IProject) {
|
||||||
const cancel = setModuleLoading(setIsLoading)
|
const cancel = setModuleLoading(setIsLoading)
|
||||||
const projectService = new ProjectService()
|
const projectService = new ProjectService()
|
||||||
|
|
||||||
|
const oldProject = projects.value[project.id]
|
||||||
|
if (oldProject && oldProject.parentProjectId !== project.parentProjectId && oldProject.parentProjectId > 0) {
|
||||||
|
const parentProject = projects.value[oldProject.parentProjectId]
|
||||||
|
if (parentProject) {
|
||||||
|
const childProjectIndex = parentProject.childProjectIds.findIndex(pId => pId === project.id)
|
||||||
|
parentProject.childProjectIds.splice(childProjectIndex, 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await projectService.update(project)
|
await projectService.update(project)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user