mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[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:
committed by
Eugenio Romano
parent
855fdd8f48
commit
0274088114
@@ -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);
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
});
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user