add a defaultValue parameter to the ReportFilters component

This commit is contained in:
Ron Rennick 2019-05-02 15:21:37 -03:00
parent 0162adf532
commit f529143e14
1 changed files with 5 additions and 1 deletions

View File

@ -74,7 +74,7 @@ class FilterPicker extends Component {
getFilter( value ) {
const { config, query } = this.props;
const allFilters = flattenFilters( config.filters );
value = value || query[ config.param ] || DEFAULT_FILTER;
value = value || query[ config.param ] || config.defaultValue || DEFAULT_FILTER;
return find( allFilters, { value } ) || {};
}
@ -255,6 +255,10 @@ FilterPicker.propTypes = {
* The url paramter this filter will modify.
*/
param: PropTypes.string.isRequired,
/**
* The default paramter value to use instead of 'all'.
*/
defaultValue: PropTypes.string,
/**
* Determine if the filter should be shown. Supply a function with the query object as an argument returning a boolean.
*/