counties, pagination, filter count, show total results
This commit is contained in:
@@ -125,7 +125,7 @@
|
||||
id="filterDropdownButton"
|
||||
class="max-sm:hidden px-4 py-2 text-sm font-medium text-gray-900 bg-white border border-gray-200 rounded-lg hover:bg-gray-100 hover:text-blue-700 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700 md:me-2"
|
||||
>
|
||||
<i class="fas fa-filter mr-2"></i>Filter (1)
|
||||
<i class="fas fa-filter mr-2"></i>Filter ({{ getNumberOfFiltersSet() }})
|
||||
</button>
|
||||
}
|
||||
<button
|
||||
@@ -242,7 +242,7 @@
|
||||
id="filterDropdownMobileButton"
|
||||
class="w-full mx-4 px-4 py-2 text-sm font-medium text-gray-900 bg-white border border-gray-200 rounded-lg hover:bg-gray-100 hover:text-blue-700 focus:ring-2 focus:ring-blue-700 focus:text-blue-700 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700"
|
||||
>
|
||||
<i class="fas fa-filter mr-2"></i>Filter (1)
|
||||
<i class="fas fa-filter mr-2"></i>Filter ({{ getNumberOfFiltersSet() }})
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -11,10 +11,11 @@ import { filter, Observable, Subject, Subscription } from 'rxjs';
|
||||
import { User } from '../../../../../bizmatch-server/src/models/db.model';
|
||||
import { BusinessListingCriteria, CommercialPropertyListingCriteria, emailToDirName, KeycloakUser, UserListingCriteria } from '../../../../../bizmatch-server/src/models/main.model';
|
||||
import { environment } from '../../../environments/environment';
|
||||
import { CriteriaChangeService } from '../../services/criteria-change.service';
|
||||
import { SearchService } from '../../services/search.service';
|
||||
import { SharedService } from '../../services/shared.service';
|
||||
import { UserService } from '../../services/user.service';
|
||||
import { getCriteriaStateObject, getSessionStorageHandlerWrapper, map2User } from '../../utils/utils';
|
||||
import { compareObjects, createEmptyBusinessListingCriteria, createEmptyCommercialPropertyListingCriteria, createEmptyUserListingCriteria, getCriteriaStateObject, map2User } from '../../utils/utils';
|
||||
import { DropdownComponent } from '../dropdown/dropdown.component';
|
||||
import { ModalService } from '../search-modal/modal.service';
|
||||
@Component({
|
||||
@@ -40,6 +41,7 @@ export class HeaderComponent {
|
||||
private subscription: Subscription;
|
||||
criteria: BusinessListingCriteria | CommercialPropertyListingCriteria | UserListingCriteria;
|
||||
private routerSubscription: Subscription | undefined;
|
||||
baseRoute: string;
|
||||
constructor(
|
||||
public keycloakService: KeycloakService,
|
||||
private router: Router,
|
||||
@@ -48,6 +50,7 @@ export class HeaderComponent {
|
||||
private breakpointObserver: BreakpointObserver,
|
||||
private modalService: ModalService,
|
||||
private searchService: SearchService,
|
||||
private criteriaChangeService: CriteriaChangeService,
|
||||
) {}
|
||||
|
||||
async ngOnInit() {
|
||||
@@ -75,18 +78,46 @@ export class HeaderComponent {
|
||||
});
|
||||
}
|
||||
private checkCurrentRoute(url: string): void {
|
||||
const baseRoute = url.split('/')[1]; // Nimmt den ersten Teil der Route nach dem ersten '/'
|
||||
this.baseRoute = url.split('/')[1]; // Nimmt den ersten Teil der Route nach dem ersten '/'
|
||||
const specialRoutes = [, '', ''];
|
||||
if ('businessListings' === baseRoute) {
|
||||
this.criteria = onChange(getCriteriaStateObject('business'), getSessionStorageHandlerWrapper('business'));
|
||||
} else if ('commercialPropertyListings' === baseRoute) {
|
||||
this.criteria = onChange(getCriteriaStateObject('commercialProperty'), getSessionStorageHandlerWrapper('commercialProperty'));
|
||||
} else if ('brokerListings' === baseRoute) {
|
||||
this.criteria = onChange(getCriteriaStateObject('broker'), getSessionStorageHandlerWrapper('broker'));
|
||||
if ('businessListings' === this.baseRoute) {
|
||||
//this.criteria = onChange(getCriteriaStateObject('business'), getSessionStorageHandlerWrapper('business'));
|
||||
//this.criteria = onChange(getCriteriaStateObject('business'), this.getSessionStorageHandler);
|
||||
this.criteria = this.createEnhancedProxy(getCriteriaStateObject('business'));
|
||||
} else if ('commercialPropertyListings' === this.baseRoute) {
|
||||
// this.criteria = onChange(getCriteriaStateObject('commercialProperty'), getSessionStorageHandlerWrapper('commercialProperty'));
|
||||
this.criteria = this.createEnhancedProxy(getCriteriaStateObject('commercialProperty'));
|
||||
} else if ('brokerListings' === this.baseRoute) {
|
||||
// this.criteria = onChange(getCriteriaStateObject('broker'), getSessionStorageHandlerWrapper('broker'));
|
||||
this.criteria = this.createEnhancedProxy(getCriteriaStateObject('broker'));
|
||||
} else {
|
||||
this.criteria = undefined;
|
||||
}
|
||||
}
|
||||
private createEnhancedProxy(obj: any) {
|
||||
const component = this;
|
||||
|
||||
const sessionStorageHandler = function (path, value, previous, applyData) {
|
||||
let criteriaType = '';
|
||||
if ('/businessListings' === window.location.pathname) {
|
||||
criteriaType = 'business';
|
||||
} else if ('/commercialPropertyListings' === window.location.pathname) {
|
||||
criteriaType = 'commercialProperty';
|
||||
} else if ('/brokerListings' === window.location.pathname) {
|
||||
criteriaType = 'broker';
|
||||
}
|
||||
sessionStorage.setItem(`${criteriaType}_criteria`, JSON.stringify(this));
|
||||
};
|
||||
|
||||
return onChange(obj, function (path, value, previous, applyData) {
|
||||
// Call the original sessionStorageHandler
|
||||
sessionStorageHandler.call(this, path, value, previous, applyData);
|
||||
|
||||
// Notify about the criteria change using the component's context
|
||||
component.criteriaChangeService.notifyCriteriaChange();
|
||||
});
|
||||
}
|
||||
|
||||
ngAfterViewInit() {}
|
||||
|
||||
async openModal() {
|
||||
@@ -94,13 +125,6 @@ export class HeaderComponent {
|
||||
if (accepted) {
|
||||
this.searchService.search(this.criteria);
|
||||
}
|
||||
// if (this.isActive('/businessListings')) {
|
||||
// this.modalService.showModal(createEmptyBusinessListingCriteria());
|
||||
// } else if (this.isActive('/commercialPropertyListings')) {
|
||||
// this.modalService.showModal(createEmptyCommercialPropertyListingCriteria());
|
||||
// } else if (this.isActive('/brokerListings')) {
|
||||
// this.modalService.showModal(createEmptyUserListingCriteria());
|
||||
// }
|
||||
}
|
||||
navigateWithState(dest: string, state: any) {
|
||||
this.router.navigate([dest], { state: state });
|
||||
@@ -146,4 +170,15 @@ export class HeaderComponent {
|
||||
this.destroy$.next();
|
||||
this.destroy$.complete();
|
||||
}
|
||||
getNumberOfFiltersSet() {
|
||||
if (this.criteria?.criteriaType === 'broker') {
|
||||
return compareObjects(createEmptyUserListingCriteria(), this.criteria, ['start', 'length', 'page']);
|
||||
} else if (this.criteria?.criteriaType === 'business') {
|
||||
return compareObjects(createEmptyBusinessListingCriteria(), this.criteria, ['start', 'length', 'page']);
|
||||
} else if (this.criteria?.criteriaType === 'commercialProperty') {
|
||||
return compareObjects(createEmptyCommercialPropertyListingCriteria(), this.criteria, ['start', 'length', 'page']);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user