mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
[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:
committed by
Eugenio Romano
parent
c61de922af
commit
e806e97c75
@@ -151,7 +151,8 @@
|
||||
"FILE_UPLOAD": {
|
||||
"BUTTON": {
|
||||
"UPLOAD_FILE": "Upload file",
|
||||
"UPLOAD_FOLDER": "Upload folder"
|
||||
"UPLOAD_FOLDER": "Upload folder",
|
||||
"PERMISSION_CHECK_ERROR": "Error checking permission."
|
||||
},
|
||||
"VERSION": {
|
||||
"MESSAGES": {
|
||||
|
||||
@@ -384,7 +384,7 @@ describe('UploadButtonComponent', () => {
|
||||
spyOn(contentService, 'getNode').and.returnValue(throwError('error'));
|
||||
|
||||
component.error.subscribe((value) => {
|
||||
expect(value).toBe('error');
|
||||
expect(value).toBe('FILE_UPLOAD.BUTTON.PERMISSION_CHECK_ERROR');
|
||||
done();
|
||||
});
|
||||
|
||||
|
||||
@@ -120,7 +120,13 @@ export class UploadButtonComponent extends UploadBase implements OnInit, OnChang
|
||||
|
||||
this.contentService.getNode(this.rootFolderId, opts).subscribe(
|
||||
(res) => this.permissionValue.next(this.nodeHasPermission(res.entry, AllowableOperationsEnum.CREATE)),
|
||||
(error) => this.error.emit(error)
|
||||
(error: { error: Error }) => {
|
||||
if (error && error.error) {
|
||||
this.error.emit(error.error.message);
|
||||
} else {
|
||||
this.error.emit('FILE_UPLOAD.BUTTON.PERMISSION_CHECK_ERROR');
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user