diff --git a/bizmatch/src/app/components/search-modal/search-modal.component.ts b/bizmatch/src/app/components/search-modal/search-modal.component.ts index 8c35e98..81cdde7 100644 --- a/bizmatch/src/app/components/search-modal/search-modal.component.ts +++ b/bizmatch/src/app/components/search-modal/search-modal.component.ts @@ -22,11 +22,11 @@ import { ModalService } from './modal.service'; styleUrl: './search-modal.component.scss', }) export class SearchModalComponent { - cities$: Observable; + // cities$: Observable; counties$: Observable; - cityLoading = false; + // cityLoading = false; countyLoading = false; - cityInput$ = new Subject(); + // cityInput$ = new Subject(); countyInput$ = new Subject(); 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 diff --git a/bizmatch/src/app/components/validated-county/validated-county.component.html b/bizmatch/src/app/components/validated-county/validated-county.component.html new file mode 100644 index 0000000..82a0ab8 --- /dev/null +++ b/bizmatch/src/app/components/validated-county/validated-county.component.html @@ -0,0 +1,32 @@ +
+ @if(label){ + + } + + @for (county of counties$ | async; track county.id) { + {{ county }} + } + +
diff --git a/bizmatch/src/app/components/validated-county/validated-county.component.scss b/bizmatch/src/app/components/validated-county/validated-county.component.scss new file mode 100644 index 0000000..b27bb07 --- /dev/null +++ b/bizmatch/src/app/components/validated-county/validated-county.component.scss @@ -0,0 +1,9 @@ +:host ::ng-deep .ng-select.custom .ng-select-container { + // --tw-bg-opacity: 1; + // background-color: rgb(249 250 251 / var(--tw-bg-opacity)); + // height: 42px; + border-radius: 0.5rem; + .ng-value-container .ng-input { + top: 10px; + } +} diff --git a/bizmatch/src/app/components/validated-county/validated-county.component.ts b/bizmatch/src/app/components/validated-county/validated-county.component.ts new file mode 100644 index 0000000..2d666e3 --- /dev/null +++ b/bizmatch/src/app/components/validated-county/validated-county.component.ts @@ -0,0 +1,70 @@ +import { CommonModule } from '@angular/common'; +import { Component, forwardRef, Input } from '@angular/core'; +import { FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms'; +import { NgSelectModule } from '@ng-select/ng-select'; +import { catchError, concat, distinctUntilChanged, map, Observable, of, Subject, switchMap, tap } from 'rxjs'; +import { CountyResult, GeoResult } from '../../../../../bizmatch-server/src/models/main.model'; +import { City } from '../../../../../bizmatch-server/src/models/server.model'; +import { GeoService } from '../../services/geo.service'; +import { SelectOptionsService } from '../../services/select-options.service'; +import { BaseInputComponent } from '../base-input/base-input.component'; +import { TooltipComponent } from '../tooltip/tooltip.component'; +import { ValidationMessagesService } from '../validation-messages.service'; + +@Component({ + selector: 'app-validated-county', + standalone: true, + imports: [CommonModule, FormsModule, NgSelectModule, TooltipComponent], + templateUrl: './validated-county.component.html', + styleUrl: './validated-county.component.scss', + providers: [ + { + provide: NG_VALUE_ACCESSOR, + useExisting: forwardRef(() => ValidatedCountyComponent), + multi: true, + }, + ], +}) +export class ValidatedCountyComponent extends BaseInputComponent { + @Input() items; + @Input() labelClasses: string; + @Input() state: string; + @Input() readonly = false; + counties$: Observable; + countyLoading = false; + countyInput$ = new Subject(); + constructor(validationMessagesService: ValidationMessagesService, private geoService: GeoService, public selectOptions: SelectOptionsService) { + super(validationMessagesService); + } + + override ngOnInit() { + super.ngOnInit(); + this.loadCounties(); + } + onInputChange(event: City): void { + this.value = event; //{ ...event, longitude: parseFloat(event.longitude), latitude: parseFloat(event.latitude) }; + this.onChange(this.value); + } + private loadCounties() { + this.counties$ = concat( + of([]), // default items + this.countyInput$.pipe( + distinctUntilChanged(), + tap(() => (this.countyLoading = true)), + switchMap(term => + this.geoService.findCountiesStartingWith(term, this.state ? [this.state] : null).pipe( + catchError(() => of([])), // empty list on error + map(counties => counties.map(county => county.name)), // transform the list of objects to a list of city names + tap(() => (this.countyLoading = false)), + ), + ), + ), + ); + } + trackByFn(item: GeoResult) { + return item.id; + } + compareFn = (item, selected) => { + return item.id === selected.id; + }; +} diff --git a/bizmatch/src/app/pages/subscription/account/account.component.html b/bizmatch/src/app/pages/subscription/account/account.component.html index 2c72b5e..630cea5 100644 --- a/bizmatch/src/app/pages/subscription/account/account.component.html +++ b/bizmatch/src/app/pages/subscription/account/account.component.html @@ -158,10 +158,11 @@ @for (areasServed of user.areasServed; track areasServed; let i=$index){
- +
- + +
} diff --git a/bizmatch/src/app/pages/subscription/account/account.component.ts b/bizmatch/src/app/pages/subscription/account/account.component.ts index 5c7dec9..09a21a3 100644 --- a/bizmatch/src/app/pages/subscription/account/account.component.ts +++ b/bizmatch/src/app/pages/subscription/account/account.component.ts @@ -19,6 +19,7 @@ import { MessageComponent } from '../../../components/message/message.component' import { MessageService } from '../../../components/message/message.service'; import { TooltipComponent } from '../../../components/tooltip/tooltip.component'; import { ValidatedCityComponent } from '../../../components/validated-city/validated-city.component'; +import { ValidatedCountyComponent } from '../../../components/validated-county/validated-county.component'; import { ValidatedInputComponent } from '../../../components/validated-input/validated-input.component'; import { ValidatedQuillComponent } from '../../../components/validated-quill/validated-quill.component'; import { ValidatedSelectComponent } from '../../../components/validated-select/validated-select.component'; @@ -50,6 +51,7 @@ import { TOOLBAR_OPTIONS } from '../../utils/defaults'; ValidatedQuillComponent, ValidatedCityComponent, TooltipComponent, + ValidatedCountyComponent, ], providers: [TitleCasePipe], templateUrl: './account.component.html', @@ -237,4 +239,9 @@ export class AccountComponent { isAdmin() { return this.keycloakService.getUserRoles(true).includes('ADMIN'); } + setState(index: number, state: string) { + if (state === null) { + this.user.areasServed[index].county = null; + } + } } diff --git a/bizmatch/src/app/pages/subscription/edit-business-listing/edit-business-listing.component.html b/bizmatch/src/app/pages/subscription/edit-business-listing/edit-business-listing.component.html index 8736609..2f5bc69 100644 --- a/bizmatch/src/app/pages/subscription/edit-business-listing/edit-business-listing.component.html +++ b/bizmatch/src/app/pages/subscription/edit-business-listing/edit-business-listing.component.html @@ -166,7 +166,17 @@ -->
- +
+ + + + + @for (licensedIn of listingUser?.licensedIn; track listingUser?.licensedIn) { + {{ licensedIn.state }} {{ licensedIn.registerNo }} + } + +
+