diff --git a/src/components/metadata/CollectionMetadata.vue b/src/components/metadata/CollectionMetadata.vue index 3ff2aa5f5d39cb0fd3122a2d3a31d5bec47f2966..ed80e84e0895bd02d66217979f8a7537d83591a5 100644 --- a/src/components/metadata/CollectionMetadata.vue +++ b/src/components/metadata/CollectionMetadata.vue @@ -7,15 +7,23 @@ </div> </template> -<script setup> +<script setup lang="ts"> import { computed } from 'vue'; import { useStore } from 'vuex'; import MetadataItem from '@/components/metadata/MetadataItem.vue'; + +function getCollectorName (collection: Collection) : string | null { + if (!collection) return null; + if(collection.collector.length === 0) return null; + return collection.collector[0].name; +} + const store = useStore(); -const collection = computed(() => store.getters['contents/collection']); +const collection = computed<Collection>(() => store.getters['contents/collection']); + const metadata = computed(() => { if (!collection.value) return []; @@ -24,11 +32,12 @@ const metadata = computed(() => { sub: 'subtitle', }; - const collectorName = collection.value.collector?.name; - const { description } = collection.value; + const collectorName: string | null = getCollectorName(collection.value); + const description: string | undefined = collection.value.description; + const collectionTitle: Title[] = collection.value.title; return [ - ...collection.value.title + ...collectionTitle .filter((collection) => collection) .map((collectionTitle) => ({ key: mappings[collectionTitle.type] || 'title', @@ -36,7 +45,6 @@ const metadata = computed(() => { })), ...(collectorName ? [{ key: 'collector', value: collectorName }] : []), ...(description ? [{ key: 'description', value: description }] : []), - ...(collection.value.metadata || []), ]; }); </script> diff --git a/src/types.d.ts b/src/types.d.ts index 6476b20c2e2574d7be2fce660973f2c1cf22d900..7c60ab2a84457ca32f3a47501ca42c53309f6685 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -22,7 +22,7 @@ declare global { modules?: Module[] } - + interface DataIntegrity { type: string, value: string @@ -109,6 +109,7 @@ declare global { type: TitleType } type TitleType = 'main' | 'sub'; + } -export {} +export {} \ No newline at end of file diff --git a/tests/cypress/e2e/metadata.cy.js b/tests/cypress/e2e/metadata.cy.js index 1bccdef8f3366f339015478f72ca9eee2f654736..def3f93cfcc794841dc14670c9bef19e0f39fecf 100644 --- a/tests/cypress/e2e/metadata.cy.js +++ b/tests/cypress/e2e/metadata.cy.js @@ -42,7 +42,7 @@ describe('Metadata', () => { .get(selectors.metadataView) .find(selectors.collection) .find(selectors.title) - .eq(1) + .eq(2) .should('contain', 'Description') .next() .should('contain', 'Arabic/Karshuni collection for the Ahiqar project. Funded by DFG, 2018–2021, University of Göttingen');