From a127d702a38131c6a12a0c2e12d246233c896656 Mon Sep 17 00:00:00 2001 From: TreetopFlyer Date: Sat, 8 May 2021 09:56:44 -0400 Subject: [PATCH 01/16] collect unique and sum --- index.html | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/index.html b/index.html index 1d9966b..e93994a 100644 --- a/index.html +++ b/index.html @@ -71,6 +71,40 @@ var N = { } }; + + + - + \ No newline at end of file From 258dfefb219f308097f8c0219568b8a60d5c0be3 Mon Sep 17 00:00:00 2001 From: TreetopFlyer Date: Sat, 8 May 2021 13:51:19 -0400 Subject: [PATCH 03/16] render pivot --- index.html | 125 +++++++++++++++++++++++++++-------------------------- 1 file changed, 63 insertions(+), 62 deletions(-) diff --git a/index.html b/index.html index 450d45e..9d79970 100644 --- a/index.html +++ b/index.html @@ -1,4 +1,8 @@ - - - \ No newline at end of file From 687ac9e7ccb7dfe74e860718913980d9c0e3a988 Mon Sep 17 00:00:00 2001 From: SethTrowbridge Date: Sun, 9 May 2021 20:26:40 -0400 Subject: [PATCH 07/16] Flow create, Disconnect purge --- index.html | 290 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 163 insertions(+), 127 deletions(-) diff --git a/index.html b/index.html index 9dc1bb9..5077f7b 100644 --- a/index.html +++ b/index.html @@ -1,22 +1,18 @@
- + + + @@ -135,6 +144,8 @@ N.Disconnect(a, c, "parent"); var Pivot = { Leaves:{}, + Root:{}, + Init(inRows) { Pivot.Leaves = inRows.map(r => N.Create({Row:r})); @@ -189,7 +200,7 @@ var Pivot = { iterator = child => Pivot.Pivot(child, inColumnIndicies, inSumIndicies, depth+1); } - N.Flow(inParent, "Hierarchy").forEach(iterator); + N.Step(inParent, "Hierarchy").forEach(iterator); return inParent; }, Create(inColumnIndicies, inSumIndicies) @@ -205,7 +216,7 @@ var Pivot = let gatherDown = n => { N.Connect(inNode, n, "ModifyDown"); - N.Flow(n, "Hierarchy").length == 0 ? leaves.push(n) : null; + N.Step(n, "Hierarchy").length == 0 ? leaves.push(n) : null; }; let gatherOut = n => N.Connect(inNode, n, "ModifyOut"); @@ -225,9 +236,11 @@ var Pivot = + From 437a56221abe6cf6c15767d26483223579e948e9 Mon Sep 17 00:00:00 2001 From: SethTrowbridge Date: Fri, 14 May 2021 07:11:23 -0400 Subject: [PATCH 14/16] modifications flow into new pivots --- index.html | 105 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 65 insertions(+), 40 deletions(-) diff --git a/index.html b/index.html index a349f09..0fdb3d7 100644 --- a/index.html +++ b/index.html @@ -20,8 +20,19 @@ var N = Link:{} }; }, - Connect(inNodeMajor, inNodeMinor, inKey) + Connect(inNodeMajor, inNodeMinor, inKey, inUnique) { + if(inUnique) // bail if the nodes are already connected + { + let check = N.Step(inNodeMajor, inKey, true); + if(check) + { + if(check.indexOf(inNodeMinor) < 0) + { + return; + } + } + } N.Step(inNodeMajor, inKey, true, true).push(inNodeMinor); N.Step(inNodeMinor, inKey, false, true).push(inNodeMajor); }, @@ -31,7 +42,9 @@ var N = if(inNodeMinor === null) { - inNodeMajor.Link[inKey].Set.forEach( inLoopNode => + let check = N.Step(inNodeMajor, inKey); + if(!check){ return; } + check.forEach( inLoopNode => { if(inLoopNode.Link[inKey].Get.length == 1) { @@ -140,29 +153,6 @@ var N = }; - - @@ -313,15 +341,13 @@ Pivot.Init([ ["#6", "a", "short", 0], ["#7", "b", "short", 7], ]); -let pivotRoot1 = Pivot.Create([1, 2], [3]); -//let pivotRoot2 = Pivot.Create([2, 1], [3]); -//let pivots = [pivotRoot1, pivotRoot2]; -let pivots = [pivotRoot1]; +Pivot.Create([1, 2], [3]); let AddNewPivot = () => { - pivots.push(Pivot.Create([2, 1], [3])); -} + Pivot.Create([2], [3]); + Render(); +}; let ElNode = ({node, depth}) => { @@ -405,22 +431,37 @@ let ElNode = ({node, depth}) => ]); }; let ElPivot = ({pivot}) => -{ +{ return h("div", {style:{display:"inline-block", width:"500px"}}, [ + h(ElModifiers, {node:pivot}), h(ElNode, {node:pivot, depth:0}) ]); }; +let ElModifiers = ({node}) => +{ + let modifiers = N.Step(node, "Modifier") || []; + + return h("div", null, [ + h("strong", null, "modifiers"), + ...modifiers.map( m => h("span", {onClick:e=> + { + Pivot.Unmodify(N.Step(m, "ModifyAt")[0]); + Render(); + } + }, "modifier")) + ]); +}; let ElRoot = props => { return h("div", null, [ h("h3", null, "tree view"), + h(ElModifiers, {node:Pivot.Root}), h("button", { onClick:e=> { AddNewPivot(); - Render(); } }, "add new pivot"), - ...pivots.map(pivot=>h(ElPivot, {pivot})) + ...N.Step(Pivot.Root, "Pivot").map(pivot=>h(ElPivot, {pivot})) ]) }; let Render = () => render(h(ElRoot), document.querySelector("#app")); From 23c7c60b5b2695494d340dfffcc366b6cb080b29 Mon Sep 17 00:00:00 2001 From: SethTrowbridge Date: Sat, 15 May 2021 10:47:22 -0400 Subject: [PATCH 16/16] fixed disconnect! can remove all modifiers in pivot --- index.html | 92 +++++++++++++++++++++++++++++------------------------- 1 file changed, 50 insertions(+), 42 deletions(-) diff --git a/index.html b/index.html index 49e492e..6ebb739 100644 --- a/index.html +++ b/index.html @@ -40,24 +40,27 @@ var N = { let remove = (inArray, inMatch) => inArray.findIndex( (inMember, inIndex, inArray) => (inMember === inMatch) ? inArray.splice(inIndex, 1) : false ); + // if no specific child was passed if(inNodeMinor === null) { + // get all the children let check = N.Step(inNodeMajor, inKey); if(!check){ return; } - check.forEach( inLoopNode => - { - if(inLoopNode.Link[inKey].Get.length == 1) - { - // we're about to delete the last get reference on a minor node, just purge the key entirely - delete inLoopNode.Link[inKey]; - } - else - { - remove( inLoopNode.Link[inKey].Get, inNodeMajor); - } + // go down to each child ... + check.forEach( inNodeMinor => + { + let connections = inNodeMinor.Link[inKey]; + remove( connections.Get, inNodeMajor); // ... and remove any reference to the parent + + // if after the remove operation, this child has no connections on inKey, scrub the key + if(!connections.Set.length && !connections.Get.length) + { + delete inNodeMinor.Link[inKey]; + } }); - // we just wiped out all set, if get is empty we can purge the key from major + + // we just wiped out all outgoing connections to the parent, if incoming connections are empty too we can purge the key there as well if(inNodeMajor.Link[inKey].Get.length == 0) { delete inNodeMajor.Link[inKey]; @@ -65,20 +68,27 @@ var N = return; } + // if no specific parent was passed if(inNodeMajor === null) { - inNodeMinor.Link[inKey].Get.forEach( inLoopNode => + // get all the parents + let check = N.Step(inNodeMinor, inKey, false); + if(!check){ return; } + + // go up to each parent ... + check.forEach( inNodeMajor => { - if(inLoopNode.Link[inKey].Set.length == 1) + let connections = inNodeMajor.Link[inKey]; + remove( connections.Set, inNodeMinor); // ... and remove any reference to the child + + // if after the remove operation, this parent has no connections on inKey, scrub the key + if( !connections.Set.length && !connections.Get.length ) { - delete inLoopNode.Link[inKey]; - } - else - { - remove( inLoopNode.Link[inKey].Set, inNodeMinor); + delete inNodeMajor.Link[inKey]; } }); - // we just wiped out all get, if set is empty we can purge the key from minor + + // we just wiped out all incoming connections to the child, if outgoing connections are empty too we can purge the key there as well if(inNodeMinor.Link[inKey].Set.length == 0) { delete inNodeMinor.Link[inKey]; @@ -86,7 +96,7 @@ var N = return; } - + // if a specific parent and child were passed if(inNodeMajor.Link[inKey].Set.length == 1) { delete inNodeMajor.Link[inKey]; @@ -110,7 +120,7 @@ var N = let connectionGroup = inNode.Link[inKey]; if(!connectionGroup) { - if(inForceCreate) + if(inForceCreate === true) { inNode.Link[inKey] = connectionGroup = {Get:[], Set:[]}; } @@ -262,24 +272,24 @@ var Pivot = { N.ID.Walk++; - let pivotRoot = N.Create({Leaves:Pivot.Leaves}); + let pivotRoot = N.Create({Label:"Pivot Root", Leaves:Pivot.Leaves}); N.Connect(Pivot.Root, pivotRoot, "Pivot"); return Pivot.Pivot(pivotRoot, inPivotIndicies, inSumIndicies); }, Delete(inRoot) { - N.ID.Walk++; - - let scan = n => + let check = N.Step(inRoot, "Modifier"); + if(check) { - - }; - - N.Walk(scan, inRoot, "Hierarchy") + while(check.length>0) + { + Pivot.Unmodify(check[0]); + } + } }, Modify(inNode) { - let modified = N.Create({}); + let modified = N.Create({Label:"Modifier"}); N.ID.Walk++; if(N.Step(inNode, "Hierarchy").length) { @@ -290,7 +300,6 @@ var Pivot = } else { - N.Connect(Pivot.Root, modified, "Modifier"); } @@ -313,15 +322,13 @@ var Pivot = return modified; }, - Unmodify(inNode) + Unmodify(inModifier) { - let modifier = N.Step(inNode, "ModifyAt", false)[0]; - - N.Disconnect(modifier, null, "ModifyUp"); - N.Disconnect(modifier, null, "ModifyDown"); - N.Disconnect(modifier, null, "ModifyOut"); - N.Disconnect(modifier, null, "ModifyAt"); - N.Disconnect(null, modifier, "Modifier"); + N.Disconnect(inModifier, null, "ModifyUp"); + N.Disconnect(inModifier, null, "ModifyDown"); + N.Disconnect(inModifier, null, "ModifyOut"); + N.Disconnect(inModifier, null, "ModifyAt"); + N.Disconnect(null, inModifier, "Modifier"); } }; @@ -412,7 +419,7 @@ let ElNode = ({node, depth}) => className:"Icon Modify remove", onClick:e=> { - Pivot.Unmodify(node); + Pivot.Unmodify(N.Step(node, "ModifyAt", false)[0]); Render(); } }, "Unmodify"); @@ -433,6 +440,7 @@ let ElNode = ({node, depth}) => let ElPivot = ({pivot}) => { return h("div", {style:{display:"inline-block", width:"500px"}}, [ + h("button", {onClick:e=>{Pivot.Delete(pivot);Render();}}, "delete?"), h(ElModifiers, {node:pivot}), h(ElNode, {node:pivot, depth:0}) ]); @@ -445,7 +453,7 @@ let ElModifiers = ({node}) => h("strong", null, "modifiers"), ...modifiers.map( m => h("span", {onClick:e=> { - Pivot.Unmodify(N.Step(m, "ModifyAt")[0]); + Pivot.Unmodify(m); Render(); } }, "modifier"))