diff --git a/ng2-components/ng2-activiti-form/src/components/widgets/core/group.model.ts b/ng2-components/ng2-activiti-form/src/components/widgets/core/group.model.ts index de701aec0a..bf14a9d2a7 100644 --- a/ng2-components/ng2-activiti-form/src/components/widgets/core/group.model.ts +++ b/ng2-components/ng2-activiti-form/src/components/widgets/core/group.model.ts @@ -23,4 +23,14 @@ export class GroupModel { name: string; status: string; + constructor(json?: any) { + if (json) { + this.externalId = json.externalId; + this.groups = json.groups; + this.id = json.id; + this.name = json.name; + this.status = json.status; + } + } + } diff --git a/ng2-components/ng2-activiti-form/src/components/widgets/functional-group/functional-group.widget.html b/ng2-components/ng2-activiti-form/src/components/widgets/functional-group/functional-group.widget.html index 7a9bf8f2a5..5562b58d6e 100644 --- a/ng2-components/ng2-activiti-form/src/components/widgets/functional-group/functional-group.widget.html +++ b/ng2-components/ng2-activiti-form/src/components/widgets/functional-group/functional-group.widget.html @@ -10,7 +10,7 @@ -
+
-
+
    -
  • {{item.name}} diff --git a/ng2-components/ng2-activiti-form/src/components/widgets/typeahead/typeahead.widget.spec.ts b/ng2-components/ng2-activiti-form/src/components/widgets/typeahead/typeahead.widget.spec.ts index b0705fc9b1..5dbfdd09eb 100644 --- a/ng2-components/ng2-activiti-form/src/components/widgets/typeahead/typeahead.widget.spec.ts +++ b/ng2-components/ng2-activiti-form/src/components/widgets/typeahead/typeahead.widget.spec.ts @@ -72,6 +72,9 @@ describe('TypeaheadWidget', () => { }); it('should show popup on key up', () => { + + spyOn(widget, 'getOptions').and.returnValue([{}, {}]); + widget.minTermLength = 1; widget.value = 'some value'; @@ -80,6 +83,15 @@ describe('TypeaheadWidget', () => { expect(widget.popupVisible).toBeTruthy(); }); + it('should require items to show popup', () => { + widget.minTermLength = 1; + widget.value = 'some value'; + + widget.popupVisible = false; + widget.onKeyUp(null); + expect(widget.popupVisible).toBeFalsy(); + }); + it('should require value to show popup', () => { widget.minTermLength = 1; widget.value = ''; @@ -90,6 +102,8 @@ describe('TypeaheadWidget', () => { }); it('should require value to be of min length to show popup', () => { + spyOn(widget, 'getOptions').and.returnValue([{}, {}]); + widget.minTermLength = 3; widget.value = 'v'; diff --git a/ng2-components/ng2-activiti-form/src/components/widgets/typeahead/typeahead.widget.ts b/ng2-components/ng2-activiti-form/src/components/widgets/typeahead/typeahead.widget.ts index 8ed39cc2ef..d58ccf6f83 100644 --- a/ng2-components/ng2-activiti-form/src/components/widgets/typeahead/typeahead.widget.ts +++ b/ng2-components/ng2-activiti-form/src/components/widgets/typeahead/typeahead.widget.ts @@ -34,6 +34,7 @@ export class TypeaheadWidget extends WidgetComponent implements OnInit { popupVisible: boolean = false; minTermLength: number = 1; value: string; + options: FormFieldOption[] = []; constructor(private formService: FormService) { super(); @@ -72,7 +73,12 @@ export class TypeaheadWidget extends WidgetComponent implements OnInit { } onKeyUp(event: KeyboardEvent) { - this.popupVisible = !!(this.value && this.value.length >= this.minTermLength); + if (this.value && this.value.length >= this.minTermLength) { + this.options = this.getOptions(); + this.popupVisible = this.options.length > 0; + } else { + this.popupVisible = false; + } } onBlur() {