From 5d44f91a85216e571b64cd0d4775bad81ca9a394 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9verin=20Beauvais?= Date: Fri, 27 Sep 2024 17:15:20 -0700 Subject: [PATCH] - app version = 5.11.26 (#741) - refactored file input rules to emit error messages - separated onFileSelected and onRemoveClicked to simplify code Co-authored-by: Severin Beauvais --- package-lock.json | 4 +- package.json | 2 +- .../ContinuationAuthorization.vue | 35 ++++---- src/components/common/FileUploadPreview.vue | 84 +++++++++---------- 4 files changed, 60 insertions(+), 65 deletions(-) diff --git a/package-lock.json b/package-lock.json index fdb05684..ddc13310 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "business-create-ui", - "version": "5.11.25", + "version": "5.11.26", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "business-create-ui", - "version": "5.11.25", + "version": "5.11.26", "dependencies": { "@babel/compat-data": "^7.21.5", "@bcrs-shared-components/approval-type": "1.1.2", diff --git a/package.json b/package.json index bc9166ba..a012dbc3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "business-create-ui", - "version": "5.11.25", + "version": "5.11.26", "private": true, "appName": "Create UI", "sbcName": "SBC Common Components", diff --git a/src/components/ContinuationIn/ContinuationAuthorization.vue b/src/components/ContinuationIn/ContinuationAuthorization.vue index 58b0f752..17cc6d07 100644 --- a/src/components/ContinuationIn/ContinuationAuthorization.vue +++ b/src/components/ContinuationIn/ContinuationAuthorization.vue @@ -103,6 +103,7 @@ class="d-none mt-6" :maxSize="MAX_FILE_SIZE" :customErrorMessage.sync="customErrorMessage" + :isRequired="false" @fileValidity="onFileValidity($event)" @fileSelected="onFileSelected($event)" /> @@ -136,7 +137,7 @@ class="remove-document-button" text color="primary" - @click="onFileSelected(null, index)" + @click="onRemoveClicked(index)" > Remove @@ -330,18 +331,11 @@ export default class ExtraproRegistration extends Mixins(DocumentMixin) { /** * Called when FileUploadPreview tells us about a new or cleared file. * This is called right after the File Validity event. - * @param file the file to add or null to delete - * @param index the index of the file to delete + * @param file the file to add */ - async onFileSelected (file: File, index = 0): Promise { - if (file) { - // verify that file is valid - if (!this.fileValidity) { - // if file loader hasn't set an error message, set default message - if (!this.customErrorMessage) this.customErrorMessage = 'Invalid file.' - return // don't add to array - } - + async onFileSelected (file: File): Promise { + // verify that file is specified and is valid + if (file && this.fileValidity) { // verify that file doesn't already exist if (this.authorization.files.find(f => f.file.name === file.name)) { // set error message @@ -376,15 +370,22 @@ export default class ExtraproRegistration extends Mixins(DocumentMixin) { }) this.isFileAdded = true - } else if (file === null) { - // null file means user clicked Remove button - proceed - // undefined file means file upload was cancelled - do nothing + } + } + + /** + * Called when user clicks a Remove button. + * @param index the index of the file to remove + */ + onRemoveClicked (index = NaN): void { + // safety check + if (index >= 0) { // delete file from Minio, not waiting for response and ignoring errors this.deleteDocument(this.authorization.files[index].fileKey).catch(() => null) // remove file from array this.authorization.files.splice(index, 1) - // clear previous error message, if any - this.customErrorMessage = null + // clear any existing error message + this.customErrorMessage = '' } } diff --git a/src/components/common/FileUploadPreview.vue b/src/components/common/FileUploadPreview.vue index 9debbe26..80d77096 100644 --- a/src/components/common/FileUploadPreview.vue +++ b/src/components/common/FileUploadPreview.vue @@ -1,9 +1,5 @@