-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
79 additions
and
23 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
oarepo_ui/theme/assets/semantic-ui/js/oarepo_ui/search/SearchAppActiveFilters.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,57 @@ | ||
import PropTypes from "prop-types"; | ||
import React from "react"; | ||
import _groupBy from "lodash/groupBy"; | ||
import _map from "lodash/map"; | ||
import { Label, Icon } from "semantic-ui-react"; | ||
import { withState } from "react-searchkit"; | ||
|
||
const SearchAppActiveFiltersComponent = ({ | ||
filters, | ||
removeActiveFilter, | ||
getLabel, | ||
currentResultsState: { | ||
data: { aggregations }, | ||
}, | ||
}) => { | ||
const groupedData = _groupBy(filters, 0); | ||
|
||
return ( | ||
<> | ||
{_map(groupedData, (filters, key) => ( | ||
<Label.Group key={key}> | ||
<Label pointing="right">{aggregations[key]?.label}</Label> | ||
{filters.map((filter, index) => { | ||
const { label, activeFilter } = getLabel(filter); | ||
return ( | ||
// eslint-disable-next-line react/no-array-index-key | ||
<Label | ||
color="blue" | ||
key={activeFilter} | ||
onClick={() => removeActiveFilter(activeFilter)} | ||
> | ||
<Icon name="filter" /> | ||
{label} | ||
<Icon name="delete" /> | ||
</Label> | ||
); | ||
})} | ||
</Label.Group> | ||
))} | ||
</> | ||
); | ||
}; | ||
|
||
export const SearchAppActiveFilters = withState( | ||
SearchAppActiveFiltersComponent | ||
); | ||
|
||
SearchAppActiveFiltersComponent.propTypes = { | ||
filters: PropTypes.array, | ||
removeActiveFilter: PropTypes.func.isRequired, | ||
getLabel: PropTypes.func.isRequired, | ||
currentResultsState: PropTypes.shape({ | ||
data: PropTypes.shape({ | ||
aggregations: PropTypes.object, | ||
}).isRequired, | ||
}).isRequired, | ||
}; |
5 changes: 0 additions & 5 deletions
5
oarepo_ui/theme/assets/semantic-ui/js/oarepo_ui/search/SearchAppFacets.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
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
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