Browse Source

review changes

- bugfix: avoid set value to undefined
- filter by startsWith instead include
pull/2429/head
Kevin Lien 2 years ago
committed by Thomas
parent
commit
755d56a8e8
  1. 8
      apps/client/src/app/pages/accounts/create-or-update-account-dialog/create-or-update-account-dialog.component.ts

8
apps/client/src/app/pages/accounts/create-or-update-account-dialog/create-or-update-account-dialog.component.ts

@ -110,23 +110,25 @@ export class CreateOrUpdateAccountDialog implements OnDestroy {
const matchingEntry = this.platforms.find(({ name }) => {
return name === inputValue;
});
if (matchingEntry) {
this.accountForm.controls['platformId'].setValue(matchingEntry);
}
}
}
displayFn(platform: Platform) {
public displayFn(platform: Platform) {
return platform?.name ? platform.name : '';
}
private _filter(value: string): Platform[] {
const filterValue = value.toLowerCase();
return this.platforms.filter(({ name }) => {
return name.toLowerCase().includes(filterValue);
return name.toLowerCase().startsWith(filterValue);
});
}
private _autocompleteObjectValidator(): ValidatorFn {
return (control: AbstractControl): { [key: string]: any } | null => {
return (control: AbstractControl) => {
if (typeof control.value === 'string') {
return { invalidAutocompleteObject: { value: control.value } };
}

Loading…
Cancel
Save