Skip to content

Commit

Permalink
add Browse results processing
Browse files Browse the repository at this point in the history
  • Loading branch information
SKarolFolio committed Oct 18, 2024
1 parent 92262f8 commit 58e6ed5
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 34 deletions.
51 changes: 27 additions & 24 deletions src/common/helpers/search/formatters/authorities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,31 @@ export const formatAuthorityItem = (
authoritiesList: AuthorityAsSearchResultDTO[],
sourceData?: SourceDataDTO,
): SearchResultsTableRow[] =>
authoritiesList?.map(({ id, authRefType, headingRef, headingType, sourceFileId }) => {
const sourceLabel = sourceData?.find(({ id: sourceId }) => sourceId === sourceFileId)?.name ?? sourceFileId;
authoritiesList?.map(
({ id = '', authRefType = '', headingRef = '', headingType = '', sourceFileId = '', isAnchor = false }) => {
const sourceLabel = sourceData?.find(({ id: sourceId }) => sourceId === sourceFileId)?.name ?? sourceFileId;

return {
__meta: {
id,
key: uuidv4(),
},
authorized: {
label: authRefType,
},
title: {
label: headingRef,
className: 'title',
},
subclass: {
label: headingType,
className: 'heading-type',
},
authoritySource: {
label: sourceLabel,
className: 'authority-source',
},
};
});
return {
__meta: {
id,
key: uuidv4(),
isAnchor,
},
authorized: {
label: authRefType,
},
title: {
label: headingRef,
className: 'title',
},
subclass: {
label: headingType,
className: 'heading-type',
},
authoritySource: {
label: sourceLabel,
className: 'authority-source',
},
};
},
);
2 changes: 1 addition & 1 deletion src/common/hooks/useSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export const useSearch = () => {
query: generatedQuery,
offset: offset?.toString(),
limit: searchResultsLimit?.toString(),
resultsContainer: searchResultsContainer,
resultsContainer: searchResultsContainer?.[selectedNavigationSegment as SearchSegmentValue],
})
: await getByIdentifier({
endpointUrl: currentEndpointUrl ?? endpointUrl,
Expand Down
3 changes: 2 additions & 1 deletion src/common/i18n/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ export const BASE_LOCALE = {
'ld.fetchingExternalResourceById': 'Fetching external resource id {resourceId}...',
'ld.lastUpdated': 'Last updated',
'ld.marcAuthorityRecord': 'MARC authority record',
'ld.selectBrowseOption': 'Select a browse option'
'ld.selectBrowseOption': 'Select a browse option',
'ld.searchQueryWouldBeHere': '{query} would be here'
};

export const i18nMessages = {
Expand Down
1 change: 1 addition & 0 deletions src/common/styles/common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ $disabled-input-bg-color: #ebebe4;
$disabled-input-color: #777;
$buttonHighlighted: #1960a4;
$buttonActive: rgba(37, 118, 195, 0.3);
$error: #990000;

$btn-hover-drop-shadow: 0px 10px 10px -6px rgba(0, 0, 0, 0.37);
$highlighted-focusable-outline-box-shadow:
Expand Down
8 changes: 5 additions & 3 deletions src/components/CommonStatus/CommonStatus.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import '@common/styles/common.scss';

.common-status {
position: fixed;
bottom: 1.75rem;
Expand Down Expand Up @@ -61,13 +63,13 @@
}

&.error {
border-color: #990000;
color: #990000;
border-color: $error;
color: $error;
background-color: #ead2d0;

.status-message-icon path,
.status-message-close path {
fill: #990000;
fill: $error;
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/components/ComplexLookupField/ModalComplexLookup.scss
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@
text-decoration: underline;
}
}

.search-results-item-missing-match {
font-weight: 700;

&-query {
color: $error;
}
}
}

.table-header-contents-wrapper {
Expand Down
2 changes: 1 addition & 1 deletion src/components/ComplexLookupField/ModalComplexLookup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export const ModalComplexLookup: FC<ModalComplexLookupProps> = memo(
getSearchFacetsData={getFacetsData}
fetchSearchResults={getSearchResults}
searchResultsLimit={api.searchQuery.limit}
searchResultsContainer={api.results.container}
searchResultsContainer={api.results.containers}
onAssignRecord={onAssign}
/>
</div>
Expand Down
11 changes: 10 additions & 1 deletion src/components/ComplexLookupField/configs/Authorities.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,16 @@ export const authoritiesTableConfig: SearchResultsTableConfig = {
onTitleClick?.(__meta.id, title.label as string, subclass.label as string);
};

return (
return __meta.isAnchor ? (
<div className='search-results-item-missing-match'>
<FormattedMessage
id="ld.searchQueryWouldBeHere"
values={{
query: <span className='search-results-item-missing-match-query'>{row.title.label}</span>,
}}
/>
</div>
) : (
<Button type={ButtonType.Link} className="search-results-item-title" onClick={handleClick}>
{row.title.label}
</Button>
Expand Down
5 changes: 4 additions & 1 deletion src/configs/complexLookup/complexLookup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ export const COMPLEX_LOOKUPS_CONFIG: ComplexLookupsConfig = {
limit: 100,
},
results: {
container: 'authorities',
containers: {
[SearchSegment.Search]: 'authorities',
[SearchSegment.Browse]: 'items',
},
},
},
labels: {
Expand Down
1 change: 1 addition & 0 deletions src/types/api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ type AuthorityAsSearchResultDTO = {
headingRef?: string;
headingType?: string;
sourceFileId?: string;
isAnchor?: boolean;
[key: string]: string | string[];
};

Expand Down
4 changes: 3 additions & 1 deletion src/types/complexLookup.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ type ComplexLookupApiEntryConfig = {
limit?: number;
};
results: {
container: string;
containers: {
[key in SearchSegment]: string;
};
};
};

Expand Down
4 changes: 3 additions & 1 deletion src/types/search.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ type SearchParams = {
getSearchFacetsData?: (facet?: string, isOpen?: boolean) => Promise<void>;
searchResultsLimit?: number;
fetchSearchResults?: (params: any) => Promise<SearchResults>;
searchResultsContainer?: string;
searchResultsContainer?: {
[key in SearchSegment]: string;
};
hasMarcPreview?: boolean;
renderMarcPreview?: () => JSX.Element | null;
onAssignRecord?: ({ id, title, linkedFieldValue }: ComplexLookupAssignRecordDTO) => void;
Expand Down

0 comments on commit 58e6ed5

Please sign in to comment.