Skip to content

Commit

Permalink
Bug fix for metadata values not part of vocabularies
Browse files Browse the repository at this point in the history
  • Loading branch information
ksuess committed Sep 21, 2023
1 parent 7822514 commit b1f370f
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/components/Views/FacetedSearch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ const _CustomResultsListItem = (props) => {
const translate = (key) => {
let label = key;
if (querystringindexes?.informationtype) {
label = querystringindexes.informationtype.values[key].title;
label = querystringindexes.informationtype.values[key]?.title || key;
}
return label;
};
Expand All @@ -228,7 +228,8 @@ const _CustomResultsListItem = (props) => {
className={cx('searchkitresultitem', result.review_state)}
>
<Item.Content>
{result.informationtype?.length ? (
{Array.isArray(result.informationtype) &&
result.informationtype?.length > 0 ? (
<Item.Meta>
{result.informationtype?.map((item, index) => {
let tito = translate(item);
Expand Down Expand Up @@ -336,10 +337,17 @@ const CustomBucketAggregationElement = (props) => {
(state) => state.query?.data?.querystringindexes,
);

/**
* Translate labels according vocabulary
* @param {*} bucks
* @returns
*/
const translate = (bucks) => {
if (querystringindexes[fieldname]) {
bucks.forEach((element) => {
element.label = querystringindexes[fieldname].values[element.key].title;
element.label =
querystringindexes[fieldname].values[element.key]?.title ||
element.key;
});
}
return bucks;
Expand Down

0 comments on commit b1f370f

Please sign in to comment.