From af58e94e738cd0f2810ab254f4fcb62e565dc7c1 Mon Sep 17 00:00:00 2001 From: ArneBo Date: Thu, 20 Feb 2025 15:02:40 +0100 Subject: [PATCH] fix(front): make all available fields available for editform (rebased on develop) --- .../composables/moderation/useEditConfigs.ts | 40 ++++++++++++++----- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/front/src/composables/moderation/useEditConfigs.ts b/front/src/composables/moderation/useEditConfigs.ts index 5beee3b57..27385d0d7 100644 --- a/front/src/composables/moderation/useEditConfigs.ts +++ b/front/src/composables/moderation/useEditConfigs.ts @@ -1,4 +1,4 @@ -import type { Album, Track, Actor } from '~/types' +import type { Album, Artist, Content, Track, Actor } from '~/types' import { i18n } from '~/init/locale' @@ -16,14 +16,25 @@ export interface EditableConfigField extends ConfigField { id: EditObjectType } -export type EditObject = (Partial | Partial) & { attributed_to: Actor } -export type EditObjectType = 'album' | 'track' +export type EditObject = (Partial | Partial | Partial) & { attributed_to: Actor } +export type EditObjectType = 'artist' | 'album' | 'track' type Configs = Record +const getContentValueRepr = (val: Content) => val.text + // TODO: Get params from typescript type somehow? export default (): Configs => { const { t } = i18n.global + const description: ConfigField = { + id: 'description', + type: 'content', + required: true, + label: t('composables.moderation.useEditConfigs.description.label'), + getValue: (obj) => obj.description ?? { text: '', content_type: 'text/markdown' }, + getValueRepr: getContentValueRepr + } + const cover: ConfigField = { id: 'cover', type: 'attachment', @@ -37,15 +48,25 @@ export default (): Configs => { type: 'tags', required: true, label: t('composables.moderation.useEditConfigs.tags.label'), - getValue: (obj) => ({ - current: obj.tags || [], - others: [], - custom: [], - }), + getValue: (obj) => { return obj.tags }, getValueRepr: (tags: string[]) => tags.slice().sort().join('\n') } return { + artist: { + fields: [ + { + id: 'name', + type: 'text', + required: true, + label: t('composables.moderation.useEditConfigs.artist.name'), + getValue: (artist) => (artist as Artist).name + }, + description, + cover, + tags + ] + }, album: { fields: [ { @@ -55,9 +76,9 @@ export default (): Configs => { label: t('composables.moderation.useEditConfigs.album.title'), getValue: (album) => (album as Album).title }, + description, { id: 'release_date', - // TODO: Change type to date and offer date select input in form type: 'text', required: false, label: t('composables.moderation.useEditConfigs.album.releaseDate'), @@ -76,6 +97,7 @@ export default (): Configs => { label: t('composables.moderation.useEditConfigs.track.title'), getValue: (track) => (track as Track).title }, + description, cover, { id: 'position',