fix(front): channel upload edit form
This commit is contained in:
parent
3996747802
commit
f407527b6c
|
@ -1,12 +1,14 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Upload, Track } from '~/types'
|
import type { Upload, Track } from '~/types'
|
||||||
|
|
||||||
import { reactive, computed, watch } from 'vue'
|
import { reactive, computed, watch, ref } from 'vue'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
|
|
||||||
import TagsSelector from '~/components/library/TagsSelector.vue'
|
|
||||||
import AttachmentInput from '~/components/common/AttachmentInput.vue'
|
import AttachmentInput from '~/components/common/AttachmentInput.vue'
|
||||||
|
|
||||||
|
import Input from '~/components/ui/Input.vue'
|
||||||
|
import Pills from '~/components/ui/Pills.vue'
|
||||||
|
|
||||||
type Values = Pick<Track, 'title' | 'position' | 'tags'> & { cover: string | null, description: string }
|
type Values = Pick<Track, 'title' | 'position' | 'tags'> & { cover: string | null, description: string }
|
||||||
interface Events {
|
interface Events {
|
||||||
(e: 'update:values', values: Values): void
|
(e: 'update:values', values: Values): void
|
||||||
|
@ -24,12 +26,25 @@ const props = withDefaults(defineProps<Props>(), {
|
||||||
values: null
|
values: null
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// TODO: Make Tags work
|
||||||
|
|
||||||
|
type Item = { type: 'custom' | 'preset', label: string }
|
||||||
|
type tagsModel = {
|
||||||
|
currents: Item[],
|
||||||
|
others?: Item[],
|
||||||
|
}
|
||||||
|
|
||||||
|
const tags = ref({
|
||||||
|
currents: [],
|
||||||
|
others: []
|
||||||
|
} satisfies tagsModel)
|
||||||
|
|
||||||
// TODO: check if `position: 0` is a good default
|
// TODO: check if `position: 0` is a good default
|
||||||
const newValues = reactive<Values>({
|
const newValues = reactive<Values>({
|
||||||
position: 0,
|
position: 0,
|
||||||
description: '',
|
description: '',
|
||||||
title: '',
|
title: '',
|
||||||
tags: [],
|
tags: tags.value.currents.map(tag => tag.label),
|
||||||
cover: null,
|
cover: null,
|
||||||
...(props.values ?? props.upload.import_metadata ?? {})
|
...(props.values ?? props.upload.import_metadata ?? {})
|
||||||
})
|
})
|
||||||
|
@ -39,54 +54,45 @@ watch(newValues, (values) => emit('update:values', values), { immediate: true })
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div :class="['ui', {loading: isLoading}, 'form']">
|
<Layout
|
||||||
<div class="ui required field">
|
form
|
||||||
<label for="upload-title">
|
:class="[{loading: isLoading}]"
|
||||||
{{ t('components.channels.UploadMetadataForm.label.title') }}
|
>
|
||||||
</label>
|
<Input
|
||||||
<input
|
v-model="newValues.title"
|
||||||
v-model="newValues.title"
|
:label="t('components.channels.UploadMetadataForm.label.title')"
|
||||||
type="text"
|
required
|
||||||
>
|
/>
|
||||||
</div>
|
|
||||||
<attachment-input
|
<attachment-input
|
||||||
v-model="newValues.cover"
|
v-model="newValues.cover"
|
||||||
@delete="newValues.cover = ''"
|
@delete="newValues.cover = ''"
|
||||||
>
|
>
|
||||||
{{ t('components.channels.UploadMetadataForm.label.image') }}
|
{{ t('components.channels.UploadMetadataForm.label.image') }}
|
||||||
</attachment-input>
|
</attachment-input>
|
||||||
<div class="ui small hidden divider" />
|
<label for="upload-tags">
|
||||||
<div class="ui two fields">
|
{{ t('components.channels.UploadMetadataForm.label.tags') }}
|
||||||
<div class="ui field">
|
</label>
|
||||||
<label for="upload-tags">
|
<!-- TODO: Make Tags work -->
|
||||||
{{ t('components.channels.UploadMetadataForm.label.tags') }}
|
<Pills
|
||||||
</label>
|
:get="(v) => { tags = v }"
|
||||||
<tags-selector
|
:set="() => tags"
|
||||||
id="upload-tags"
|
label="Custom Tags"
|
||||||
v-model="newValues.tags"
|
cancel="Cancel"
|
||||||
:required="false"
|
/>
|
||||||
/>
|
<Spacer />
|
||||||
</div>
|
<Input
|
||||||
<div class="ui field">
|
v-model="newValues.position"
|
||||||
<label for="upload-position">
|
type="number"
|
||||||
{{ t('components.channels.UploadMetadataForm.label.position') }}
|
min="1"
|
||||||
</label>
|
step="1"
|
||||||
<input
|
:label="t('components.channels.UploadMetadataForm.label.position')"
|
||||||
v-model="newValues.position"
|
/>
|
||||||
type="number"
|
<label for="upload-description">
|
||||||
min="1"
|
{{ t('components.channels.UploadMetadataForm.label.description') }}
|
||||||
step="1"
|
</label>
|
||||||
>
|
<content-form
|
||||||
</div>
|
v-model="newValues.description"
|
||||||
</div>
|
field-id="upload-description"
|
||||||
<div class="ui field">
|
/>
|
||||||
<label for="upload-description">
|
</Layout>
|
||||||
{{ t('components.channels.UploadMetadataForm.label.description') }}
|
|
||||||
</label>
|
|
||||||
<content-form
|
|
||||||
v-model="newValues.description"
|
|
||||||
field-id="upload-description"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -303,6 +303,7 @@ const resetField = (fieldId: string) => {
|
||||||
</attachment-input>
|
</attachment-input>
|
||||||
</template>
|
</template>
|
||||||
<template v-else-if="fieldConfig.type === 'tags'">
|
<template v-else-if="fieldConfig.type === 'tags'">
|
||||||
|
<!-- TODO: Make Tags work -->
|
||||||
<Pills
|
<Pills
|
||||||
:id="fieldConfig.id"
|
:id="fieldConfig.id"
|
||||||
ref="tags"
|
ref="tags"
|
||||||
|
|
|
@ -202,7 +202,7 @@ watch(showDeleteModal, (newValue) => {
|
||||||
<div class="meta">
|
<div class="meta">
|
||||||
<span>{{ t('components.library.TrackBase.title') }}</span>
|
<span>{{ t('components.library.TrackBase.title') }}</span>
|
||||||
<i class="bi bi-dot" />
|
<i class="bi bi-dot" />
|
||||||
<span>{{ track.album.title }}</span>
|
<span>{{ track.album?.title }}</span>
|
||||||
<i
|
<i
|
||||||
v-if="totalDuration > 0"
|
v-if="totalDuration > 0"
|
||||||
class="bi bi-dot"
|
class="bi bi-dot"
|
||||||
|
|
Loading…
Reference in New Issue