Skip to content
Snippets Groups Projects
Commit e7aae58a authored by Duy Minh Vo's avatar Duy Minh Vo
Browse files

fix(dpi): address issue that caused file upload to fail when creating new datasets

Resolves catalog ID appropriately now
parent 69295f41
No related branches found
No related tags found
No related merge requests found
<template>
<div class="position-relative w-100 ">
<FormKit name="mode" validation="required" type="text" class="selectInputField formkit-inner " readonly="readonly"
@click="triggerDropdown()" :placeholder="t('message.dataupload.info.preferredInput')" v-model="inputChoice" :validation-messages="{
......@@ -26,7 +25,7 @@
<input type="text" v-model="context.model" @blur="context.blurHandler" hidden />
<div class="file-div position-relative">
<input class="mt-3" type="file" id="aUrlFL" name="fileUpload" @change="validateFile($event)"
:accept="validExtensions">
:accept="validExtensions" :disabled="isLoading || !catalogId">
<div class="upload-feedback position-absolute d-flex" style="right: 0">
<div v-if="isLoading" class="lds-ring">
</div>
......@@ -58,13 +57,14 @@ import axios from 'axios';
import helper from '../utils/general-helper'
import { getNode } from '@formkit/core'
import { reactive, ref, onMounted, computed } from 'vue';
import { reactive, ref, onMounted, computed, defineComponent } from 'vue';
import { onClickOutside } from '@vueuse/core'
import { useRuntimeEnv } from "../../composables/useRuntimeEnv.ts";
import { FormKit } from '@formkit/vue';
import { FormKit, useFormKitNodeById } from '@formkit/vue';
import { useI18n } from 'vue-i18n';
import { useDpiContext } from '../composables';
export default {
export default defineComponent({
props: {
context: {
type: Object,
......@@ -96,9 +96,6 @@ export default {
...mapGetters('dpiStore', [
'getData',
]),
getCatalogue() {
return getNode('dcat:catalog').value;
}
},
methods: {
...mapActions('dpiStore', [
......@@ -202,7 +199,7 @@ export default {
return await this.uploadFile(file, {
method: 'PUT',
url: `${this.$env.api.fileUploadUrl}data/${fileId}?catalog=${this.getCatalogue}`,
url: `${this.$env.api.fileUploadUrl}data/${fileId}?catalog=${this.catalogId}`,
});
}
......@@ -217,7 +214,8 @@ export default {
const form = new FormData();
form.append('file', file);
const catalog = this.getCatalogue;
const catalog = this.catalogId;
debugger;
const token = this.getUserData.rtpToken;
const resolvedOptions = {
......@@ -287,14 +285,26 @@ export default {
drop.active = !drop.active
}
const dpiContext = useDpiContext();
const catalogIdFromFormkit = useFormKitNodeById('catalog')
const catalogId = computed(() =>
// Extract from catalog input field
catalogIdFromFormkit?.value.value
// Try to recover if catalog is empty for some reason
|| dpiContext.value.edit?.catalog
);
return {
drop,
onClickOutside,
triggerDropdown,
t
t,
catalogId,
};
}
};
},
});
</script>
<style lang="scss" scoped>
......
......@@ -6,7 +6,7 @@
<div v-if="isReady">
<!-- Hidden input that contains the actual catalog id. We rely on that to pass the catalog id to backend later -->
<FormKit v-show="false" v-model="selectedCatalogId" :name="`${props.context.node.name}`" type="text" />
<FormKit v-show="false" v-model="selectedCatalogId" :name="`${props.context.node.name}`" :id="`${props.context.node.id || props.context.node.name}`" type="text" />
<!-- User-facing input that displays the name of the selected catalog -->
<FormKit
......
......@@ -1097,8 +1097,10 @@ const dcatapProperties: InputDefinition = {
catalog: {
identifier: 'catalog',
$formkit: 'simpleSelect',
name: 'dcat:catalog',
id: 'dcat:catalog',
// Intentionally not setting something like dcat:catalog here
// Because we don't neeed catalog to be part of the payload
name: 'catalog',
id: 'catalog',
placeholder: 'Catalog',
classes: { outer: 'formkitProperty formkitCmpWrap mx-0 my-3 p-3' }
},
......
......@@ -1347,6 +1347,7 @@ const dcatapProperties: InputDefinition = {
// Intentionally not setting something like dcat:catalog here
// Because we don't neeed catalog to be part of the payload
name: 'catalog',
id: 'catalog',
class: 'property mandatory',
options: {},
classes: { outer: 'formkitProperty formkitCmpWrap mx-0 my-3 p-3' }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment