From ba5443f6e720d522acd7be49c630b7f12da26b4e Mon Sep 17 00:00:00 2001 From: sasse Date: Wed, 19 Jun 2024 14:53:40 +0200 Subject: [PATCH 1/3] fix(Breadcrumb): minor fix of undefined ontologyName key --- .../MetadataWidget/BreadcrumbWidget/BreadcrumbPresentation.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/widgets/MetadataWidget/BreadcrumbWidget/BreadcrumbPresentation.tsx b/src/components/widgets/MetadataWidget/BreadcrumbWidget/BreadcrumbPresentation.tsx index 06eb1a52..c9231b92 100644 --- a/src/components/widgets/MetadataWidget/BreadcrumbWidget/BreadcrumbPresentation.tsx +++ b/src/components/widgets/MetadataWidget/BreadcrumbWidget/BreadcrumbPresentation.tsx @@ -7,7 +7,7 @@ function BreadcrumbPresentation(props: BreadcrumbPresentationProps) { <> - {props.ontologyName.toUpperCase()} + {props.ontologyName ? props.ontologyName.toUpperCase() : "No ontology name available"} {" > "} From 0bff1e855e037f4b2dab2e3189ef466ef150d455 Mon Sep 17 00:00:00 2001 From: sasse Date: Thu, 20 Jun 2024 09:15:59 +0200 Subject: [PATCH 2/3] fix(search): add useLegacy parameter because of facet key diffs --- dist_plainjs/manually_maintained_types.d.ts | 1 + src/app/types.ts | 2 +- .../SearchResultsListWidget.stories.tsx | 3 +- .../SearchResultsListWidget.tsx | 36 ++++++++++++------- .../SearchResultsListWidgetHTML.stories.ts | 6 +++- .../SearchResultsListWidgetStories.ts | 14 ++++++++ 6 files changed, 47 insertions(+), 15 deletions(-) diff --git a/dist_plainjs/manually_maintained_types.d.ts b/dist_plainjs/manually_maintained_types.d.ts index 859f589d..dd111455 100644 --- a/dist_plainjs/manually_maintained_types.d.ts +++ b/dist_plainjs/manually_maintained_types.d.ts @@ -224,6 +224,7 @@ declare global { initialItemsPerPage?: number; itemsPerPageOptions?: number[]; targetLink?: string; + useLegacy?: boolean; } & Partial> )=>void } diff --git a/src/app/types.ts b/src/app/types.ts index ea891601..d5d62624 100644 --- a/src/app/types.ts +++ b/src/app/types.ts @@ -353,7 +353,7 @@ export type SearchBarWidgetProps = Omit void; }; -export type SearchResultsListWidgetProps = Partial> & ApiObj & TargetLinkObj & ParameterObj & { +export type SearchResultsListWidgetProps = Partial> & ApiObj & TargetLinkObj & ParameterObj & UseLegacyObj &{ /** * The terms to search. By default, the search is performed over term labels, synonyms, descriptions, identifiers and annotation properties. */ diff --git a/src/components/widgets/SearchResultsListWidget/SearchResultsListWidget.stories.tsx b/src/components/widgets/SearchResultsListWidget/SearchResultsListWidget.stories.tsx index 0e3e464f..84ae3e24 100644 --- a/src/components/widgets/SearchResultsListWidget/SearchResultsListWidget.stories.tsx +++ b/src/components/widgets/SearchResultsListWidget/SearchResultsListWidget.stories.tsx @@ -13,5 +13,6 @@ export { SearchResultsListNFDI4Health, ErrorSearchResultsList, TibNFDI4CHEM, - TibDataPlant + TibDataPlant, + SearchResultsListOls4 } from "./SearchResultsListWidgetStories" diff --git a/src/components/widgets/SearchResultsListWidget/SearchResultsListWidget.tsx b/src/components/widgets/SearchResultsListWidget/SearchResultsListWidget.tsx index 406a57b5..a4826bcd 100644 --- a/src/components/widgets/SearchResultsListWidget/SearchResultsListWidget.tsx +++ b/src/components/widgets/SearchResultsListWidget/SearchResultsListWidget.tsx @@ -33,6 +33,7 @@ function SearchResultsListWidget(props: SearchResultsListWidgetProps) { itemsPerPageOptions = DEFAULT_PAGE_SIZE_OPTIONS, targetLink, preselected, + useLegacy = true, ...rest } = props; const olsApi = new OlsApi(api); @@ -130,20 +131,31 @@ function SearchResultsListWidget(props: SearchResultsListWidgetProps) { if (response["facet_counts"] && response["facet_counts"]["facet_fields"]) { if (response["facet_counts"]["facet_fields"]["type"]) { updateFilterOptions( - filterByTypeOptions, - response["facet_counts"]["facet_fields"]["type"], - setFilterByTypeOptions, - (currentValue: string) => `${currentValue[0].toUpperCase()}${currentValue.slice(1)}` - ); - } - if (response["facet_counts"]["facet_fields"]["ontology_name"]) { - updateFilterOptions( - filterByOntologyOptions, - response["facet_counts"]["facet_fields"]["ontology_name"], - setFilterByOntologyOptions, - (currentValue: string) => currentValue.toUpperCase() + filterByTypeOptions, + response["facet_counts"]["facet_fields"]["type"], + setFilterByTypeOptions, + (currentValue: string) => `${currentValue[0].toUpperCase()}${currentValue.slice(1)}` ); } + if (useLegacy) { + if (response["facet_counts"]["facet_fields"]["ontology_name"]) { + updateFilterOptions( + filterByOntologyOptions, + response["facet_counts"]["facet_fields"]["ontology_name"], + setFilterByOntologyOptions, + (currentValue: string) => currentValue.toUpperCase() + ); + } + } else { + if (response["facet_counts"]["facet_fields"]["ontologyId"]) { + updateFilterOptions( + filterByOntologyOptions, + response["facet_counts"]["facet_fields"]["ontologyId"], + setFilterByOntologyOptions, + (currentValue: string) => currentValue.toUpperCase() + ); + } + } } setTotalItems(response["response"]["numFound"]); diff --git a/src/components/widgets/SearchResultsListWidget/SearchResultsListWidgetHTML.stories.ts b/src/components/widgets/SearchResultsListWidget/SearchResultsListWidgetHTML.stories.ts index 27de68d0..4f66b212 100644 --- a/src/components/widgets/SearchResultsListWidget/SearchResultsListWidgetHTML.stories.ts +++ b/src/components/widgets/SearchResultsListWidget/SearchResultsListWidgetHTML.stories.ts @@ -31,6 +31,7 @@ window['SemLookPWidgets'].createSearchResultsList( initialItemsPerPage:${args.initialItemsPerPage}, itemsPerPageOptions:[${args.itemsPerPageOptions}], targetLink:"${args.targetLink}", + useLegacy:"${args.useLegacy}", }, document.querySelector('#search_results_list_widget_container_${num}') ) @@ -44,5 +45,8 @@ window['SemLookPWidgets'].createSearchResultsList( export { SearchResultsListSafety, SearchResultsListNFDI4Health, - ErrorSearchResultsList + ErrorSearchResultsList, + TibNFDI4CHEM, + TibDataPlant, + SearchResultsListOls4 } from "./SearchResultsListWidgetStories" diff --git a/src/components/widgets/SearchResultsListWidget/SearchResultsListWidgetStories.ts b/src/components/widgets/SearchResultsListWidget/SearchResultsListWidgetStories.ts index 8d382760..28ae6f90 100644 --- a/src/components/widgets/SearchResultsListWidget/SearchResultsListWidgetStories.ts +++ b/src/components/widgets/SearchResultsListWidget/SearchResultsListWidgetStories.ts @@ -21,6 +21,9 @@ export const SearchResultsListWidgetStoryArgTypes = { parameter: { type: { required: false } }, + useLegacy: { + type: { required: false } + } } export const SearchResultsListWidgetStoryArgs = { @@ -47,6 +50,7 @@ export const SearchResultsListNFDI4Health = { targetLink: "", parameter: "collection=nfdi4health", preselected: [{ label: "diabetes" }], + useLegacy: true } }; @@ -75,4 +79,14 @@ export const TibDataPlant = { query: "agriculture", targetLink: "", } +}; + +export const SearchResultsListOls4 = { + args: { + api: "https://www.ebi.ac.uk/ols4/api/", + query: "*", + targetLink: "/", + parameter: "", + useLegacy: false + } }; \ No newline at end of file From 0b7d246957f3a2a8aa2ac29384d4a70d1e75363b Mon Sep 17 00:00:00 2001 From: Roman Baum Date: Thu, 20 Jun 2024 11:41:43 +0200 Subject: [PATCH 3/3] feat(SearchResultsListWidget): Added parameter to show the description for an OLS3 API in the autocomplete result list. --- .../SearchResultsListWidget.tsx | 1 + .../SearchResultsListWidgetStories.ts | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/components/widgets/SearchResultsListWidget/SearchResultsListWidget.tsx b/src/components/widgets/SearchResultsListWidget/SearchResultsListWidget.tsx index a4826bcd..5ffe503a 100644 --- a/src/components/widgets/SearchResultsListWidget/SearchResultsListWidget.tsx +++ b/src/components/widgets/SearchResultsListWidget/SearchResultsListWidget.tsx @@ -220,6 +220,7 @@ function SearchResultsListWidget(props: SearchResultsListWidgetProps) { singleSelection={true} hasShortSelectedLabel={true} placeholder={"Search"} + parameter={parameter} preselected={preselected} /> diff --git a/src/components/widgets/SearchResultsListWidget/SearchResultsListWidgetStories.ts b/src/components/widgets/SearchResultsListWidget/SearchResultsListWidgetStories.ts index 28ae6f90..8fa078ee 100644 --- a/src/components/widgets/SearchResultsListWidget/SearchResultsListWidgetStories.ts +++ b/src/components/widgets/SearchResultsListWidget/SearchResultsListWidgetStories.ts @@ -39,7 +39,7 @@ export const SearchResultsListSafety = { api: "https://semanticlookup.zbmed.de/api/", query: "d*", targetLink: "", - parameter: "collection=safety", + parameter: "collection=safety&fieldList=description,label,iri,ontology_name,type,short_form", } }; @@ -48,7 +48,7 @@ export const SearchResultsListNFDI4Health = { api: "https://semanticlookup.zbmed.de/api/", query: "d*", targetLink: "", - parameter: "collection=nfdi4health", + parameter: "collection=nfdi4health&fieldList=description,label,iri,ontology_name,type,short_form", preselected: [{ label: "diabetes" }], useLegacy: true } @@ -66,7 +66,7 @@ export const ErrorSearchResultsList = { export const TibNFDI4CHEM = { args: { api: "https://service.tib.eu/ts4tib/api/", - parameter: "classification=NFDI4CHEM&schema=collection", + parameter: "classification=NFDI4CHEM&schema=collection&fieldList=description,label,iri,ontology_name,type,short_form", query: "assay", targetLink: "", } @@ -75,7 +75,7 @@ export const TibNFDI4CHEM = { export const TibDataPlant = { args: { api: "https://service.tib.eu/ts4tib/api/", - parameter: "classification=DataPLANT&schema=collection", + parameter: "classification=DataPLANT&schema=collection&fieldList=description,label,iri,ontology_name,type,short_form", query: "agriculture", targetLink: "", } @@ -89,4 +89,4 @@ export const SearchResultsListOls4 = { parameter: "", useLegacy: false } -}; \ No newline at end of file +};