mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-19 17:14:57 +00:00
parent
f64ef77d41
commit
1c2b2fa40a
@ -2,7 +2,7 @@
|
||||
|
||||
<label [attr.for]="field.id">{{field.name}}</label>
|
||||
<div>
|
||||
<span *ngIf="hasFile" class="attach-widget__file">{{getLinkedFileName()}}</span>
|
||||
<span *ngIf="hasFile()" class="attach-widget__file mdl-chip"><span class="mdl-chip__text">{{getLinkedFileName()}}</span></span>
|
||||
<button #browseFile (click)="showDialog();" class="mdl-button mdl-js-button mdl-js-ripple-effect attach-widget__browser">
|
||||
<i class="material-icons">image</i>
|
||||
Browse {{selectedFolderSiteName}}
|
||||
|
@ -42,24 +42,23 @@ describe('AttachWidget', () => {
|
||||
});
|
||||
|
||||
it('should require field value to check file', () => {
|
||||
widget.hasFile = false;
|
||||
widget.field = null;
|
||||
widget.ngOnInit();
|
||||
expect(widget.hasFile).toBeFalsy();
|
||||
expect(widget.hasFile()).toBeFalsy();
|
||||
|
||||
widget.field = new FormFieldModel(null, {
|
||||
type: FormFieldTypes.UPLOAD,
|
||||
value: null
|
||||
});
|
||||
widget.ngOnInit();
|
||||
expect(widget.hasFile).toBeFalsy();
|
||||
expect(widget.hasFile()).toBeFalsy();
|
||||
|
||||
widget.field = new FormFieldModel(null, {
|
||||
type: FormFieldTypes.UPLOAD,
|
||||
value: [{ name: 'file' }]
|
||||
});
|
||||
widget.ngOnInit();
|
||||
expect(widget.hasFile).toBeTruthy();
|
||||
expect(widget.hasFile()).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should setup with form field', () => {
|
||||
@ -116,19 +115,20 @@ describe('AttachWidget', () => {
|
||||
expect(widget.selectedFile).toBe(node);
|
||||
expect(widget.field.value).toEqual([link]);
|
||||
expect(widget.field.json.value).toEqual([link]);
|
||||
expect(widget.hasFile()).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should reset', () => {
|
||||
widget.hasFile = true;
|
||||
widget.field = new FormFieldModel(null, {
|
||||
type: FormFieldTypes.UPLOAD,
|
||||
value: [{ name: 'filename' }]
|
||||
});
|
||||
|
||||
widget.reset();
|
||||
expect(widget.hasFile).toBeFalsy();
|
||||
expect(widget.hasFile()).toBeFalsy();
|
||||
expect(widget.field.value).toBeNull();
|
||||
expect(widget.field.json.value).toBeNull();
|
||||
expect(widget.hasFile()).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should close dialog on cancel', () => {
|
||||
|
@ -35,7 +35,6 @@ export class AttachWidget extends WidgetComponent implements OnInit {
|
||||
selectedFolderSiteName: string;
|
||||
selectedFolderAccountId: string;
|
||||
fileName: string;
|
||||
hasFile: boolean;
|
||||
selectedFolderNodes: [ExternalContent];
|
||||
selectedFile: ExternalContent;
|
||||
|
||||
@ -54,10 +53,6 @@ export class AttachWidget extends WidgetComponent implements OnInit {
|
||||
|
||||
ngOnInit() {
|
||||
if (this.field) {
|
||||
if (this.field.value) {
|
||||
this.hasFile = true;
|
||||
}
|
||||
|
||||
let params = this.field.params;
|
||||
|
||||
if (params &&
|
||||
@ -149,7 +144,10 @@ export class AttachWidget extends WidgetComponent implements OnInit {
|
||||
reset() {
|
||||
this.field.value = null;
|
||||
this.field.json.value = null;
|
||||
this.hasFile = false;
|
||||
}
|
||||
|
||||
hasFile(): boolean {
|
||||
return this.field && this.field.value;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user