funkwhale/front/src/components/channels/UploadMetadataForm.vue

90 wiersze
2.3 KiB
Vue
Czysty Zwykły widok Historia

2022-07-30 19:56:44 +00:00
<script setup lang="ts">
2022-07-31 23:42:59 +00:00
import type { Upload } from '~/types'
2022-07-30 19:56:44 +00:00
import { ref, computed, watch } from 'vue'
import TagsSelector from '~/components/library/TagsSelector.vue'
import AttachmentInput from '~/components/common/AttachmentInput.vue'
interface Emits {
// TODO (wvffle): Find correct type
2022-07-31 23:42:59 +00:00
(e: 'values', values: Record<string, string>): void
2022-07-30 19:56:44 +00:00
}
interface Props {
upload: Upload
2022-07-31 23:42:59 +00:00
values?: Record<string, string> | null
2022-07-30 19:56:44 +00:00
}
const emit = defineEmits<Emits>()
const props = withDefaults(defineProps<Props>(), {
values: null
})
// TODO (wvffle): This is something like a Track, but `cover` is a plain uuid
const newValues = ref({ ...(props.values ?? props.upload.import_metadata) } as any)
// computed: {
// isLoading () {
// return !!this.metadata
// }
// },
const isLoading = computed(() => !props.upload)
watch(newValues, (values) => emit('values', values), { immediate: true })
</script>
<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"
>
</div>
<attachment-input
v-model="newValues.cover"
2021-12-06 10:35:20 +00:00
@delete="newValues.cover = null"
>
2022-05-01 14:15:57 +00:00
<translate translate-context="Content/Channel/*">
2021-12-06 10:35:20 +00:00
Track Picture
</translate>
</attachment-input>
2021-12-06 10:35:20 +00:00
<div class="ui small hidden divider" />
<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"
/>
</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"
>
</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"
/>
</div>
</div>
</template>