Skip to content

Commit

Permalink
Merge pull request #812 from danskernesdigitalebibliotek/update-advan…
Browse files Browse the repository at this point in the history
…ced-search-filters

Update advanced search filters
  • Loading branch information
Adamik10 authored Jan 2, 2024
2 parents 8a3f7a2 + 924c47e commit f8e847a
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 41 deletions.
15 changes: 9 additions & 6 deletions src/apps/advanced-search/AdvancedSearchResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const AdvancedSearchResult: React.FC<AdvancedSearchResultProps> = ({
}, [data, page]);

const shouldShowSearchResults = isLoading || (!isLoading && hitcount > 0);
const shouldShowResultHeadline = hitcount && !isLoading;
const shouldShowResultHeadline = !!(hitcount && !isLoading);

useEffect(() => {
if (copiedLinkToSearch) {
Expand All @@ -108,11 +108,14 @@ const AdvancedSearchResult: React.FC<AdvancedSearchResultProps> = ({
/* ID is used to scroll to the results upon hitting the search button. */
id="advanced-search-result"
>
{isLoading && t("loadingResultsText")}
{shouldShowResultHeadline &&
t("showingMaterialsText", {
placeholders: { "@hitcount": hitcount }
})}
{isLoading && <>{t("loadingResultsText")}</>}
{shouldShowResultHeadline && (
<>
{t("showingMaterialsText", {
placeholders: { "@hitcount": hitcount }
})}
</>
)}
</h2>
{!showContentOnly && (
<button
Expand Down
4 changes: 2 additions & 2 deletions src/apps/advanced-search/advanced-search.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe("Search Result", () => {
cy.getBySel("advanced-search-material-types").first().click();
cy.getBySel("preview-section", true).should(
"contain",
"'Harry' AND 'Prince' AND generalmaterialtype='bøger'"
"'Harry' AND 'Prince' AND term.generalmaterialtype='bøger'"
);
});

Expand Down Expand Up @@ -170,7 +170,7 @@ describe("Search Result", () => {
.eq(1)
.within(() => {
cy.get("input").should("have.value", "Rowling");
cy.get("select").should("have.value", "creator");
cy.get("select").should("have.value", "term.creatorcontributor");
});
// We currently have no good way to identify selected options in the
// multiselect so checking the text of the button is the best we can do.
Expand Down
62 changes: 29 additions & 33 deletions src/apps/advanced-search/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,36 @@ import { MultiselectOption } from "../../components/multiselect/types";

export const advancedSearchIndexes = [
"all",
"creator",
"subject",
"genre",
"language",
"date",
"mainCreator",
"mainTitle",
"source",
"dateFirstEdition",
"decimaldk5",
"type",
"audience",
"publisher",
"identifier",
"acSource"
"term.creatorcontributor",
"term.subject",
"term.genreandform",
"term.mainlanguage",
"datefirstedition",
"term.creator",
"term.title",
"term.source",
"dk5",
"term.specificmaterialtype",
"term.childrenoradults",
"term.publisher",
"term.isbn"
] as const;

export const advancedSearchIndexTranslations = {
all: "advancedSearchAllIndexesText",
creator: "advancedSearchCreatorText",
subject: "advancedSearchSubjectText",
genre: "advancedSearchGenreText",
language: "advancedSearchLanguageText",
date: "advancedSearchDateText",
mainCreator: "advancedSearchMainCreatorText",
mainTitle: "advancedSearchMainTitleText",
source: "advancedSearchSourceText",
dateFirstEdition: "advancedSearchDateFirstEditionText",
decimaldk5: "advancedSearchDecimalDk5Text",
type: "advancedSearchTypeText",
audience: "advancedSearchAudienceText",
publisher: "advancedSearchPublisherText",
identifier: "advancedSearchIdentifierText",
acSource: "advancedSearchAcSourceText"
"term.creatorcontributor": "advancedSearchCreatorText",
"term.subject": "advancedSearchSubjectText",
"term.genreandform": "advancedSearchGenreText",
"term.mainlanguage": "advancedSearchLanguageText",
datefirstedition: "advancedSearchDateText",
"term.creator": "advancedSearchMainCreatorText",
"term.title": "advancedSearchMainTitleText",
"term.source": "advancedSearchSourceText",
dk5: "advancedSearchDecimalDk5Text",
"term.specificmaterialtype": "advancedSearchTypeText",
"term.childrenoradults": "advancedSearchAudienceText",
"term.publisher": "advancedSearchPublisherText",
"term.isbn": "advancedSearchIdentifierText"
} as const;

export type AdvancedSearchIndex = typeof advancedSearchIndexes[number];
Expand Down Expand Up @@ -106,7 +102,7 @@ export const advancedSearchFiction: MultiselectOption[] = [
];

export const advancedSearchFilters = {
materialTypes: "generalmaterialtype",
fiction: "fictionnonfiction",
accessibility: "accesstype"
materialTypes: "term.generalmaterialtype",
fiction: "term.fictionnonfiction",
accessibility: "term.accesstype"
};

0 comments on commit f8e847a

Please sign in to comment.