From b0e5e8f3c7813af65a60ebfafa55f2c922a70ec0 Mon Sep 17 00:00:00 2001 From: brontolosone <177225737+brontolosone@users.noreply.github.com> Date: Tue, 8 Oct 2024 14:40:24 +0000 Subject: [PATCH 1/7] demo: enable .xml form upload --- packages/web-forms/src/demo/FormUpload.vue | 28 ++++++++++++---------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/packages/web-forms/src/demo/FormUpload.vue b/packages/web-forms/src/demo/FormUpload.vue index 8fa22ebc0..2347d6345 100644 --- a/packages/web-forms/src/demo/FormUpload.vue +++ b/packages/web-forms/src/demo/FormUpload.vue @@ -77,19 +77,23 @@ const uploadFile = async (file: File) => { reset(); uploadedFilename.value = file.name; - const { data: response, error: conversionError } = await convertXlsForm(file); - - if (conversionError) { - error.value = conversionError; - } else if (response) { - if (response.error) { - error.value = response.error; - } else if (response.xform_url) { - xformUrl.value = response.xform_url; - } + if (file.name.endsWith('.xml')) { + xformUrl.value = URL.createObjectURL(file); + } else { + const { data: response, error: conversionError } = await convertXlsForm(file); + + if (conversionError) { + error.value = conversionError; + } else if (response) { + if (response.error) { + error.value = response.error; + } else if (response.xform_url) { + xformUrl.value = response.xform_url; + } - if (response.warnings && response.warnings.length > 0) { - warnings.value = response.warnings; + if (response.warnings && response.warnings.length > 0) { + warnings.value = response.warnings; + } } } From 5c47a71857ad1649036d9ed9e717518ae11a0be0 Mon Sep 17 00:00:00 2001 From: brontolosone <177225737+brontolosone@users.noreply.github.com> Date: Thu, 10 Oct 2024 12:34:37 +0000 Subject: [PATCH 2/7] in *dev mode*, *optionally* bypass the conversion/validation service for xml form uploads --- packages/web-forms/src/demo/FormUpload.vue | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/web-forms/src/demo/FormUpload.vue b/packages/web-forms/src/demo/FormUpload.vue index 2347d6345..0431d0ebb 100644 --- a/packages/web-forms/src/demo/FormUpload.vue +++ b/packages/web-forms/src/demo/FormUpload.vue @@ -27,6 +27,10 @@ const { data: config, error: configErrors } = useConfiguration(); const xlsformOnlineBaseUrl = computed(() => config.value?.['xlsform-online-url']); +const inDevMode = import.meta.env.DEV; + +const bypassConverterForXml = ref(false); + watch(configErrors, (value) => { if (value) { error.value = @@ -77,8 +81,8 @@ const uploadFile = async (file: File) => { reset(); uploadedFilename.value = file.name; - if (file.name.endsWith('.xml')) { - xformUrl.value = URL.createObjectURL(file); + if (bypassConverterForXml.value && file.name.endsWith('.xml')) { + xformUrl.value = URL.createObjectURL(file); // leaks; in non-demo code, we might want to deallocate the object URL at some point. } else { const { data: response, error: conversionError } = await convertXlsForm(file); @@ -149,6 +153,14 @@ document.addEventListener( Drag and drop XLSForm or upload form +