diff --git a/packages/piveau-hub-ui-modules/lib/data-provider-interface/components/FileUpload.vue b/packages/piveau-hub-ui-modules/lib/data-provider-interface/components/FileUpload.vue index 8066db55e513d9f9415f322c73667f6359e39dfc..551496fc2730c2fb2de857ccdd2c16d7939807bb 100644 --- a/packages/piveau-hub-ui-modules/lib/data-provider-interface/components/FileUpload.vue +++ b/packages/piveau-hub-ui-modules/lib/data-provider-interface/components/FileUpload.vue @@ -1,5 +1,4 @@ <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> diff --git a/packages/piveau-hub-ui-modules/lib/data-provider-interface/components/SimpleSelect.vue b/packages/piveau-hub-ui-modules/lib/data-provider-interface/components/SimpleSelect.vue index b6e2f18b08a2af04a196b321942b621a82bb72da..4326817720744543a3c31c79d391126652697bff 100644 --- a/packages/piveau-hub-ui-modules/lib/data-provider-interface/components/SimpleSelect.vue +++ b/packages/piveau-hub-ui-modules/lib/data-provider-interface/components/SimpleSelect.vue @@ -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 diff --git a/packages/piveau-hub-ui-modules/lib/data-provider-interface/config/dcatap/input-definition.ts b/packages/piveau-hub-ui-modules/lib/data-provider-interface/config/dcatap/input-definition.ts index 189a004232432f368bac942dac43bbb30d75fea3..6b1be95cf0eabf566bf4eb74d4e39923a7e4d59b 100644 --- a/packages/piveau-hub-ui-modules/lib/data-provider-interface/config/dcatap/input-definition.ts +++ b/packages/piveau-hub-ui-modules/lib/data-provider-interface/config/dcatap/input-definition.ts @@ -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' } }, diff --git a/packages/piveau-hub-ui-modules/lib/data-provider-interface/config/dcatapde/input-definition.ts b/packages/piveau-hub-ui-modules/lib/data-provider-interface/config/dcatapde/input-definition.ts index 21bcde4e4bb93cdd22a9babddea1930775e69c96..1fa85f36cdae072e1eef6ed5f959dcd781d40770 100644 --- a/packages/piveau-hub-ui-modules/lib/data-provider-interface/config/dcatapde/input-definition.ts +++ b/packages/piveau-hub-ui-modules/lib/data-provider-interface/config/dcatapde/input-definition.ts @@ -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' }