From 999ec0973360b7fbc1a76ebd1ad72fe0258c0cd0 Mon Sep 17 00:00:00 2001
From: Vijaivir Dhaliwal <91633223+vijaivir@users.noreply.github.com>
Date: Mon, 12 Aug 2024 13:53:50 -0700
Subject: [PATCH] Fix: CDOGS reupload bug (#1463)
* fix reupload template issue
* fix typo
---
.../src/components/forms/PrintOptions.vue | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/app/frontend/src/components/forms/PrintOptions.vue b/app/frontend/src/components/forms/PrintOptions.vue
index ec67ce693..718decbf2 100644
--- a/app/frontend/src/components/forms/PrintOptions.vue
+++ b/app/frontend/src/components/forms/PrintOptions.vue
@@ -50,6 +50,7 @@ export default {
defaultReportname: '',
displayTemplatePrintButton: false,
isValidFile: true,
+ fileInputKey: 0,
validFileExtensions: ['txt', 'docx', 'html', 'odt', 'pptx', 'xlsx'],
defaultExportFileTypes: ['pdf'],
uploadExportFileTypes: ['pdf'],
@@ -184,6 +185,7 @@ export default {
? disposition.substring(disposition.indexOf('filename=') + 9)
: undefined;
},
+
createDownload(blob, filename = undefined) {
const url = window.URL.createObjectURL(blob);
const a = document.createElement('a');
@@ -256,6 +258,7 @@ export default {
this.loading = false;
}
},
+
createBody(content, contentFileType, outputFileName, outputFileType) {
return {
options: {
@@ -270,6 +273,7 @@ export default {
},
};
},
+
async fetchDefaultTemplate() {
// Calling the API to check whether the form has any uploaded document templates
this.loading = true;
@@ -313,6 +317,7 @@ export default {
this.loading = false;
}
},
+
validateFileExtension(event) {
if (event.length > 0) {
const fileExtension = event[0].name.split('.').pop();
@@ -325,6 +330,7 @@ export default {
this.uploadExportFileTypes = ['pdf'];
// reset the v-select value
this.templateForm.outputFileType = null;
+
if (this.validFileExtensions.includes(fileExtension)) {
this.isValidFile = true;
} else {
@@ -341,6 +347,12 @@ export default {
this.isValidFile = true;
}
},
+
+ handleFileUpload(event) {
+ this.fileInputKey += 1;
+ this.templateForm.files = event;
+ this.validateFileExtension(event);
+ },
},
};
@@ -475,6 +487,7 @@ export default {
value="upload"
>