diff --git a/src/frontend/app/administration/contact/page/form/contacts-form.component.html b/src/frontend/app/administration/contact/page/form/contacts-form.component.html index f3224bbb094191d1c2b9d12944577399877bf4c3..762527b72df8e5c4eb5160922a93f85865108d3d 100644 --- a/src/frontend/app/administration/contact/page/form/contacts-form.component.html +++ b/src/frontend/app/administration/contact/page/form/contacts-form.component.html @@ -280,7 +280,7 @@ <input matInput #autoCompleteInput [formControl]="field.control" [placeholder]="field.label" [matAutocomplete]="matAutocompletePostCodeTown"> <mat-autocomplete #matAutocompletePostCodeTown="matAutocomplete" (optionSelected)="selectPostCode($event)"> <mat-option *ngFor="let postcode of postcodesFilteredResult | async" [value]="postcode"> - {{postcode.postcode}} - {{postcode.town}} + {{postcode.town}} </mat-option> </mat-autocomplete> </mat-form-field> diff --git a/src/frontend/app/administration/contact/page/form/contacts-form.component.ts b/src/frontend/app/administration/contact/page/form/contacts-form.component.ts index e79d9cb7d56ca52eb23fccf49ded7d0780e3e54a..fe4ad7200ce14700cceb6a6fb1983c93bcf264e7 100644 --- a/src/frontend/app/administration/contact/page/form/contacts-form.component.ts +++ b/src/frontend/app/administration/contact/page/form/contacts-form.component.ts @@ -517,8 +517,20 @@ export class ContactsFormComponent implements OnInit { if (field.id === 'addressPostcode') { this.postcodesFilteredResult = field.control.valueChanges .pipe( - startWith(''), - exhaustMap((value: string) => this.http.get('../rest/postcode?search=' + value)), + debounceTime(300), + filter((value: string) => value.length > 2), + distinctUntilChanged(), + exhaustMap((value: string) => this.http.get('../rest/autocomplete/postcodes?postcode=' + value)), + map((data: any) => data.postcodes), + ); + } + if (field.id === 'addressTown') { + this.postcodesFilteredResult = field.control.valueChanges + .pipe( + debounceTime(300), + filter((value: string) => value.length > 2), + distinctUntilChanged(), + exhaustMap((value: string) => this.http.get('../rest/autocomplete/postcodes?town=' + value)), map((data: any) => data.postcodes), ); }