-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #130 from partio-scout/feature/generic-filters
Add generic filter that allows user to choose which property is filtered
- Loading branch information
Showing
4 changed files
with
78 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
src/client/components/ParticipantListPage/containers/GenericPropertyFilterContainer.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import React from 'react'; | ||
import { Input } from 'react-bootstrap'; | ||
import { getPropertyFilterContainer } from './PropertyFilterContainer'; | ||
import _ from 'lodash'; | ||
|
||
export function getGenericPropertyFilterContainer(searchFilterStore, searchFilterActions) { | ||
const PropertyFilterContainer = getPropertyFilterContainer(searchFilterStore, searchFilterActions); | ||
|
||
const properties = [ | ||
{ childNaps: 'Lapsi nukkuu päiväunet' }, | ||
{ accommodation: 'Majoittautuminen' }, | ||
{ country: 'Maa' }, | ||
{ willOfTheWisp: 'Virvatuli' }, | ||
{ willOfTheWispWave: 'Virvatulen aalto' }, | ||
]; | ||
|
||
class GenericPropertyFilterContainer extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
property: '', | ||
}; | ||
this.onPropertyChange = this.onPropertyChange.bind(this); | ||
} | ||
|
||
static availableProperties() { | ||
return properties.map(p => _.keys(p)[0]); | ||
} | ||
|
||
onPropertyChange(e) { | ||
this.props.onChange(this.state.property, null); | ||
this.setState({ property: e.target.value }); | ||
searchFilterActions.loadOptions.defer(e.target.value); | ||
} | ||
|
||
render() { | ||
return ( | ||
<div> | ||
<Input type="select" label="Kenttä" value={ this.state.property } onChange={ this.onPropertyChange }> | ||
<option value=""></option> | ||
{ properties.map((property, index) => <option value={ _.keys(property)[0] } key={ index }>{ _.values(property)[0] }</option>) } | ||
</Input> | ||
<PropertyFilterContainer | ||
onChange={ this.props.onChange } | ||
currentSelection={ this.props.currentSelection } | ||
label="" | ||
property={ this.state.property } | ||
/> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
GenericPropertyFilterContainer.propTypes = { | ||
onChange: React.PropTypes.func.isRequired, | ||
currentSelection: React.PropTypes.object.isRequired, | ||
}; | ||
|
||
return GenericPropertyFilterContainer; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters