mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-19 17:14:57 +00:00
commit
728ac0a669
@ -1,11 +1,10 @@
|
|||||||
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label typeahead-widget"
|
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label typeahead-widget"
|
||||||
[class.is-dirty]="value"
|
[class.is-dirty]="value"
|
||||||
[class.typeahead-widget__invalid]="!field.isValid">
|
[class.typeahead-widget__invalid]="!field.isValid" id="typehead-div">
|
||||||
<input class="mdl-textfield__input"
|
<input class="mdl-textfield__input"
|
||||||
type="text"
|
type="text"
|
||||||
[attr.id]="field.id"
|
[attr.id]="field.id"
|
||||||
[(ngModel)]="value"
|
[(ngModel)]="value"
|
||||||
(ngModelChange)="checkVisibility(field)"
|
|
||||||
(keyup)="onKeyUp($event)"
|
(keyup)="onKeyUp($event)"
|
||||||
(blur)="onBlur()"
|
(blur)="onBlur()"
|
||||||
[disabled]="field.readOnly">
|
[disabled]="field.readOnly">
|
||||||
|
@ -308,4 +308,33 @@ describe('TypeaheadWidget', () => {
|
|||||||
expect(widget.field.value).toBeNull();
|
expect(widget.field.value).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should emit field change event on item click', () => {
|
||||||
|
let event = jasmine.createSpyObj('event', ['preventDefault']);
|
||||||
|
let fakeField = new FormFieldModel(new FormModel(), {id: 'fakeField', value: 'fakeValue'});
|
||||||
|
widget.field = fakeField;
|
||||||
|
let item = {id: 'fake-id-opt', name: 'fake-name-opt'};
|
||||||
|
widget.onItemClick(item, event);
|
||||||
|
|
||||||
|
widget.fieldChanged.subscribe((field) => {
|
||||||
|
expect(field).toBeDefined();
|
||||||
|
expect(field.id).toEqual('fakeField');
|
||||||
|
expect(field.value).toEqual('fake-id-opt');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should emit field change event on blur', (done) => {
|
||||||
|
spyOn(widget, 'flushValue').and.stub();
|
||||||
|
let fakeField = new FormFieldModel(new FormModel(), {id: 'fakeField', value: 'fakeValue'});
|
||||||
|
widget.field = fakeField;
|
||||||
|
widget.onBlur();
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
widget.fieldChanged.subscribe((field) => {
|
||||||
|
expect(field).toBeDefined();
|
||||||
|
expect(field.id).toEqual('field-id');
|
||||||
|
expect(field.value).toEqual('field-value');
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
}, 200);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -81,6 +81,7 @@ export class TypeaheadWidget extends WidgetComponent implements OnInit {
|
|||||||
onBlur() {
|
onBlur() {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.flushValue();
|
this.flushValue();
|
||||||
|
this.checkVisibility(this.field);
|
||||||
}, 200);
|
}, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,6 +109,7 @@ export class TypeaheadWidget extends WidgetComponent implements OnInit {
|
|||||||
if (item) {
|
if (item) {
|
||||||
this.field.value = item.id;
|
this.field.value = item.id;
|
||||||
this.value = item.name;
|
this.value = item.name;
|
||||||
|
this.checkVisibility(this.field);
|
||||||
}
|
}
|
||||||
if (event) {
|
if (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user