From 0558ac58e0f65325017976f7e159daa23dd711e6 Mon Sep 17 00:00:00 2001 From: Alexandr Shalaginov Date: Mon, 29 Jul 2024 10:52:36 +0300 Subject: [PATCH 1/3] SUPPORT-8381: fix --- .../template/ervu/component/ErvuFileUpload.html | 15 ++++++++------- .../ervu/component/fileupload/ErvuFileUpload.ts | 9 +++++++-- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/frontend/src/resources/template/ervu/component/ErvuFileUpload.html b/frontend/src/resources/template/ervu/component/ErvuFileUpload.html index 4ea024b9..896d989c 100644 --- a/frontend/src/resources/template/ervu/component/ErvuFileUpload.html +++ b/frontend/src/resources/template/ervu/component/ErvuFileUpload.html @@ -7,14 +7,15 @@ *ngIf="(!maxFilesToUpload || uploader.queue.length < maxFilesToUpload) && isDropZoneVisible"> {{selectFileFieldText}} - + +
{{item?.file?.name}} diff --git a/frontend/src/ts/ervu/component/fileupload/ErvuFileUpload.ts b/frontend/src/ts/ervu/component/fileupload/ErvuFileUpload.ts index 1762ae05..8e81aeb3 100644 --- a/frontend/src/ts/ervu/component/fileupload/ErvuFileUpload.ts +++ b/frontend/src/ts/ervu/component/fileupload/ErvuFileUpload.ts @@ -51,7 +51,7 @@ export class ErvuFileUpload extends InputControl { protected isFilesListVisible: boolean = true; protected isProgressBarVisible: boolean = false; - private fileInputEl: any; + private fileInputEl: HTMLInputElement; private url: string = '/backend/employee/document'; private messagesService: MessagesService; @@ -95,7 +95,7 @@ export class ErvuFileUpload extends InputControl { ngAfterViewInit() { super.ngAfterViewInit(); - this.fileInputEl = $(this.el.nativeElement).find('.file-input'); + this.fileInputEl = $(this.el.nativeElement).find('.file-input')[0] as HTMLInputElement; } openFileChooseDialog() { @@ -109,7 +109,9 @@ export class ErvuFileUpload extends InputControl { removeFile(item: FileItem) { item.remove(); + this.fileInputEl.value = ''; this.fileDeletedEvent.trigger(); + this.cd.markForCheck(); } private setUploaderMethods() { @@ -162,6 +164,8 @@ export class ErvuFileUpload extends InputControl { default: this.messagesService.error(`Не удалось добавить файл ${item.name}.`); } + this.fileInputEl.value = ''; + this.cd.markForCheck(); }; } @@ -212,6 +216,7 @@ export class ErvuFileUpload extends InputControl { public reset() { //don't use super because there is no ngModel here this.uploader.clearQueue(); + this.fileInputEl.value = ''; this.isDropZoneVisible = true; this.isFilesListVisible = true; this.isProgressBarVisible = false; From 82e8b112629d418567edbd33af47096b5b18b213 Mon Sep 17 00:00:00 2001 From: Alexandr Shalaginov Date: Mon, 29 Jul 2024 11:51:29 +0300 Subject: [PATCH 2/3] SUPPORT-8381: fix (2) --- .../ts/ervu/component/fileupload/ErvuFileUpload.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/frontend/src/ts/ervu/component/fileupload/ErvuFileUpload.ts b/frontend/src/ts/ervu/component/fileupload/ErvuFileUpload.ts index 8e81aeb3..e23611d0 100644 --- a/frontend/src/ts/ervu/component/fileupload/ErvuFileUpload.ts +++ b/frontend/src/ts/ervu/component/fileupload/ErvuFileUpload.ts @@ -54,6 +54,7 @@ export class ErvuFileUpload extends InputControl { private fileInputEl: HTMLInputElement; private url: string = '/backend/employee/document'; private messagesService: MessagesService; + private isUploadErrorOccurred = false; constructor(el: ElementRef, cd: ChangeDetectorRef) { super(el, cd); @@ -135,14 +136,17 @@ export class ErvuFileUpload extends InputControl { this.isDropZoneVisible = true; this.isFilesListVisible = true; this.isProgressBarVisible = false; + this.isUploadErrorOccurred = true; this.cd.markForCheck(); }; this.uploader.onCompleteAll = () => { - this.uploader.clearQueue(); - this.fileUploadEndEvent.trigger(); - this.isProgressBarVisible = false; - this.cd.markForCheck(); + if (!this.isUploadErrorOccurred) { + this.uploader.clearQueue(); + this.fileUploadEndEvent.trigger(); + this.isProgressBarVisible = false; + this.cd.markForCheck(); + } }; this.uploader.onAfterAddingFile = (fileItem: FileItem) => { @@ -220,6 +224,7 @@ export class ErvuFileUpload extends InputControl { this.isDropZoneVisible = true; this.isFilesListVisible = true; this.isProgressBarVisible = false; + this.isUploadErrorOccurred = false; this.cd.markForCheck(); } } \ No newline at end of file From 56806cf240b443638909a9fbbd3021f5ebc4d7be Mon Sep 17 00:00:00 2001 From: Alexandr Shalaginov Date: Mon, 29 Jul 2024 12:53:25 +0300 Subject: [PATCH 3/3] SUPPORT-8381: fix by review --- .../src/ts/ervu/component/fileupload/ErvuFileUpload.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/src/ts/ervu/component/fileupload/ErvuFileUpload.ts b/frontend/src/ts/ervu/component/fileupload/ErvuFileUpload.ts index e23611d0..58f16b74 100644 --- a/frontend/src/ts/ervu/component/fileupload/ErvuFileUpload.ts +++ b/frontend/src/ts/ervu/component/fileupload/ErvuFileUpload.ts @@ -96,7 +96,7 @@ export class ErvuFileUpload extends InputControl { ngAfterViewInit() { super.ngAfterViewInit(); - this.fileInputEl = $(this.el.nativeElement).find('.file-input')[0] as HTMLInputElement; + this.fileInputEl = this.el.nativeElement.querySelector('.file-input'); } openFileChooseDialog() { @@ -110,7 +110,7 @@ export class ErvuFileUpload extends InputControl { removeFile(item: FileItem) { item.remove(); - this.fileInputEl.value = ''; + this.fileInputEl.value = null; this.fileDeletedEvent.trigger(); this.cd.markForCheck(); } @@ -168,7 +168,7 @@ export class ErvuFileUpload extends InputControl { default: this.messagesService.error(`Не удалось добавить файл ${item.name}.`); } - this.fileInputEl.value = ''; + this.fileInputEl.value = null; this.cd.markForCheck(); }; } @@ -220,7 +220,7 @@ export class ErvuFileUpload extends InputControl { public reset() { //don't use super because there is no ngModel here this.uploader.clearQueue(); - this.fileInputEl.value = ''; + this.fileInputEl.value = null; this.isDropZoneVisible = true; this.isFilesListVisible = true; this.isProgressBarVisible = false;