Skip to content

Commit

Permalink
Merge pull request #217 from bcgov/fix/vue-3-bugs
Browse files Browse the repository at this point in the history
fix: breaking vuetify changes to file upload
  • Loading branch information
SoLetsDev authored Sep 10, 2024
2 parents a19b36a + d588a9b commit acc281c
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions frontend/src/components/DocumentUpload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
label="Document Type"
/>
<v-file-input
v-model="fileArray"
v-model="inputFile"
:rules="fileRules"
:accept="fileAccept"
placeholder="Select your file"
Expand Down Expand Up @@ -103,7 +103,7 @@ export default {
buttonKey: 0,
documentTypeCode: null,
fileAccept: '',
fileArray: [],
inputFile: null,
fileFormats: 'PDF, JPEG, and PNG',
fileInputError: [],
fileRules: [],
Expand All @@ -120,7 +120,7 @@ export default {
return getRequestStore().requestID;
},
dataReady () {
return this.validForm && this.fileArray;
return this.validForm && this.inputFile;
},
documentTypes() {
return sortBy(this.documentTypeCodes, ['displayOrder']).map(code =>
Expand Down Expand Up @@ -170,13 +170,12 @@ export default {
submitRequest() {
if (this.dataReady) {
try {
const [ file ] = this.fileArray;
this.active = true;
const reader = new FileReader();
reader.onload = this.uploadFile;
reader.onabort = this.handleFileReadErr;
reader.onerror = this.handleFileReadErr;
reader.readAsBinaryString(file);
reader.readAsBinaryString(this.inputFile);
} catch (e) {
this.handleFileReadErr();
throw e;
Expand All @@ -188,12 +187,11 @@ export default {
this.setErrorAlert('Sorry, an unexpected error seems to have occurred. Try uploading your files later.');
},
async uploadFile(env) {
const [ file ] = this.fileArray;
let document = {
documentTypeCode: this.documentTypeCode,
fileName: getFileNameWithMaxNameLength(file.name),
fileExtension: file.type,
fileSize: file.size,
fileName: getFileNameWithMaxNameLength(this.inputFile.name),
fileExtension: this.inputFile.type,
fileSize: this.inputFile.size,
documentData: btoa(env.target.result)
};
Expand Down

0 comments on commit acc281c

Please sign in to comment.