From 06554b83dc03259711414bc67f63ff70a3106553 Mon Sep 17 00:00:00 2001 From: Gregory Wolanski Date: Wed, 25 Oct 2017 21:35:19 +0200 Subject: [PATCH 1/2] Add expand/collapse all layer groups feature (#130) --- src/components/layers/LayerList.jsx | 49 ++++++++++++++++++++++++++--- src/styles/_layer.scss | 2 +- 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/src/components/layers/LayerList.jsx b/src/components/layers/LayerList.jsx index 00bf33e..d18c356 100644 --- a/src/components/layers/LayerList.jsx +++ b/src/components/layers/LayerList.jsx @@ -49,6 +49,7 @@ class LayerListContainer extends React.Component { super(props) this.state = { collapsedGroups: {}, + areAllGroupsExpanded: false, isOpen: { add: false, } @@ -94,6 +95,31 @@ class LayerListContainer extends React.Component { }) } + toggleLayers() { + let idx=0 + + let newGroups=[] + + this.groupedLayers().forEach(layers => { + const groupPrefix = layerPrefix(layers[0].id) + const lookupKey = [groupPrefix, idx].join('-') + + + if (layers.length > 1) { + newGroups[lookupKey] = this.state.areAllGroupsExpanded + } + + layers.forEach((layer) => { + idx += 1 + }) + }); + + this.setState({ + collapsedGroups: newGroups, + areAllGroupsExpanded: !this.state.areAllGroupsExpanded + }) + } + groupedLayers() { const groups = [] for (let i = 0; i < this.props.layers.length; i++) { @@ -176,12 +202,25 @@ class LayerListContainer extends React.Component { />
Layers +
+
+ + {this.state.areAllGroupsExpanded === true ? "Collapse" : "Expand"} + +
+
- +
+
+ + Add Layer + +
+