From ede7f35c870ad71b8122e61c44a95f449b72b9fa Mon Sep 17 00:00:00 2001 From: TreetopFlyer Date: Sat, 29 May 2021 16:04:38 -0400 Subject: [PATCH] column visibility --- index.html | 49 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/index.html b/index.html index 864b245..0197df2 100755 --- a/index.html +++ b/index.html @@ -713,7 +713,6 @@ let ModificationsIcon = ({node}) => let PivotBranch = props => { let row = props.node.Meta.Row; - let displayCells = row.map(column=>h("td", null, column)); let displayCellsModify = row.map(column=>false); props.node.Meta.IndexSum.forEach(i=> { @@ -727,6 +726,20 @@ let PivotBranch = props => } }); + let displayCells = (node, visible) => + { + let output = []; + node.Meta.Row.forEach((column, i)=> + { + if(visible[i]) + { + output.push( h("td", null, column) ); + } + } + ); + return output; + } + let stylesLeaf = css` background:#ddd; color:#333; @@ -741,7 +754,7 @@ let PivotBranch = props => <${ModificationsIcon} node=${props.node}> - ${displayCells} + ${displayCells(props.node, props.visible)} ${(N.Step(props.node, "Leaf")||[]).map(leaf => { @@ -749,9 +762,7 @@ let PivotBranch = props => <${ModificationsIcon} node=${leaf}> - ${ - leaf.Meta.Row.map(column=>h("td", null, column)) - } + ${displayCells(leaf, props.visible)} `; } @@ -763,6 +774,9 @@ let PivotBranch = props => let PivotRoot = ({pivot}) => { + let labels = (N.Step(Pivot.Schema, "all")||[]).map(column => column.Meta.Label); + let [visibleGet, visibleSet] = useState(labels.map(column=>true)); + let stylesRoot = css` display:block; box-sizing:border-box; @@ -784,13 +798,36 @@ let PivotRoot = ({pivot}) => let rows = []; N.ID.Walk++; - N.Walk(n=>rows.push(h(PivotBranch, {node:n}, null)), pivot, "Hierarchy"); + N.Walk(n=>rows.push(h(PivotBranch, {node:n, visible:visibleGet}, null)), pivot, "Hierarchy"); return html`
${pivot.Meta.Label}
<${Section} key="settings" label=${`Settings`}> +

pivot

+

columns

+
+ + +
+
+ ${visibleGet.map((v, i) => html``)} +
<${Section} key="tree" label=${"Tree"}>