[ADF-3274] people widget instead of the people list (#3582)

* people list added

* tests added

* style fix

* Update start-task.component.ts

Use correct import

* Update people.widget.spec.ts

add the async

* peopleSelected test fixed
This commit is contained in:
Maurizio Vitale
2018-07-23 09:23:33 +01:00
committed by Eugenio Romano
parent 855fdd8f48
commit 0274088114
7 changed files with 63 additions and 9 deletions

View File

@@ -206,6 +206,22 @@ describe('PeopleWidgetComponent', () => {
expect(fixture.debugElement.query(By.css('#adf-people-widget-user-0'))).toBeNull();
});
});
it('should emit peopleSelected if option is selected', async(() => {
let selectEmitSpy = spyOn(widget.peopleSelected, 'emit');
let peopleHTMLElement: HTMLInputElement = <HTMLInputElement> element.querySelector('input');
peopleHTMLElement.focus();
peopleHTMLElement.value = 'T';
peopleHTMLElement.dispatchEvent(new Event('keyup'));
peopleHTMLElement.dispatchEvent(new Event('input'));
fixture.detectChanges();
fixture.whenStable().then(() => {
fixture.detectChanges();
expect(fixture.debugElement.query(By.css('#adf-people-widget-user-0'))).not.toBeNull();
widget.onItemSelect(fakeUserResult[0]);
expect(selectEmitSpy).toHaveBeenCalledWith(1001);
});
}));
});
});

View File

@@ -19,7 +19,7 @@
import { PeopleProcessService } from '../../../../services/people-process.service';
import { UserProcessModel } from '../../../../models';
import { Component, ElementRef, OnInit, ViewChild, ViewEncapsulation } from '@angular/core';
import { Component, ElementRef, EventEmitter, OnInit, Output, ViewChild, ViewEncapsulation } from '@angular/core';
import { FormService } from '../../../services/form.service';
import { GroupModel } from '../core/group.model';
import { baseHost, WidgetComponent } from './../widget.component';
@@ -46,6 +46,9 @@ export class PeopleWidgetComponent extends WidgetComponent implements OnInit {
@ViewChild('inputValue')
input: ElementRef;
@Output()
peopleSelected: EventEmitter<number>;
groupId: string;
value: any;
@@ -89,6 +92,7 @@ export class PeopleWidgetComponent extends WidgetComponent implements OnInit {
constructor(public formService: FormService, public peopleProcessService: PeopleProcessService) {
super(formService);
this.peopleSelected = new EventEmitter();
}
ngOnInit() {
@@ -135,6 +139,7 @@ export class PeopleWidgetComponent extends WidgetComponent implements OnInit {
onItemSelect(item: UserProcessModel) {
if (item) {
this.field.value = item;
this.peopleSelected.emit(item && item.id || undefined);
this.value = this.getDisplayName(item);
}
}