From 66473084eb2265bd488b835d9cc22aa2c540d76f Mon Sep 17 00:00:00 2001 From: wvffle Date: Tue, 27 Dec 2022 13:54:33 +0000 Subject: [PATCH] fix(ui): expose public channel upload form methods This commit also returns a function removed during Vue 3 rewrite. (in 1c395c01b0f30e13e86a81650ea5630026c3b8b7) Part-of: --- front/src/components/channels/UploadForm.vue | 28 ++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/front/src/components/channels/UploadForm.vue b/front/src/components/channels/UploadForm.vue index 3b964f737..4181a5623 100644 --- a/front/src/components/channels/UploadForm.vue +++ b/front/src/components/channels/UploadForm.vue @@ -399,6 +399,34 @@ watchEffect(() => { const labels = computed(() => ({ editTitle: t('components.channels.UploadForm.button.edit') })) + +const isLoading = ref(false) +const publish = async () => { + isLoading.value = true + + errors.value = [] + + try { + await axios.post('uploads/action/', { + action: 'publish', + objects: uploadedFiles.value.map((file) => file.response?.uuid) + }) + + store.commit('channels/publish', { + uploads: uploadedFiles.value.map((file) => ({ ...file.response, import_status: 'pending' })), + channel: selectedChannel.value + }) + } catch (error) { + errors.value = (error as BackendError).backendErrors + } + + isLoading.value = false +} + +defineExpose({ + step, + publish +})