From 51807aa0c760d83729a54be1aed67dca50b6222c Mon Sep 17 00:00:00 2001 From: Rizky Date: Thu, 14 Dec 2023 18:30:55 +0700 Subject: [PATCH] wip fix --- app/web/src/nova/ed/logic/comp/load.tsx | 20 +++++++++++++++++++- app/web/src/nova/ed/logic/tree/build.tsx | 18 ++++++++++++++++++ app/web/src/nova/ed/panel/main/main.tsx | 9 ++++++++- 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/app/web/src/nova/ed/logic/comp/load.tsx b/app/web/src/nova/ed/logic/comp/load.tsx index 59170071..6204243c 100644 --- a/app/web/src/nova/ed/logic/comp/load.tsx +++ b/app/web/src/nova/ed/logic/comp/load.tsx @@ -50,7 +50,7 @@ export const loadCompSnapshot = async ( doc.off("update", p.comp.list[id_comp].on_update); } - const meta = {}; + const meta: Record = {}; const tree: NodeModel[] = []; const item = mitem.toJSON() as IItem; p.comp.loaded[id_comp] = { @@ -63,6 +63,24 @@ export const loadCompSnapshot = async ( on: { visit(m) { pushTreeNode(p, m, meta, tree); + + if (m.parent) { + if (m.parent.id === "root") { + if (m.item.id === item.id) { + m.mitem = mitem; + } + } else { + const parent = meta[m.parent.id]; + + if (parent.mitem) { + parent.mitem.get("childs")?.forEach((child) => { + if (child.get("id") === m.item.id) { + m.mitem = child; + } + }); + } + } + } }, }, note: "load-comp", diff --git a/app/web/src/nova/ed/logic/tree/build.tsx b/app/web/src/nova/ed/logic/tree/build.tsx index 25b363c5..a92e95b1 100644 --- a/app/web/src/nova/ed/logic/tree/build.tsx +++ b/app/web/src/nova/ed/logic/tree/build.tsx @@ -40,6 +40,24 @@ export const treeRebuild = async (p: PG, arg?: { note?: string }) => { async visit(m) { if (!is_layout) { pushTreeNode(p, m, meta, p.page.tree); + + if (m.parent) { + if (m.parent.id === "root") { + if (m.item.id === item.id) { + m.mitem = mitem; + } + } else { + const parent = meta[m.parent.id]; + + if (parent.mitem) { + parent.mitem.get("childs")?.forEach((child) => { + if (child.get("id") === m.item.id) { + m.mitem = child; + } + }); + } + } + } } }, }, diff --git a/app/web/src/nova/ed/panel/main/main.tsx b/app/web/src/nova/ed/panel/main/main.tsx index 5feb422b..e96c64b7 100644 --- a/app/web/src/nova/ed/panel/main/main.tsx +++ b/app/web/src/nova/ed/panel/main/main.tsx @@ -9,7 +9,14 @@ export const EdMain = () => { active.hover.renderMain = local.render; return ( -
+