2022-07-30 19:56:44 +00:00
|
|
|
<script setup lang="ts">
|
2022-08-31 17:33:52 +00:00
|
|
|
import type { Upload, Tag, Track } from '~/types'
|
2022-07-30 19:56:44 +00:00
|
|
|
|
2022-08-31 16:39:24 +00:00
|
|
|
import { reactive, computed, watch } from 'vue'
|
2022-07-30 19:56:44 +00:00
|
|
|
|
|
|
|
import TagsSelector from '~/components/library/TagsSelector.vue'
|
|
|
|
import AttachmentInput from '~/components/common/AttachmentInput.vue'
|
|
|
|
|
2022-08-31 17:33:52 +00:00
|
|
|
type Values = Pick<Track, 'title' | 'description' | 'position' | 'tags'> & { cover: string }
|
2022-08-30 20:23:17 +00:00
|
|
|
interface Events {
|
2022-08-31 16:39:24 +00:00
|
|
|
(e: 'update:values', values: Values): void
|
2022-07-30 19:56:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
upload: Upload
|
2022-08-31 17:33:52 +00:00
|
|
|
values: Values | null
|
2022-07-30 19:56:44 +00:00
|
|
|
}
|
|
|
|
|
2022-08-30 20:23:17 +00:00
|
|
|
const emit = defineEmits<Events>()
|
2022-07-30 19:56:44 +00:00
|
|
|
const props = withDefaults(defineProps<Props>(), {
|
|
|
|
values: null
|
|
|
|
})
|
|
|
|
|
2022-08-31 17:33:52 +00:00
|
|
|
const newValues = reactive<Omit<Values, 'tags'> & { tags: Tag[] }>({
|
|
|
|
...(props.values ?? props.upload.import_metadata ?? {}) as Values,
|
|
|
|
tags: ((props.values ?? props.upload.import_metadata)?.tags?.map(name => ({ name })) ?? []) as Tag[]
|
2022-08-31 16:39:24 +00:00
|
|
|
})
|
2022-07-30 19:56:44 +00:00
|
|
|
|
|
|
|
const isLoading = computed(() => !props.upload)
|
2022-08-31 17:33:52 +00:00
|
|
|
watch(newValues, (values) => emit('update:values', {
|
|
|
|
...values,
|
|
|
|
tags: values.tags?.map(({ name }) => name)
|
|
|
|
}), { immediate: true })
|
2022-07-30 19:56:44 +00:00
|
|
|
</script>
|
|
|
|
|
2020-02-23 14:31:03 +00:00
|
|
|
<template>
|
|
|
|
<div :class="['ui', {loading: isLoading}, 'form']">
|
|
|
|
<div class="ui required field">
|
|
|
|
<label for="upload-title">
|
|
|
|
<translate translate-context="*/*/*/Noun">Title</translate>
|
|
|
|
</label>
|
2021-12-06 10:35:20 +00:00
|
|
|
<input
|
|
|
|
v-model="newValues.title"
|
|
|
|
type="text"
|
|
|
|
>
|
2020-02-23 14:31:03 +00:00
|
|
|
</div>
|
|
|
|
<attachment-input
|
|
|
|
v-model="newValues.cover"
|
2022-08-31 16:39:24 +00:00
|
|
|
@delete="newValues.cover = ''"
|
2021-12-06 10:35:20 +00:00
|
|
|
>
|
2022-05-01 14:15:57 +00:00
|
|
|
<translate translate-context="Content/Channel/*">
|
2021-12-06 10:35:20 +00:00
|
|
|
Track Picture
|
|
|
|
</translate>
|
2020-02-23 14:31:03 +00:00
|
|
|
</attachment-input>
|
2021-12-06 10:35:20 +00:00
|
|
|
<div class="ui small hidden divider" />
|
2020-02-23 14:31:03 +00:00
|
|
|
<div class="ui two fields">
|
|
|
|
<div class="ui field">
|
|
|
|
<label for="upload-tags">
|
|
|
|
<translate translate-context="*/*/*/Noun">Tags</translate>
|
|
|
|
</label>
|
|
|
|
<tags-selector
|
|
|
|
id="upload-tags"
|
2021-12-06 10:35:20 +00:00
|
|
|
v-model="newValues.tags"
|
|
|
|
:required="false"
|
|
|
|
/>
|
2020-02-23 14:31:03 +00:00
|
|
|
</div>
|
|
|
|
<div class="ui field">
|
|
|
|
<label for="upload-position">
|
|
|
|
<translate translate-context="*/*/*/Short, Noun">Position</translate>
|
|
|
|
</label>
|
2021-12-06 10:35:20 +00:00
|
|
|
<input
|
|
|
|
v-model="newValues.position"
|
|
|
|
type="number"
|
|
|
|
min="1"
|
|
|
|
step="1"
|
|
|
|
>
|
2020-02-23 14:31:03 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="ui field">
|
|
|
|
<label for="upload-description">
|
|
|
|
<translate translate-context="*/*/*">Description</translate>
|
|
|
|
</label>
|
2021-12-06 10:35:20 +00:00
|
|
|
<content-form
|
|
|
|
v-model="newValues.description"
|
|
|
|
field-id="upload-description"
|
|
|
|
/>
|
2020-02-23 14:31:03 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|