Skip to content

Commit

Permalink
Fix showing relevance
Browse files Browse the repository at this point in the history
  • Loading branch information
tiberiuichim committed Feb 13, 2025
1 parent 0cb3ecf commit c400383
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 26 deletions.
1 change: 0 additions & 1 deletion searchlib/components/FilterList/ActiveFilterList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ const ActiveFilterList = (props) => {
<Icon className="ri-arrow-down-s-line" />
<div className="filter-list-header">
<h4 className="filter-list-title">
{' '}
<FormattedMessage
id="Active filters"
defaultMessage="Active filters"
Expand Down
1 change: 1 addition & 0 deletions searchlib/components/FilterList/ActiveFilterValue.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const ActiveFilterValue = (props) => {
filterLabel
);

// TODO: the active filters are retrieved from the request URL. They should be treated as IDs and translated
return (
<div className="filter-wrapper">
<div className="filter-label">{objFilterLabel}:</div>
Expand Down
27 changes: 12 additions & 15 deletions searchlib/components/SearchView/FilterAsideContentView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { loadingFamily } from '@eeacms/search/state';
import { useAtomValue } from 'jotai';

import { useIntl } from 'react-intl';
import { defineMessages, FormattedMessage } from 'react-intl';
import { defineMessages } from 'react-intl';

const messages = defineMessages({
'Title a-z': {
Expand All @@ -40,10 +40,13 @@ const messages = defineMessages({
id: 'Oldest',
defaultMessage: 'Oldest',
},
Relevance: {
id: 'Relevance',
defaultMessage: 'Relevance',
},
});

export const FilterAsideContentView = (props) => {
// console.log('redraw FilterAsideContentView');
const { appConfig, children, current, wasInteracted } = props;
const { sortOptions, resultViews } = appConfig;
const views = useViews();
Expand Down Expand Up @@ -95,19 +98,13 @@ export const FilterAsideContentView = (props) => {
const { showFilters, showFacets, showClusters, showSorting } = appConfig;
const showPaging = appConfig.showLandingPage === false ? true : wasInteracted;
const intl = useIntl();
const sortOptions2 = sortOptions.map((item) => {
if (!(item.name instanceof String) && item?.name?.id) {
if (item?.name?.id in messages) {
// console.log('sortOptions2', item?.name?.id);
item.name = intl.formatMessage(messages[item.name.id]);
} else {
item.name = item.name.id;
}
}
return item;
});
// console.log('sortOptions3', sortOptions, sortOptions2);
// console.log('props', props);

const sortOptions2 = sortOptions.map((item) => ({
...item,
name: messages[item.name?.id]
? intl.formatMessage(messages[item.name.id])
: item.name,
}));

return (
<>
Expand Down
6 changes: 3 additions & 3 deletions searchlib/components/Sorting/SortingDropdownWithLabel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ const SortingViewComponent = (props) => {

const activeValue = `${sortField}|||${sortDirection}`;

const activeLabel = sortOptions.filter(({ text, value }) => {
return value === activeValue;
})[0].text;
const activeLabel = sortOptions.filter(
({ value }) => value === activeValue,
)[0].text;

const { width } = useWindowDimensions();
const isSmallScreen = width < 1000;
Expand Down
2 changes: 0 additions & 2 deletions searchlib/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ export function getDefaultFilters(appConfig, options) {
// values: facet.default.values.sort(),
// type: facet.default.type || 'any',
// }));
// console.log(defaultFiltersList);
// return defaultFiltersList;
}

Expand All @@ -157,7 +156,6 @@ export const getDefaultFilterValues = (facets, options) => {
: acc,
[],
);
// console.log('defaultFilterValues', defaultFilterValues);
return normalizeFilters(defaultFilterValues);
};

Expand Down
10 changes: 5 additions & 5 deletions searchlib/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -463,11 +463,11 @@ const config = {
},

sortOptions: [
{
name: 'Relevance',
value: '',
direction: '',
},
// {
// name: 'Relevance',
// value: '',
// direction: '',
// },
],
},
},
Expand Down

0 comments on commit c400383

Please sign in to comment.