Merge pull request #185 from gregorywolanski/130

Add expand/collapse all layer groups feature (#130)
This commit is contained in:
Orange Mug 2018-01-04 15:52:38 +00:00 committed by GitHub
commit 6e86c60f89
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 45 additions and 6 deletions

View file

@ -50,6 +50,7 @@ class LayerListContainer extends React.Component {
super(props)
this.state = {
collapsedGroups: {},
areAllGroupsExpanded: false,
isOpen: {
add: false,
}
@ -95,6 +96,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++) {
@ -178,11 +204,24 @@ class LayerListContainer extends React.Component {
<header className="maputnik-layer-list-header">
<span className="maputnik-layer-list-header-title">Layers</span>
<span className="maputnik-space" />
<Button
onClick={this.toggleModal.bind(this, 'add')}
className="maputnik-add-layer">
Add Layer
</Button>
<div className="maputnik-default-property">
<div className="maputnik-multibutton">
<a
onClick={this.toggleLayers.bind(this)}
className="maputnik-button">
{this.state.areAllGroupsExpanded === true ? "Collapse" : "Expand"}
</a>
</div>
</div>
<div className="maputnik-default-property">
<div className="maputnik-multibutton">
<a
onClick={this.toggleModal.bind(this, 'add')}
className="maputnik-button maputnik-button-selected">
Add Layer
</a>
</div>
</div>
</header>
<ul className="maputnik-layer-list-container">
{listItems}

View file

@ -1,7 +1,7 @@
// LAYER LIST
.maputnik-layer-list {
&-header {
padding: $margin-2;
padding: $margin-2 $margin-2 $margin-3;
@include flex-row;