Skip to content
Snippets Groups Projects
Commit fd6a251f authored by Paul Pestov's avatar Paul Pestov
Browse files

Merge branch 'omalkja/convert-CollectionMetadata-Typescript' into 'develop'

refactor: Convert 'metadata/CollectionMetadata' component to Typescript

See merge request !303
parents 0105b37b 9ee9d119
No related branches found
No related tags found
1 merge request!303refactor: Convert 'metadata/CollectionMetadata' component to Typescript
Pipeline #467407 passed
......@@ -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>
......
......@@ -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
......@@ -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');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment