From 33fba85e0fb3e4050c63f106ff8d4d4473038189 Mon Sep 17 00:00:00 2001 From: Ansh Grover Date: Sat, 30 Mar 2024 23:58:05 +0530 Subject: [PATCH] edit location bug fix --- service/invasiveUtil.js | 8 ++++---- service/updateParentHelper.js | 22 +++++++++++++++++++++- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/service/invasiveUtil.js b/service/invasiveUtil.js index 7861e84..cb0a2b2 100644 --- a/service/invasiveUtil.js +++ b/service/invasiveUtil.js @@ -125,8 +125,8 @@ const markLocationNonInvasive = async (locationid) => { await LocationDAO.editLocation(locationid, location); - await updateParentHelper.removeLocationFromParent(locationid, location); - await updateParentHelper.addLocationMetadataInParent(locationid, location); + // await updateParentHelper.removeLocationFromParent(locationid, location); + await updateParentHelper.addUpdateLocationMetadataInParent(locationid, location); if (location.parenttype == "subproject") { await markSubProjectNonInvasive(location.parentid); @@ -155,8 +155,8 @@ const markSubProjectNonInvasive = async (subProjectId) => { subProject.isInvasive = false; await SubProjectDAO.editSubProject(subProjectId, subProject); - await updateParentHelper.removeSubprojectMetaDataInProject(subProjectId, subProject); - await updateParentHelper.addSubprojectMetaDataInProject(subProjectId, subProject); + // await updateParentHelper.removeSubprojectMetaDataInProject(subProjectId, subProject); + await updateParentHelper.addUpdateSubprojectMetaDataInProject(subProjectId, subProject); if (subProject.parenttype == "project") { await markProjectNonInvasive(subProject.parentid); diff --git a/service/updateParentHelper.js b/service/updateParentHelper.js index 0c1d73d..93e0497 100644 --- a/service/updateParentHelper.js +++ b/service/updateParentHelper.js @@ -192,6 +192,25 @@ const addSubprojectMetaDataInProject = async (subProjectId, subProject) => { ); }; +const addUpdateSubprojectMetaDataInProject = async (subProjectId, subProject) => { + const subProjectDataInParent = { + name: subProject.name, + type: "subproject", + url: subProject.url, + description: subProject.description, + isInvasive: subProject.isInvasive, + sequenceNo: subProject.sequenceNo !== undefined ? subProject.sequenceNo : null, + }; + await ProjectDAO.addUpdateProjectChild( + subProject.parentid, + subProjectId, + subProjectDataInParent + ); + console.log( + `Added subproject with id ${subProjectId} in project id ${subProject.parentid} successfully` + ); +}; + const removeSubprojectMetaDataInProject = async (subProjectId, subProject) => { await ProjectDAO.removeProjectChild(subProject.parentid, subProjectId); console.log( @@ -225,5 +244,6 @@ module.exports = { removeSubprojectMetaDataInProject, addRemoveSubProjectMetadataInProject, addUpdateLocationMetadataInParent, - addUpdateSectionMetadataFromParent + addUpdateSectionMetadataFromParent, + addUpdateSubprojectMetaDataInProject };