mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-3562] People Widget reactive form (#3805)
* [ADF-3562] People Widget reactive form * [ADF-3382] Removed comment
This commit is contained in:
committed by
Eugenio Romano
parent
7e4c30a274
commit
bd4ac1b71d
@@ -10,8 +10,7 @@
|
||||
data-automation-id="adf-people-search-input"
|
||||
type="text"
|
||||
[id]="field.id"
|
||||
[(ngModel)]="value"
|
||||
[formControl] ="searchTerm"
|
||||
[formControl]="searchTerm"
|
||||
placeholder="{{field.placeholder}}"
|
||||
[matAutocomplete]="auto">
|
||||
<mat-autocomplete class="adf-people-widget-list" #auto="matAutocomplete" (optionSelected)="onItemSelect($event.option.value)">
|
||||
|
@@ -70,7 +70,7 @@ export class PeopleWidgetComponent extends WidgetComponent implements OnInit {
|
||||
);
|
||||
}),
|
||||
map((list: UserProcessModel[]) => {
|
||||
let value = (this.input.nativeElement as HTMLInputElement).value;
|
||||
let value = this.searchTerm.value;
|
||||
this.checkUserAndValidateForm(list, value);
|
||||
return list;
|
||||
})
|
||||
@@ -83,7 +83,7 @@ export class PeopleWidgetComponent extends WidgetComponent implements OnInit {
|
||||
|
||||
ngOnInit() {
|
||||
if (this.field) {
|
||||
this.value = this.getDisplayName(this.field.value);
|
||||
this.searchTerm.setValue(this.getDisplayName(this.field.value));
|
||||
if (this.field.readOnly) {
|
||||
this.searchTerm.disable();
|
||||
}
|
||||
@@ -97,7 +97,7 @@ export class PeopleWidgetComponent extends WidgetComponent implements OnInit {
|
||||
|
||||
checkUserAndValidateForm(list, value) {
|
||||
const isValidUser = this.isValidUser(list, value);
|
||||
if (isValidUser) {
|
||||
if (isValidUser || value === '') {
|
||||
this.field.validationSummary.message = '';
|
||||
this.field.validate();
|
||||
this.field.form.validateForm();
|
||||
@@ -131,7 +131,7 @@ export class PeopleWidgetComponent extends WidgetComponent implements OnInit {
|
||||
onItemSelect(item) {
|
||||
if (item) {
|
||||
this.field.value = item;
|
||||
this.value = item;
|
||||
this.searchTerm.setValue(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user