Tests for Upload widget

This commit is contained in:
Denys Vuika
2016-10-13 13:53:47 +01:00
parent d179accca7
commit cf287abdc1
3 changed files with 94 additions and 7 deletions

View File

@@ -29,6 +29,7 @@ export class UploadWidget extends WidgetComponent implements OnInit {
hasFile: boolean;
fileName: string;
displayText: string;
constructor(private settingsService: AlfrescoSettingsService,
private authService: AlfrescoAuthenticationService) {
@@ -43,18 +44,19 @@ export class UploadWidget extends WidgetComponent implements OnInit {
this.hasFile = true;
let file = this.field.value[0];
this.fileName = file.name;
this.displayText = decodeURI(file.name);
}
}
getUploadedFileName(): string {
return decodeURI(this.fileName);
}
reset() {
this.field.value = null;
this.field.json.value = null;
this.hasFile = false;
this.fileName = null;
this.displayText = null;
if (this.field) {
this.field.value = null;
this.field.json.value = null;
}
}
onFileChanged(event: any) {
@@ -65,6 +67,7 @@ export class UploadWidget extends WidgetComponent implements OnInit {
this.hasFile = true;
this.fileName = encodeURI(file.name);
this.displayText = file.name;
let formData: FormData = new FormData();
formData.append('file', file, this.fileName);