Skip to content

Commit

Permalink
cleanup and remove of IGIB naming
Browse files Browse the repository at this point in the history
  • Loading branch information
ksuess committed Dec 29, 2020
1 parent 4f9cffa commit 7a17bac
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 54 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
/*
* respect IGIB filters: kompasscomponent, targetaudience, ...
*/

import _extend from 'lodash/extend';
import _isEmpty from 'lodash/isEmpty';

import { listFields, nestedFields } from './constants.js';

export class IGIBESRequestSerializer {
export class CustomESRequestSerializer {
getFilters = (filters) => {
/**
* input: [
Expand Down Expand Up @@ -50,8 +46,8 @@ export class IGIBESRequestSerializer {
*/
serialize = (stateQuery) => {
const { queryString, sortBy, sortOrder, page, size, filters } = stateQuery;
// console.debug('IGIBESRequestSerializer queryString', queryString);
// console.debug('IGIBESRequestSerializer filters', filters);
// console.debug('CustomESRequestSerializer queryString', queryString);
// console.debug('CustomESRequestSerializer filters', filters);

const bodyParams = {};
if (!_isEmpty(queryString)) {
Expand Down
56 changes: 9 additions & 47 deletions src/components/Views/FacetedSearch.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO update counts of BucketAggregation on selection of filter
import React, { useEffect } from 'react';

import { OverridableContext } from 'react-overridable';
Expand Down Expand Up @@ -25,7 +26,7 @@ import {
} from 'react-searchkit';

import { ESSearchApi } from '../Searchkit/ESSearchApi';
import { IGIBESRequestSerializer } from '../Searchkit/IGIBESRequestSerializer';
import { CustomESRequestSerializer } from '../Searchkit/CustomESRequestSerializer';
import { Results } from '../Searchkit/Results';

import { settings } from '~/config';
Expand All @@ -39,42 +40,6 @@ import './less/public.less';

const OnResults = withState(Results);

const customAggComp = (title, containerCmp) => {
return containerCmp ? (
<Menu vertical>
<Menu.Item>
<Menu.Header>{title}</Menu.Header>
{containerCmp}
</Menu.Item>
</Menu>
) : null;
};

const customAggValuesContainerCmp = (valuesCmp) => (
<Menu.Menu>{valuesCmp}</Menu.Menu>
);

const customAggValueCmp = (
bucket,
isSelected,
onFilterClicked,
getChildAggCmps,
) => {
const childAggCmps = getChildAggCmps(bucket);
return (
<Menu.Item
key={bucket.key}
name={bucket.key}
active={isSelected}
onClick={() => onFilterClicked(bucket.key)}
>
<Label>{bucket.doc_count}</Label>
{bucket.key}
{childAggCmps}
</Menu.Item>
);
};

// class Tags extends Component {
// onClick = (event, value) => {
// window.history.push({
Expand All @@ -97,7 +62,7 @@ const customAggValueCmp = (
// }
// }

const IGIBResultsListItem = ({ result, index }) => {
const CustomResultsListItem = ({ result, index }) => {
return (
<Item key={index}>
<Item.Content>
Expand Down Expand Up @@ -193,7 +158,7 @@ const myCountElement = ({ totalResults }) => <div>{totalResults} Treffer</div>;

// One Filter of Faceted Navigation
const customBucketAggregationElement = (props) => {
// console.debug('IGIBBucketAggregationElement', props);
// console.debug('customBucketAggregationElement', props);
const { title, containerCmp } = props;
const selectedFilters = containerCmp.props.selectedFilters.map((el) => el[1]);
// console.debug(selectedFilters);
Expand Down Expand Up @@ -265,10 +230,10 @@ const customBucketAggregationValuesElement = (props) => {
};

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

Expand All @@ -295,7 +260,7 @@ const FacetedSearch = ({ data, location }) => {
headers: { Accept: 'application/json' },
},
es: {
requestSerializer: IGIBESRequestSerializer,
requestSerializer: CustomESRequestSerializer,
},
});

Expand Down Expand Up @@ -325,9 +290,6 @@ const FacetedSearch = ({ data, location }) => {
field: 'kompasscomponent',
aggName: 'kompasscomponent_agg.kompasscomponent_token',
}}
renderElement={customAggComp}
renderValuesContainerElement={customAggValuesContainerCmp}
renderValueElement={customAggValueCmp}
/>
<BucketAggregation
title="Zielpublikum"
Expand Down

0 comments on commit 7a17bac

Please sign in to comment.