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>
|
<label [attr.for]="field.id">{{field.name}}</label>
|
||||||
<div>
|
<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">
|
<button #browseFile (click)="showDialog();" class="mdl-button mdl-js-button mdl-js-ripple-effect attach-widget__browser">
|
||||||
<i class="material-icons">image</i>
|
<i class="material-icons">image</i>
|
||||||
Browse {{selectedFolderSiteName}}
|
Browse {{selectedFolderSiteName}}
|
||||||
|
@ -42,24 +42,23 @@ describe('AttachWidget', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should require field value to check file', () => {
|
it('should require field value to check file', () => {
|
||||||
widget.hasFile = false;
|
|
||||||
widget.field = null;
|
widget.field = null;
|
||||||
widget.ngOnInit();
|
widget.ngOnInit();
|
||||||
expect(widget.hasFile).toBeFalsy();
|
expect(widget.hasFile()).toBeFalsy();
|
||||||
|
|
||||||
widget.field = new FormFieldModel(null, {
|
widget.field = new FormFieldModel(null, {
|
||||||
type: FormFieldTypes.UPLOAD,
|
type: FormFieldTypes.UPLOAD,
|
||||||
value: null
|
value: null
|
||||||
});
|
});
|
||||||
widget.ngOnInit();
|
widget.ngOnInit();
|
||||||
expect(widget.hasFile).toBeFalsy();
|
expect(widget.hasFile()).toBeFalsy();
|
||||||
|
|
||||||
widget.field = new FormFieldModel(null, {
|
widget.field = new FormFieldModel(null, {
|
||||||
type: FormFieldTypes.UPLOAD,
|
type: FormFieldTypes.UPLOAD,
|
||||||
value: [{ name: 'file' }]
|
value: [{ name: 'file' }]
|
||||||
});
|
});
|
||||||
widget.ngOnInit();
|
widget.ngOnInit();
|
||||||
expect(widget.hasFile).toBeTruthy();
|
expect(widget.hasFile()).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should setup with form field', () => {
|
it('should setup with form field', () => {
|
||||||
@ -116,19 +115,20 @@ describe('AttachWidget', () => {
|
|||||||
expect(widget.selectedFile).toBe(node);
|
expect(widget.selectedFile).toBe(node);
|
||||||
expect(widget.field.value).toEqual([link]);
|
expect(widget.field.value).toEqual([link]);
|
||||||
expect(widget.field.json.value).toEqual([link]);
|
expect(widget.field.json.value).toEqual([link]);
|
||||||
|
expect(widget.hasFile()).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should reset', () => {
|
it('should reset', () => {
|
||||||
widget.hasFile = true;
|
|
||||||
widget.field = new FormFieldModel(null, {
|
widget.field = new FormFieldModel(null, {
|
||||||
type: FormFieldTypes.UPLOAD,
|
type: FormFieldTypes.UPLOAD,
|
||||||
value: [{ name: 'filename' }]
|
value: [{ name: 'filename' }]
|
||||||
});
|
});
|
||||||
|
|
||||||
widget.reset();
|
widget.reset();
|
||||||
expect(widget.hasFile).toBeFalsy();
|
expect(widget.hasFile()).toBeFalsy();
|
||||||
expect(widget.field.value).toBeNull();
|
expect(widget.field.value).toBeNull();
|
||||||
expect(widget.field.json.value).toBeNull();
|
expect(widget.field.json.value).toBeNull();
|
||||||
|
expect(widget.hasFile()).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should close dialog on cancel', () => {
|
it('should close dialog on cancel', () => {
|
||||||
|
@ -35,7 +35,6 @@ export class AttachWidget extends WidgetComponent implements OnInit {
|
|||||||
selectedFolderSiteName: string;
|
selectedFolderSiteName: string;
|
||||||
selectedFolderAccountId: string;
|
selectedFolderAccountId: string;
|
||||||
fileName: string;
|
fileName: string;
|
||||||
hasFile: boolean;
|
|
||||||
selectedFolderNodes: [ExternalContent];
|
selectedFolderNodes: [ExternalContent];
|
||||||
selectedFile: ExternalContent;
|
selectedFile: ExternalContent;
|
||||||
|
|
||||||
@ -54,10 +53,6 @@ export class AttachWidget extends WidgetComponent implements OnInit {
|
|||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
if (this.field) {
|
if (this.field) {
|
||||||
if (this.field.value) {
|
|
||||||
this.hasFile = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
let params = this.field.params;
|
let params = this.field.params;
|
||||||
|
|
||||||
if (params &&
|
if (params &&
|
||||||
@ -149,7 +144,10 @@ export class AttachWidget extends WidgetComponent implements OnInit {
|
|||||||
reset() {
|
reset() {
|
||||||
this.field.value = null;
|
this.field.value = null;
|
||||||
this.field.json.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