Fixes for #36 and #72

This commit is contained in:
2024-08-14 19:47:19 +02:00
parent a8bb163acf
commit 7f756a71e8
8 changed files with 155 additions and 25 deletions

View File

@@ -22,11 +22,11 @@ import { ModalService } from './modal.service';
styleUrl: './search-modal.component.scss',
})
export class SearchModalComponent {
cities$: Observable<GeoResult[]>;
// cities$: Observable<GeoResult[]>;
counties$: Observable<CountyResult[]>;
cityLoading = false;
// cityLoading = false;
countyLoading = false;
cityInput$ = new Subject<string>();
// cityInput$ = new Subject<string>();
countyInput$ = new Subject<string>();
private criteriaChangeSubscription: Subscription;
public criteria: BusinessListingCriteria | CommercialPropertyListingCriteria | UserListingCriteria;
@@ -54,7 +54,7 @@ export class SearchModalComponent {
this.criteria.start = 0;
}
});
this.loadCities();
// this.loadCities();
this.loadCounties();
}
@@ -71,22 +71,22 @@ export class SearchModalComponent {
}
}
}
private loadCities() {
this.cities$ = concat(
of([]), // default items
this.cityInput$.pipe(
distinctUntilChanged(),
tap(() => (this.cityLoading = true)),
switchMap(term =>
this.geoService.findCitiesStartingWith(term).pipe(
catchError(() => of([])), // empty list on error
// map(cities => cities.map(city => city.city)), // transform the list of objects to a list of city names
tap(() => (this.cityLoading = false)),
),
),
),
);
}
// private loadCities() {
// this.cities$ = concat(
// of([]), // default items
// this.cityInput$.pipe(
// distinctUntilChanged(),
// tap(() => (this.cityLoading = true)),
// switchMap(term =>
// this.geoService.findCitiesStartingWith(term).pipe(
// catchError(() => of([])), // empty list on error
// // map(cities => cities.map(city => city.city)), // transform the list of objects to a list of city names
// tap(() => (this.cityLoading = false)),
// ),
// ),
// ),
// );
// }
private loadCounties() {
this.counties$ = concat(
of([]), // default items