diff --git a/index.html b/index.html index 0fdb3d7..49e492e 100644 --- a/index.html +++ b/index.html @@ -122,12 +122,17 @@ var N = return (inForward === undefined || inForward === true) ? connectionGroup.Set : connectionGroup.Get; }, - Walk(inIterator, inNode, inKey, inForward) + Walk(inIterator, inNode, inKey, inForward, inTerminal) { let array = N.Step(inNode, inKey, inForward); + + if(!array.length && inTerminal) + { + return inTerminal(inNode); + } + for(let i=0; i N.Create({Row:r})); @@ -255,26 +261,47 @@ var Pivot = Create(inPivotIndicies, inSumIndicies) { N.ID.Walk++; - return Pivot.Pivot(N.Create({Leaves:Pivot.Leaves}), inPivotIndicies, inSumIndicies); + + let pivotRoot = N.Create({Leaves:Pivot.Leaves}); + N.Connect(Pivot.Root, pivotRoot, "Pivot"); + return Pivot.Pivot(pivotRoot, inPivotIndicies, inSumIndicies); + }, + Delete(inRoot) + { + N.ID.Walk++; + + let scan = n => + { + + }; + + N.Walk(scan, inRoot, "Hierarchy") }, Modify(inNode) { let modified = N.Create({}); - let leaves = []; - - let gatherUp = n => + N.ID.Walk++; + if(N.Step(inNode, "Hierarchy").length) { - N.Connect(modified, n, "ModifyUp"); - }; + N.Walk(()=>{}, inNode, "Hierarchy", false, (inRoot)=> + { + N.Connect(inRoot, modified, "Modifier"); + }); + } + else + { + + N.Connect(Pivot.Root, modified, "Modifier"); + } + + let leaves = []; + let gatherUp = n => N.Connect(modified, n, "ModifyUp"); let gatherDown = n => { N.Connect(modified, n, "ModifyDown"); N.Step(n, "Hierarchy").length == 0 ? leaves.push(n) : null; }; - let gatherOut = n => - { - N.Connect(modified, n, "ModifyOut"); - }; + let gatherOut = n => N.Connect(modified, n, "ModifyOut"); N.ID.Walk++; inNode.ID.Walk = N.ID.Walk; @@ -294,6 +321,7 @@ var Pivot = N.Disconnect(modifier, null, "ModifyDown"); N.Disconnect(modifier, null, "ModifyOut"); N.Disconnect(modifier, null, "ModifyAt"); + N.Disconnect(null, modifier, "Modifier"); } }; @@ -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"));