Skip to content
Snippets Groups Projects
Commit 44f54e1c authored by esikkala's avatar esikkala
Browse files

Active filters: add delete buttons for uri filters

parent 6ec766fb
No related branches found
No related tags found
No related merge requests found
...@@ -2,6 +2,7 @@ import React from 'react'; ...@@ -2,6 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { withStyles } from '@material-ui/core/styles'; import { withStyles } from '@material-ui/core/styles';
import Chip from '@material-ui/core/Chip'; import Chip from '@material-ui/core/Chip';
import Tooltip from '@material-ui/core/Tooltip';
const styles = theme => ({ const styles = theme => ({
root: { root: {
...@@ -16,13 +17,15 @@ const styles = theme => ({ ...@@ -16,13 +17,15 @@ const styles = theme => ({
class ChipsArray extends React.Component { class ChipsArray extends React.Component {
handleDelete = data => () => { handleDelete = item => () => {
this.props.updateFacetOption({ if (item.filterType === 'uriFilter') {
facetClass: this.props.facetClass, this.props.updateFacetOption({
facetID: data.facetID, facetClass: this.props.facetClass,
option: data.filterType, facetID: item.facetID,
value: data.value // a react sortable tree object option: item.filterType,
}); value: item.value
});
}
}; };
generateLabel = (facetLabel, valueLabel, filterType) => { generateLabel = (facetLabel, valueLabel, filterType) => {
...@@ -63,12 +66,17 @@ class ChipsArray extends React.Component { ...@@ -63,12 +66,17 @@ class ChipsArray extends React.Component {
${this.ISOStringToYear(item.value.end)}`; ${this.ISOStringToYear(item.value.end)}`;
} }
return ( return (
<Chip <Tooltip key={key} title={`${item.facetLabel}: ${valueLabel}`}>
key={key} <Chip
icon={icon} key={key}
label={this.generateLabel(item.facetLabel, valueLabel, item.filterType)} icon={icon}
className={classes.chip} label={this.generateLabel(item.facetLabel, valueLabel, item.filterType)}
/> className={classes.chip}
onDelete={this.handleDelete(item)}
color="primary"
/>
</Tooltip>
); );
})} })}
</div> </div>
......
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