-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add flexible order of metadata items
- Loading branch information
orlinmalkja
committed
Jan 15, 2025
1 parent
dea5ea6
commit f4ea7b9
Showing
10 changed files
with
308 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"editor.formatOnSave": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"semi": false, | ||
"singleQuote": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,68 @@ | ||
<template> | ||
<div | ||
v-if="manifestHasItems" | ||
class="manifest-metadata t-mb-7" | ||
> | ||
<div v-if="manifestHasItems" class="manifest-metadata t-mb-7"> | ||
<h3 class="t-text-xl t-font-semibold t-mb-2"> | ||
{{ $t(labels.manifest) }} {{ number }} / {{ total }} | ||
</h3> | ||
<div | ||
v-for="(meta, idx) in metadata" | ||
:key="idx" | ||
class="t-mb-4" | ||
> | ||
<div v-for="(meta, idx) in metadata" :key="idx" class="t-mb-4"> | ||
<MetadataItem :item="meta" /> | ||
</div> | ||
<Actor :data="actor" /> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { computed } from 'vue'; | ||
import { useConfigStore } from '@/stores/config'; | ||
import { useContentsStore } from '@/stores/contents'; | ||
import MetadataItem from '@/components/metadata/MetadataItem.vue'; | ||
import Actor from '@/components/metadata/Actor.vue'; | ||
const configStore = useConfigStore(); | ||
const contentStore = useContentsStore(); | ||
const manifest = computed<Manifest>(() => contentStore.manifest); | ||
const manifests = computed<Manifest[]>(() => contentStore.manifests); | ||
const manifestHasItems = computed<boolean>(() => manifest.value?.sequence.length > 0); | ||
const number = computed<number>(() => (manifests.value !== null ? manifests.value.findIndex(({ id }) => id === manifest.value.id) + 1 : 1)); | ||
const total = computed<number>(() => (manifests.value !== null ? manifests.value.length : 1)); | ||
const labels = computed<Labels>(() => configStore.config.labels); | ||
import { computed } from 'vue' | ||
import { useConfigStore } from '@/stores/config' | ||
import { useContentsStore } from '@/stores/contents' | ||
import { orderMetadataItems } from '@/utils/metadata' | ||
import { getMetadataView } from '@/utils/metadata' | ||
import MetadataItem from '@/components/metadata/MetadataItem.vue' | ||
import Actor from '@/components/metadata/Actor.vue' | ||
const configStore = useConfigStore() | ||
const contentStore = useContentsStore() | ||
const manifest = computed<Manifest>(() => contentStore.manifest) | ||
const manifests = computed<Manifest[]>(() => contentStore.manifests) | ||
const manifestHasItems = computed<boolean>( | ||
() => manifest.value?.sequence.length > 0 | ||
) | ||
const number = computed<number>(() => | ||
manifests.value !== null | ||
? manifests.value.findIndex(({ id }) => id === manifest.value.id) + 1 | ||
: 1 | ||
) | ||
const total = computed<number>(() => | ||
manifests.value !== null ? manifests.value.length : 1 | ||
) | ||
const labels = computed<Labels>(() => configStore.config.labels) | ||
const metadata = computed(() => { | ||
if (!manifest.value) return []; | ||
return [ | ||
{ key: 'label', value: manifest.value.label }, | ||
if (!manifest.value) return [] | ||
let manifestOrderMetadata = getMetadataView(useConfigStore().config.panels) | ||
.connector.options.orderManifestMetadata | ||
let defaultMetadata = [ | ||
{ key: 'Label', value: manifest.value.label }, | ||
...(manifest.value.license || []).map((license) => ({ | ||
key: 'License', | ||
value: license.id, | ||
})), | ||
...(manifest.value.metadata || []), | ||
]; | ||
}); | ||
const actor = computed<Actor[] | undefined>(() => manifest.value?.actor); | ||
...(manifest.value.metadata || []).map((metaItem) => ({ | ||
key: metaItem.key, | ||
value: metaItem.value, | ||
})), | ||
] | ||
let orderedMetadata = [] | ||
if (manifestOrderMetadata?.length > 0) { | ||
orderedMetadata = orderMetadataItems(manifestOrderMetadata, defaultMetadata) | ||
return orderedMetadata | ||
} | ||
return defaultMetadata | ||
}) | ||
const actor = computed<Actor[] | undefined>(() => manifest.value?.actor) | ||
</script> |
Oops, something went wrong.