Skip to content

Commit

Permalink
label of selectedFilters, not token
Browse files Browse the repository at this point in the history
  • Loading branch information
ksuess committed Dec 29, 2020
1 parent 24d7c19 commit d2f1393
Showing 1 changed file with 24 additions and 28 deletions.
52 changes: 24 additions & 28 deletions src/components/Views/FacetedSearch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,44 +157,27 @@ const CustomResultsListItem = ({ result, index }) => {

const myCountElement = ({ totalResults }) => <div>{totalResults} Treffer</div>;

// One Filter of Faceted Navigation
// One single Filter of Faceted Navigation
const customBucketAggregationElement = (props) => {
// console.debug('customBucketAggregationElement', props);
const { title, containerCmp } = props;
const selectedFilters = containerCmp.props.selectedFilters.map((el) => el[1]);
// console.debug(selectedFilters);
// Get label from token
let buckets = containerCmp.props.buckets;
let allFilters = Object.fromEntries(
Array.from(buckets, (x) => [x.key, x.label]),
);
let selectedFilters = containerCmp.props.selectedFilters
.map((el) => el[1])
.map((token) => allFilters[token]);
return (
containerCmp && (
// <Card
// className={
// selectedFilters.length ? 'fnfilter selected' : 'fnfilter unselected'
// }
// >
// <Card.Content>
// <Card.Description>
// {selectedFilters.length ? selectedFilters.join(' ') : title}
// </Card.Description>
// </Card.Content>
// <Card.Content extra>{containerCmp}</Card.Content>
// </Card>

<Dropdown
fluid
text={selectedFilters.length ? selectedFilters.join(' ') : title}
className={
selectedFilters.length ? 'fnfilter selected' : 'fnfilter unselected'
}
>
<Dropdown.Menu>
{containerCmp}
{/* <Dropdown.Item text='New' />
<Dropdown.Item text='Open...' description='ctrl + o' />
<Dropdown.Item icon='trash' text='Move to trash' />
<Dropdown.Divider />
<Dropdown.Item text='Download As...' />
<Dropdown.Item text='Publish To Web' />
<Dropdown.Item text='E-mail Collaborators' /> */}
</Dropdown.Menu>
<Dropdown.Menu>{containerCmp}</Dropdown.Menu>
</Dropdown>
)
);
Expand Down Expand Up @@ -230,14 +213,27 @@ const customBucketAggregationValuesElement = (props) => {
);
};

const overriddenComponents = {
let overriddenComponents = {
// 'BucketAggregation.element': customBucketAggregationElement,
// 'BucketAggregationContainer.element': customBucketAggregationContainerElement,
// 'BucketAggregationValues.element': customBucketAggregationValuesElement,
'ResultsList.item.elasticsearch': CustomResultsListItem,
'Count.element': myCountElement,
};

// TODO configurable layout of filters (menu cards or dropdown)
const configSearchCards = false;
if (!configSearchCards) {
overriddenComponents = {
...overriddenComponents,
...{
'BucketAggregation.element': customBucketAggregationElement,
'BucketAggregationContainer.element': customBucketAggregationContainerElement,
'BucketAggregationValues.element': customBucketAggregationValuesElement,
},
};
}

const initialState = {
queryString: '',
layout: 'list',
Expand Down

0 comments on commit d2f1393

Please sign in to comment.