From 04141a8232f186f31bdf484f0c3e538b397a5a0e Mon Sep 17 00:00:00 2001 From: arpitnath Date: Mon, 25 Sep 2023 01:06:44 +0530 Subject: [PATCH] fixes: new version child components are not tied to its parent --- server/src/services/apps.service.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/server/src/services/apps.service.ts b/server/src/services/apps.service.ts index d98a960397..84db633551 100644 --- a/server/src/services/apps.service.ts +++ b/server/src/services/apps.service.ts @@ -410,6 +410,7 @@ export class AppsService { const newComponents = []; const newComponentLayouts = []; + const oldComponentToNewComponentMapping = {}; for (const page of pages) { const savedPage = await manager.save( @@ -446,12 +447,16 @@ export class AppsService { const componentEvents = allEvents.filter((event) => event.sourceId === component.id); newComponent.id = uuid.v4(); + + oldComponentToNewComponentMapping[component.id] = newComponent.id; + newComponent.name = component.name; newComponent.type = component.type; newComponent.pageId = savedPage.id; newComponent.properties = component.properties; newComponent.styles = component.styles; newComponent.validations = component.validations; + newComponent.parent = component.parent ? oldComponentToNewComponentMapping[component.parent] : null; newComponent.page = savedPage; newComponents.push(newComponent);