diff --git a/frontend/src/resources/template/ervu/component/ErvuFileUpload.html b/frontend/src/resources/template/ervu/component/ErvuFileUpload.html index 19100551..5c6e08d0 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..58f16b74 100644 --- a/frontend/src/ts/ervu/component/fileupload/ErvuFileUpload.ts +++ b/frontend/src/ts/ervu/component/fileupload/ErvuFileUpload.ts @@ -51,9 +51,10 @@ 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; + private isUploadErrorOccurred = false; constructor(el: ElementRef, cd: ChangeDetectorRef) { super(el, cd); @@ -95,7 +96,7 @@ export class ErvuFileUpload extends InputControl { ngAfterViewInit() { super.ngAfterViewInit(); - this.fileInputEl = $(this.el.nativeElement).find('.file-input'); + this.fileInputEl = this.el.nativeElement.querySelector('.file-input'); } openFileChooseDialog() { @@ -109,7 +110,9 @@ export class ErvuFileUpload extends InputControl { removeFile(item: FileItem) { item.remove(); + this.fileInputEl.value = null; this.fileDeletedEvent.trigger(); + this.cd.markForCheck(); } private setUploaderMethods() { @@ -133,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) => { @@ -162,6 +168,8 @@ export class ErvuFileUpload extends InputControl { default: this.messagesService.error(`Не удалось добавить файл ${item.name}.`); } + this.fileInputEl.value = null; + this.cd.markForCheck(); }; } @@ -212,9 +220,11 @@ export class ErvuFileUpload extends InputControl { public reset() { //don't use super because there is no ngModel here this.uploader.clearQueue(); + this.fileInputEl.value = null; this.isDropZoneVisible = true; this.isFilesListVisible = true; this.isProgressBarVisible = false; + this.isUploadErrorOccurred = false; this.cd.markForCheck(); } } \ No newline at end of file