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,47 +54,39 @@ 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
 | 
					 | 
				
			||||||
        v-model="newValues.title"
 | 
					 | 
				
			||||||
        type="text"
 | 
					 | 
				
			||||||
  >
 | 
					  >
 | 
				
			||||||
    </div>
 | 
					    <Input
 | 
				
			||||||
 | 
					      v-model="newValues.title"
 | 
				
			||||||
 | 
					      :label="t('components.channels.UploadMetadataForm.label.title')"
 | 
				
			||||||
 | 
					      required
 | 
				
			||||||
 | 
					    />
 | 
				
			||||||
    <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" />
 | 
					 | 
				
			||||||
    <div class="ui two fields">
 | 
					 | 
				
			||||||
      <div class="ui field">
 | 
					 | 
				
			||||||
    <label for="upload-tags">
 | 
					    <label for="upload-tags">
 | 
				
			||||||
      {{ t('components.channels.UploadMetadataForm.label.tags') }}
 | 
					      {{ t('components.channels.UploadMetadataForm.label.tags') }}
 | 
				
			||||||
    </label>
 | 
					    </label>
 | 
				
			||||||
        <tags-selector
 | 
					    <!-- TODO: Make Tags work -->
 | 
				
			||||||
          id="upload-tags"
 | 
					    <Pills
 | 
				
			||||||
          v-model="newValues.tags"
 | 
					      :get="(v) => { tags = v }"
 | 
				
			||||||
          :required="false"
 | 
					      :set="() => tags"
 | 
				
			||||||
 | 
					      label="Custom Tags"
 | 
				
			||||||
 | 
					      cancel="Cancel"
 | 
				
			||||||
    />
 | 
					    />
 | 
				
			||||||
      </div>
 | 
					    <Spacer />
 | 
				
			||||||
      <div class="ui field">
 | 
					    <Input
 | 
				
			||||||
        <label for="upload-position">
 | 
					 | 
				
			||||||
          {{ t('components.channels.UploadMetadataForm.label.position') }}
 | 
					 | 
				
			||||||
        </label>
 | 
					 | 
				
			||||||
        <input
 | 
					 | 
				
			||||||
      v-model="newValues.position"
 | 
					      v-model="newValues.position"
 | 
				
			||||||
      type="number"
 | 
					      type="number"
 | 
				
			||||||
      min="1"
 | 
					      min="1"
 | 
				
			||||||
      step="1"
 | 
					      step="1"
 | 
				
			||||||
        >
 | 
					      :label="t('components.channels.UploadMetadataForm.label.position')"
 | 
				
			||||||
      </div>
 | 
					    />
 | 
				
			||||||
    </div>
 | 
					 | 
				
			||||||
    <div class="ui field">
 | 
					 | 
				
			||||||
    <label for="upload-description">
 | 
					    <label for="upload-description">
 | 
				
			||||||
      {{ t('components.channels.UploadMetadataForm.label.description') }}
 | 
					      {{ t('components.channels.UploadMetadataForm.label.description') }}
 | 
				
			||||||
    </label>
 | 
					    </label>
 | 
				
			||||||
| 
						 | 
					@ -87,6 +94,5 @@ watch(newValues, (values) => emit('update:values', values), { immediate: true })
 | 
				
			||||||
      v-model="newValues.description"
 | 
					      v-model="newValues.description"
 | 
				
			||||||
      field-id="upload-description"
 | 
					      field-id="upload-description"
 | 
				
			||||||
    />
 | 
					    />
 | 
				
			||||||
    </div>
 | 
					  </Layout>
 | 
				
			||||||
  </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