Skip to content

Commit

Permalink
Fix: CDOGS reupload bug (#1463)
Browse files Browse the repository at this point in the history
* fix reupload template issue

* fix typo
  • Loading branch information
vijaivir authored Aug 12, 2024
1 parent 9ff472a commit 999ec09
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion app/frontend/src/components/forms/PrintOptions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export default {
defaultReportname: '',
displayTemplatePrintButton: false,
isValidFile: true,
fileInputKey: 0,
validFileExtensions: ['txt', 'docx', 'html', 'odt', 'pptx', 'xlsx'],
defaultExportFileTypes: ['pdf'],
uploadExportFileTypes: ['pdf'],
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -256,6 +258,7 @@ export default {
this.loading = false;
}
},
createBody(content, contentFileType, outputFileName, outputFileType) {
return {
options: {
Expand All @@ -270,6 +273,7 @@ export default {
},
};
},
async fetchDefaultTemplate() {
// Calling the API to check whether the form has any uploaded document templates
this.loading = true;
Expand Down Expand Up @@ -313,6 +317,7 @@ export default {
this.loading = false;
}
},
validateFileExtension(event) {
if (event.length > 0) {
const fileExtension = event[0].name.split('.').pop();
Expand All @@ -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 {
Expand All @@ -341,6 +347,12 @@ export default {
this.isValidFile = true;
}
},
handleFileUpload(event) {
this.fileInputKey += 1;
this.templateForm.files = event;
this.validateFileExtension(event);
},
},
};
</script>
Expand Down Expand Up @@ -475,6 +487,7 @@ export default {
value="upload"
></v-radio>
<v-file-input
:key="fileInputKey"
v-model="templateForm.files"
:class="{ label: isRTL }"
:style="isRTL ? { gap: '10px' } : null"
Expand All @@ -489,7 +502,7 @@ export default {
:lang="locale"
:rules="validationRules"
:disabled="selectedOption !== 'upload'"
@update:model-value="validateFileExtension($event)"
@update:model-value="handleFileUpload"
/>
<v-select
v-if="selectedOption === 'upload'"
Expand Down

0 comments on commit 999ec09

Please sign in to comment.