[AAE-207] support aps 1.x for upload reset (#5260)

* support aps 1.x for upload reset

* update test

* revert pdfjd change

* fix error reporting and crash from upload button

* i18n support for generic error

* fix test
This commit is contained in:
Denys Vuika
2019-11-21 15:06:00 +00:00
committed by Eugenio Romano
parent c61de922af
commit e806e97c75
8 changed files with 29 additions and 26 deletions

View File

@@ -134,8 +134,8 @@ describe('UploadWidgetComponent', () => {
});
uploadWidgetComponent.removeFile(uploadWidgetComponent.field.value[0]);
expect(uploadWidgetComponent.field.value.length).toBe(0);
expect(uploadWidgetComponent.field.json.value.length).toBe(0);
expect(uploadWidgetComponent.field.value).toBeNull();
expect(uploadWidgetComponent.field.json.value).toBeNull();
expect(uploadWidgetComponent.hasFile).toBeFalsy();
});

View File

@@ -108,7 +108,7 @@ export class UploadWidgetComponent extends WidgetComponent implements OnInit {
}
}
private removeElementFromList(file) {
private removeElementFromList(file: any) {
const index = this.field.value.indexOf(file);
if (index !== -1) {
@@ -119,17 +119,13 @@ export class UploadWidgetComponent extends WidgetComponent implements OnInit {
this.hasFile = this.field.value.length > 0;
this.resetFormValueWithNoFiles();
}
private resetFormValueWithNoFiles() {
if (this.field.value.length === 0) {
this.field.value = [];
this.field.json.value = [];
if (!this.hasFile) {
this.field.value = null;
this.field.json.value = null;
}
}
getIcon(mimeType) {
getIcon(mimeType: string): string {
return this.thumbnailService.getMimeTypeIcon(mimeType);
}