Skip to content

Commit

Permalink
Added optional slectAll props, to pass an action to select all features
Browse files Browse the repository at this point in the history
  • Loading branch information
kappu committed Oct 19, 2016
1 parent d757ced commit 3f5b594
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions web/client/components/data/featuregrid/FeatureGrid.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ const FeatureGrid = React.createClass({
maxZoom: React.PropTypes.number,
zoom: React.PropTypes.number,
toolbar: React.PropTypes.object,
dataSource: React.PropTypes.object
dataSource: React.PropTypes.object,
selectAll: React.PropTypes.func,
selectAllActive: React.PropTypes.bool
},
contextTypes: {
messages: React.PropTypes.object
Expand Down Expand Up @@ -79,7 +81,8 @@ const FeatureGrid = React.createClass({
toolPanel: true,
selectAll: true
},
dataSource: null
dataSource: null,
selectAllActive: false
};
},
shouldComponentUpdate(nextProps) {
Expand Down Expand Up @@ -142,9 +145,24 @@ const FeatureGrid = React.createClass({
nOfFeatures = 0;
this.api.forEachNode(() => {nOfFeatures++; });
}
tools.push(<button key="allrowsselection" onClick={() => { this.selectAllRows(this.props.select.length < nOfFeatures); }}>
let allSelected = false;
if (this.props.selectAll) {
allSelected = this.props.selectAllActive;
}else {
allSelected = !(this.props.select.length < nOfFeatures);
}
tools.push(<button key="allrowsselection" onClick={() => {
if (this.props.selectAll) {
if (!allSelected && this.api) {
this.api.deselectAll();
}
this.props.selectAll(!allSelected);
} else {
this.selectAllRows(!allSelected);
}
}}>
{
this.props.select.length < nOfFeatures ? (
(!allSelected) ? (
<I18N.Message msgId={"featuregrid.selectall"}/>
) : (
<I18N.Message msgId={"featuregrid.deselectall"}/>
Expand Down

0 comments on commit 3f5b594

Please sign in to comment.