Skip to content
Snippets Groups Projects
Commit 8724d166 authored by esikkala's avatar esikkala
Browse files

Enable filter deleting for text and timespan filters

parent 34fc261a
No related branches found
No related tags found
No related merge requests found
...@@ -37,6 +37,7 @@ const ActiveFilters = props => { ...@@ -37,6 +37,7 @@ const ActiveFilters = props => {
facetClass={props.facetClass} facetClass={props.facetClass}
updateFacetOption={props.updateFacetOption} updateFacetOption={props.updateFacetOption}
someFacetIsFetching={someFacetIsFetching} someFacetIsFetching={someFacetIsFetching}
fetchFacet={props.fetchFacet}
/> />
); );
}; };
...@@ -49,7 +50,8 @@ ActiveFilters.propTypes = { ...@@ -49,7 +50,8 @@ ActiveFilters.propTypes = {
textFilters: PropTypes.object.isRequired, textFilters: PropTypes.object.isRequired,
timespanFilters: PropTypes.object.isRequired, timespanFilters: PropTypes.object.isRequired,
updateFacetOption: PropTypes.func.isRequired, updateFacetOption: PropTypes.func.isRequired,
someFacetIsFetching: PropTypes.bool.isRequired someFacetIsFetching: PropTypes.bool.isRequired,
fetchFacet: PropTypes.func.isRequired
}; };
export default ActiveFilters; export default ActiveFilters;
...@@ -19,13 +19,35 @@ class ChipsArray extends React.Component { ...@@ -19,13 +19,35 @@ class ChipsArray extends React.Component {
handleDelete = item => () => { handleDelete = item => () => {
if (!this.props.someFacetIsFetching) { if (!this.props.someFacetIsFetching) {
if (item.filterType === 'uriFilter') { switch(item.filterType) {
this.props.updateFacetOption({ case 'uriFilter':
facetClass: this.props.facetClass, this.props.updateFacetOption({
facetID: item.facetID, facetClass: this.props.facetClass,
option: item.filterType, facetID: item.facetID,
value: item.value option: item.filterType,
}); value: item.value
});
break;
case 'textFilter':
this.props.updateFacetOption({
facetClass: this.props.facetClass,
facetID: item.facetID,
option: item.filterType,
value: null
});
break;
case 'timespanFilter': {
this.props.updateFacetOption({
facetClass: this.props.facetClass,
facetID: item.facetID,
option: item.filterType,
value: null
});
this.props.fetchFacet({
facetClass: this.props.facetClass,
facetID: item.facetID,
});
}
} }
} }
}; };
...@@ -91,7 +113,8 @@ ChipsArray.propTypes = { ...@@ -91,7 +113,8 @@ ChipsArray.propTypes = {
data: PropTypes.array.isRequired, data: PropTypes.array.isRequired,
facetClass: PropTypes.string.isRequired, facetClass: PropTypes.string.isRequired,
updateFacetOption: PropTypes.func.isRequired, updateFacetOption: PropTypes.func.isRequired,
someFacetIsFetching: PropTypes.bool.isRequired someFacetIsFetching: PropTypes.bool.isRequired,
fetchFacet: PropTypes.func.isRequired
}; };
export default withStyles(styles)(ChipsArray); export default withStyles(styles)(ChipsArray);
...@@ -193,6 +193,7 @@ class FacetBar extends React.Component { ...@@ -193,6 +193,7 @@ class FacetBar extends React.Component {
updateFacetOption={this.props.updateFacetOption} updateFacetOption={this.props.updateFacetOption}
fetchResultCount={this.props.fetchResultCount} fetchResultCount={this.props.fetchResultCount}
someFacetIsFetching={someFacetIsFetching} someFacetIsFetching={someFacetIsFetching}
fetchFacet={this.props.fetchFacet}
/> />
</Paper> </Paper>
{Object.keys(facets).map(facetID => this.renderFacet(facetID, someFacetIsFetching))} {Object.keys(facets).map(facetID => this.renderFacet(facetID, someFacetIsFetching))}
......
...@@ -91,6 +91,7 @@ class FacetInfo extends React.Component { ...@@ -91,6 +91,7 @@ class FacetInfo extends React.Component {
timespanFilters={timespanFilters} timespanFilters={timespanFilters}
updateFacetOption={this.props.updateFacetOption} updateFacetOption={this.props.updateFacetOption}
someFacetIsFetching={someFacetIsFetching} someFacetIsFetching={someFacetIsFetching}
fetchFacet={this.props.fetchFacet}
/> />
</div> </div>
<Divider className={classes.facetInfoDivider} /> <Divider className={classes.facetInfoDivider} />
...@@ -112,7 +113,8 @@ FacetInfo.propTypes = { ...@@ -112,7 +113,8 @@ FacetInfo.propTypes = {
fetchingResultCount: PropTypes.bool.isRequired, fetchingResultCount: PropTypes.bool.isRequired,
updateFacetOption: PropTypes.func.isRequired, updateFacetOption: PropTypes.func.isRequired,
fetchResultCount: PropTypes.func.isRequired, fetchResultCount: PropTypes.func.isRequired,
someFacetIsFetching: PropTypes.bool.isRequired someFacetIsFetching: PropTypes.bool.isRequired,
fetchFacet: PropTypes.func.isRequired
}; };
export default withStyles(styles)(FacetInfo); export default withStyles(styles)(FacetInfo);
...@@ -116,13 +116,20 @@ const updateFacetFilter = (state, action) => { ...@@ -116,13 +116,20 @@ const updateFacetFilter = (state, action) => {
textFilter: value textFilter: value
}; };
} else if (oldFacet.filterType === 'timespanFilter') { } else if (oldFacet.filterType === 'timespanFilter') {
newFacet = { if (value == null) {
...state.facets[facetID], newFacet = {
timespanFilter: { ...state.facets[facetID],
start: value[0], timespanFilter: null
end: value[1] };
} } else {
}; newFacet = {
...state.facets[facetID],
timespanFilter: {
start: value[0],
end: value[1]
}
};
}
} }
return { return {
...state, ...state,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment