This commit is contained in:
@@ -3,7 +3,7 @@ import { ChangeDetectorRef, Component } from '@angular/core';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { ActivatedRoute, Router, RouterModule } from '@angular/router';
|
||||
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
|
||||
import { BusinessListing, User } from '../../../../../../bizmatch-server/src/models/db.model';
|
||||
import { BusinessListing, SortByOptions, User } from '../../../../../../bizmatch-server/src/models/db.model';
|
||||
import { LISTINGS_PER_PAGE, ListingType, UserListingCriteria, emailToDirName } from '../../../../../../bizmatch-server/src/models/main.model';
|
||||
import { environment } from '../../../../environments/environment';
|
||||
import { CustomerSubTypeComponent } from '../../../components/customer-sub-type/customer-sub-type.component';
|
||||
@@ -45,6 +45,7 @@ export class BrokerListingsComponent {
|
||||
emailToDirName = emailToDirName;
|
||||
page = 1;
|
||||
pageCount = 1;
|
||||
sortBy: SortByOptions = null; // Neu: Separate Property
|
||||
constructor(
|
||||
public selectOptions: SelectOptionsService,
|
||||
private listingsService: ListingsService,
|
||||
@@ -60,13 +61,19 @@ export class BrokerListingsComponent {
|
||||
) {
|
||||
this.criteria = getCriteriaProxy('brokerListings', this) as UserListingCriteria;
|
||||
this.init();
|
||||
this.searchService.currentCriteria.pipe(untilDestroyed(this)).subscribe(criteria => {
|
||||
if (criteria && criteria.criteriaType === 'brokerListings') {
|
||||
this.loadSortBy();
|
||||
this.searchService.currentCriteria.pipe(untilDestroyed(this)).subscribe(({ criteria, sortBy }) => {
|
||||
if (criteria.criteriaType === 'brokerListings') {
|
||||
this.criteria = criteria as UserListingCriteria;
|
||||
this.sortBy = sortBy || this.sortBy || null;
|
||||
this.search();
|
||||
}
|
||||
});
|
||||
}
|
||||
private loadSortBy() {
|
||||
const storedSortBy = sessionStorage.getItem('professionalsSortBy');
|
||||
this.sortBy = storedSortBy && storedSortBy !== 'null' ? (storedSortBy as SortByOptions) : null;
|
||||
}
|
||||
async ngOnInit() {}
|
||||
async init() {
|
||||
this.search();
|
||||
@@ -101,14 +108,14 @@ export class BrokerListingsComponent {
|
||||
this.criteriaChangeService.notifyCriteriaChange();
|
||||
|
||||
// Search with cleared filters
|
||||
this.searchService.search(this.criteria);
|
||||
this.searchService.search('brokerListings');
|
||||
}
|
||||
|
||||
async openFilterModal() {
|
||||
// Open the search modal with current criteria
|
||||
const modalResult = await this.modalService.showModal(this.criteria);
|
||||
if (modalResult.accepted) {
|
||||
this.searchService.search(this.criteria);
|
||||
this.searchService.search('brokerListings');
|
||||
} else {
|
||||
this.criteria = assignProperties(this.criteria, modalResult.criteria);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user