From 3843e60d8d76bfb1ec62cc992e4cb8c2dab652c7 Mon Sep 17 00:00:00 2001 From: TomDijkema Date: Fri, 25 Oct 2024 16:56:21 +0200 Subject: [PATCH 1/3] Implement nomenclatural HTML label in Digital Specimen ID Carf Implement nomenclatural HTML label in Digital Specimen ID Carf --- .../idCard/DigitalSpecimenIdCardConfig.ts | 4 --- .../components/idCard/IdCard.tsx | 25 +++++++++++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/app/config/idCard/DigitalSpecimenIdCardConfig.ts b/src/app/config/idCard/DigitalSpecimenIdCardConfig.ts index f7d5530d..b82e8fc1 100644 --- a/src/app/config/idCard/DigitalSpecimenIdCardConfig.ts +++ b/src/app/config/idCard/DigitalSpecimenIdCardConfig.ts @@ -11,10 +11,6 @@ const DigitalSpecimenIdCardConfig = ({ digitalSpecimen }: { digitalSpecimen: Dig link?: string }[] => { return [ - { - label: 'Specimen name', - jsonPath: "$['ods:specimenName']" - }, { label: `Physical specimen ID (${digitalSpecimen["ods:physicalSpecimenIDType"]})`, jsonPath: "$['ods:normalisedPhysicalSpecimenID']", diff --git a/src/components/digitalSpecimen/components/idCard/IdCard.tsx b/src/components/digitalSpecimen/components/idCard/IdCard.tsx index d1cad473..f5fe4c58 100644 --- a/src/components/digitalSpecimen/components/idCard/IdCard.tsx +++ b/src/components/digitalSpecimen/components/idCard/IdCard.tsx @@ -12,6 +12,7 @@ import { useTrigger } from 'app/Hooks'; /* Import Types */ import { DigitalMedia } from 'app/types/DigitalMedia'; import { DigitalSpecimen } from 'app/types/DigitalSpecimen'; +import { Identification } from 'app/types/Identification'; /* Props Type */ @@ -61,6 +62,20 @@ const IdCard = (props: Props) => { }; }, []); + /** + * Function to get the HTML label of the first accepted identification within the specimen, if not present, provide generic specimen name + * @returns HTML label or specimen name string + */ + const GetSpecimenNameHTMLLabel = () => { + const acceptedIdentification: Identification | undefined = digitalSpecimen['ods:hasIdentification']?.find(identification => identification['ods:isVerifiedIdentification']); + + if (acceptedIdentification) { + return acceptedIdentification['ods:hasTaxonIdentification']?.[0]['ods:scientificNameHtmlLabel'] ?? digitalSpecimen['ods:specimenName'] ?? ''; + } else { + return digitalSpecimen['ods:specimenName'] ?? ''; + } + }; + return (
{/* First digital media image of digital specimen, if present */} @@ -78,6 +93,16 @@ const IdCard = (props: Props) => {
+ {/* Nomenclatural name (HTML label) */} + + +

Specimen Name

+

+ + + {/* ID card properties */} {DigitalSpecimenIdCardConfig({ digitalSpecimen }).map(idCardField => { return ( From 48fd80ac364569aac65d64b6c6a1936a06c7da2f Mon Sep 17 00:00:00 2001 From: TomDijkema Date: Mon, 28 Oct 2024 10:01:15 +0100 Subject: [PATCH 2/3] Fix hasMedia filter issue Fix hasMedia filter issue --- src/app/Hooks.ts | 2 +- .../components/searchFiltersMenu/SearchFiltersMenu.tsx | 2 +- .../components/searchFiltersMenu/components/BlockFilter.tsx | 6 +++--- .../searchFiltersMenu/components/BooleanFilter.tsx | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/app/Hooks.ts b/src/app/Hooks.ts index f7819fac..1c832e10 100644 --- a/src/app/Hooks.ts +++ b/src/app/Hooks.ts @@ -415,7 +415,7 @@ const useSearchFilters = () => { * Function to set the search filters based upon a search filters object * @param searchFilters An object containing search filter names as keys and values */ - const SetSearchFilters = (searchFilters: { [name: string]: string | string[] | boolean }) => { + const SetSearchFilters = (searchFilters: { [name: string]: string | string[] | boolean }) => { Object.entries(searchFilters).forEach(([name, searchFilter]) => { /* Remove all params from this name */ searchParams.delete(name); diff --git a/src/components/search/components/searchFiltersMenu/SearchFiltersMenu.tsx b/src/components/search/components/searchFiltersMenu/SearchFiltersMenu.tsx index f6349ae4..cf59bfc6 100644 --- a/src/components/search/components/searchFiltersMenu/SearchFiltersMenu.tsx +++ b/src/components/search/components/searchFiltersMenu/SearchFiltersMenu.tsx @@ -92,7 +92,7 @@ const SearchFiltersMenu = () => { /* Add to inital form search query if allowed for this filter */ if (searchFilter.searchable) { initialFormValues.search[key] = ''; - }; + } }); return ( diff --git a/src/components/search/components/searchFiltersMenu/components/BlockFilter.tsx b/src/components/search/components/searchFiltersMenu/components/BlockFilter.tsx index 437377f5..492beb1d 100644 --- a/src/components/search/components/searchFiltersMenu/components/BlockFilter.tsx +++ b/src/components/search/components/searchFiltersMenu/components/BlockFilter.tsx @@ -36,7 +36,7 @@ const BlockFilter = (props: Props) => { Object.keys(aggregations).forEach(key => { blockFilterItems.push(key); }) - }; + } /* Construct from selected values by replacing the aggregation ones */ fieldValues.forEach(fieldValue => { @@ -44,7 +44,7 @@ const BlockFilter = (props: Props) => { if (index >= 0) { blockFilterItems.splice(index, 1, fieldValue); - }; + } }); /** @@ -61,7 +61,7 @@ const BlockFilter = (props: Props) => { Remove(index); } else { Push(blockFilterItem); - }; + } SubmitForm(); }; diff --git a/src/components/search/components/searchFiltersMenu/components/BooleanFilter.tsx b/src/components/search/components/searchFiltersMenu/components/BooleanFilter.tsx index 38021c10..33054275 100644 --- a/src/components/search/components/searchFiltersMenu/components/BooleanFilter.tsx +++ b/src/components/search/components/searchFiltersMenu/components/BooleanFilter.tsx @@ -44,7 +44,7 @@ const BooleanFilter = (props: Props) => { className={`${BooleanFilterClass('true')} w-100 py-1 b-primary br-corner`} OnClick={() => { /* Set the field value to true */ - SetFieldValue?.(namePrefix ? `${namePrefix}.` : '' + `${name}[0]`, fieldValues[0] !== 'true' ? 'true' : undefined); + SetFieldValue?.((namePrefix ? `${namePrefix}.` : '') + `${name}[0]`, fieldValues[0] !== 'true' ? 'true' : undefined); /* Submit form */ SubmitForm(); @@ -59,7 +59,7 @@ const BooleanFilter = (props: Props) => { className={`${BooleanFilterClass('false')} w-100 b-primary py-1 br-corner`} OnClick={() => { /* Set the field value to false */ - SetFieldValue?.(namePrefix ? `${namePrefix}.` : '' + `${name}[0]`, fieldValues[0] !== 'false' ? 'false' : undefined); + SetFieldValue?.((namePrefix ? `${namePrefix}.` : '') + `${name}[0]`, fieldValues[0] !== 'false' ? 'false' : undefined); /* Submit form */ SubmitForm(); From 49aaa05c0304f63f0ca17470c3f4f6108054244b Mon Sep 17 00:00:00 2001 From: TomDijkema Date: Wed, 30 Oct 2024 13:43:35 +0100 Subject: [PATCH 3/3] Build fix --- src/app/Types.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/app/Types.ts b/src/app/Types.ts index bfcba6c0..7d024117 100644 --- a/src/app/Types.ts +++ b/src/app/Types.ts @@ -91,9 +91,6 @@ export type PaginationObject = { /* Super class (annotation target) */ export type SuperClass = DigitalSpecimen | DigitalMedia | Dict; -/* Super class (annotation target) */ -export type SuperClass = DigitalSpecimen | DigitalMedia | Dict; - /* Annotation target */ export type AnnotationTarget = { type: 'superClass' | 'class' | 'term',