fix(upload): use the selected channel for the file upload in channel upload form
This commit is contained in:
parent
e9ea8d6299
commit
681f3fced0
|
@ -66,7 +66,11 @@ const store = useStore()
|
||||||
|
|
||||||
const errors = ref([] as string[])
|
const errors = ref([] as string[])
|
||||||
|
|
||||||
const values = reactive({
|
const values = reactive<{
|
||||||
|
channel: string; // Channel UUID
|
||||||
|
license: unknown;
|
||||||
|
album: unknown;
|
||||||
|
}>({
|
||||||
channel: props.channel?.uuid ?? null,
|
channel: props.channel?.uuid ?? null,
|
||||||
license: null,
|
license: null,
|
||||||
album: null
|
album: null
|
||||||
|
@ -108,9 +112,9 @@ const isLoading = ref(false)
|
||||||
const selectedChannel = computed(() =>
|
const selectedChannel = computed(() =>
|
||||||
props.channel
|
props.channel
|
||||||
? props.channel
|
? props.channel
|
||||||
: availableChannels.value.count === 0
|
: availableChannels.value.length === 0
|
||||||
? (createEmptyChannel(), null)
|
? (createEmptyChannel(), null)
|
||||||
: availableChannels.value.count === 1
|
: availableChannels.value.length === 1
|
||||||
? availableChannels.value[0]
|
? availableChannels.value[0]
|
||||||
: availableChannels.value.find(({ artist }) => artist.id === channelDropdownId.value)
|
: availableChannels.value.find(({ artist }) => artist.id === channelDropdownId.value)
|
||||||
)
|
)
|
||||||
|
@ -224,12 +228,6 @@ const beforeFileUpload = (newFile: VueUploadItem) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const baseImportMetadata = computed(() => ({
|
|
||||||
channel: values.channel,
|
|
||||||
import_status: 'draft',
|
|
||||||
import_metadata: { license: values.license, album: values.album }
|
|
||||||
}))
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Uploaded files
|
// Uploaded files
|
||||||
//
|
//
|
||||||
|
@ -561,7 +559,7 @@ ChannelCreateRequest: {
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<album-select
|
<album-select
|
||||||
v-if="selectedChannel && albumSelection"
|
v-if="selectedChannel && albumSelection && albumSelection.albums.length > 0"
|
||||||
v-model="albumSelection"
|
v-model="albumSelection"
|
||||||
:class="['ui', 'field']"
|
:class="['ui', 'field']"
|
||||||
/>
|
/>
|
||||||
|
@ -697,11 +695,12 @@ ChannelCreateRequest: {
|
||||||
{{ t('components.channels.UploadForm.description.extensions', {extensions: store.state.ui.supportedExtensions.join(', ')}) }}
|
{{ t('components.channels.UploadForm.description.extensions', {extensions: store.state.ui.supportedExtensions.join(', ')}) }}
|
||||||
</Layout>
|
</Layout>
|
||||||
</Alert>
|
</Alert>
|
||||||
<file-upload-widget
|
<FileUploadWidget
|
||||||
|
v-if="selectedChannel && selectedChannel.uuid"
|
||||||
ref="upload"
|
ref="upload"
|
||||||
v-model="files"
|
v-model="files"
|
||||||
:class="['ui', 'button', 'channels']"
|
:class="['ui', 'button', 'channels']"
|
||||||
:data="baseImportMetadata"
|
:channel="selectedChannel.uuid"
|
||||||
@input-file="beforeFileUpload"
|
@input-file="beforeFileUpload"
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
|
@ -719,6 +718,6 @@ ChannelCreateRequest: {
|
||||||
class="divider"
|
class="divider"
|
||||||
:size="32"
|
:size="32"
|
||||||
/>
|
/>
|
||||||
</file-upload-widget>
|
</FileUploadWidget>
|
||||||
</Layout>
|
</Layout>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,12 +1,18 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { VueUploadItem } from 'vue-upload-component'
|
import type { VueUploadItem } from 'vue-upload-component'
|
||||||
|
|
||||||
|
import type { components } from '~/generated/types'
|
||||||
|
|
||||||
import { useCookies } from '@vueuse/integrations/useCookies'
|
import { useCookies } from '@vueuse/integrations/useCookies'
|
||||||
import { computed, ref, watch, getCurrentInstance } from 'vue'
|
import { computed, ref, watch, getCurrentInstance } from 'vue'
|
||||||
import { useStore } from '~/store'
|
import { useStore } from '~/store'
|
||||||
|
|
||||||
import FileUpload from 'vue-upload-component'
|
import FileUpload from 'vue-upload-component'
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
channel: components['schemas']['Channel']['uuid'];
|
||||||
|
}>()
|
||||||
|
|
||||||
const { get } = useCookies()
|
const { get } = useCookies()
|
||||||
const instance = getCurrentInstance()
|
const instance = getCurrentInstance()
|
||||||
const attrs = instance?.attrs ?? {}
|
const attrs = instance?.attrs ?? {}
|
||||||
|
@ -36,13 +42,15 @@ const patchFileData = (file: VueUploadItem, data: Record<string, unknown> = {})
|
||||||
|
|
||||||
if (metadata) {
|
if (metadata) {
|
||||||
metadata = { ...metadata }
|
metadata = { ...metadata }
|
||||||
if (data.channel && !metadata.title) {
|
if (!('title' in metadata)) {
|
||||||
metadata.title = filename.replace(/\.[^/.]+$/, '')
|
metadata.title = filename.replace(/\.[^/.]+$/, '')
|
||||||
}
|
}
|
||||||
|
|
||||||
data.import_metadata = JSON.stringify(metadata)
|
data.import_metadata = JSON.stringify(metadata)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data.channel = props.channel
|
||||||
|
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue