From c207de6fb44d0600bf2564889a9631da934ae033 Mon Sep 17 00:00:00 2001 From: Ryan Hamilton Date: Wed, 31 Jan 2024 16:06:49 +0000 Subject: [PATCH] Nested sublayout where you can drag from parent to child. To move back from child to parent, right click on tab. --- examples/demo/App.tsx | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/examples/demo/App.tsx b/examples/demo/App.tsx index ad645a25..1e87fb92 100755 --- a/examples/demo/App.tsx +++ b/examples/demo/App.tsx @@ -38,7 +38,7 @@ class App extends React.Component { + const json = dragging instanceof TabNode ? dragging.toJson() : dragging; + if(dragging instanceof TabNode) { + this.state.model?.doAction(Actions.deleteTab(dragging.getId())); + } + // TODO - detect tab that we are hovering over, highlight and add to that only. + // Currently user has to move it in, then move it around. + model.doAction(Actions.addNode(json, model.getFirstTabSet().getId(), DockLocation.CENTER, -1)); + }; + return { x: 0, y: 0, width: 55, height: 55, callback: callback, cursor: 'copy' }; + } + return undefined; }; onShowLayoutClick = (event: React.MouseEvent) => { @@ -301,7 +315,7 @@ class App extends React.Component; } else if (component === "sub") { - var model = node.getExtraData().model; + var model:Model = node.getExtraData().model; if (model == null) { node.getExtraData().model = Model.fromJson(node.getConfig().model); model = node.getExtraData().model; @@ -313,7 +327,14 @@ class App extends React.Component; + // TODO - Using mouse click but really I want to override the child drag to be the adult drag. + return { + if(tn instanceof TabNode || tn instanceof TabSetNode) { + model.doAction(Actions.deleteTab(tn.getId())); + this.layoutRef!.current!.addTabWithDragAndDrop(tn.getName(), tn.toJson()); + e.stopPropagation(); // else event bubbles to parent tabset + } + }} />; } else if (component === "text") { try { @@ -446,7 +467,7 @@ class App extends React.Component