location eingebaut, back buttons angeglichen, paging & criteria korrigiert
This commit is contained in:
@@ -206,7 +206,7 @@
|
||||
[ngClass]="{ 'bg-blue-700 text-white md:text-blue-700 md:bg-transparent md:dark:text-blue-500': isActive('/businessListings') }"
|
||||
class="block py-2 px-3 rounded hover:bg-gray-100 md:hover:bg-transparent md:hover:text-blue-700 md:p-0 dark:text-white md:dark:hover:text-blue-500 dark:hover:bg-gray-700 dark:hover:text-white md:dark:hover:bg-transparent dark:border-gray-700"
|
||||
aria-current="page"
|
||||
(click)="closeMenus()"
|
||||
(click)="closeMenusAndSetCriteria('businessListings')"
|
||||
>Businesses</a
|
||||
>
|
||||
</li>
|
||||
@@ -216,7 +216,7 @@
|
||||
routerLink="/commercialPropertyListings"
|
||||
[ngClass]="{ 'bg-blue-700 text-white md:text-blue-700 md:bg-transparent md:dark:text-blue-500': isActive('/commercialPropertyListings') }"
|
||||
class="block py-2 px-3 rounded hover:bg-gray-100 md:hover:bg-transparent md:hover:text-blue-700 md:p-0 dark:text-white md:dark:hover:text-blue-500 dark:hover:bg-gray-700 dark:hover:text-white md:dark:hover:bg-transparent dark:border-gray-700"
|
||||
(click)="closeMenus()"
|
||||
(click)="closeMenusAndSetCriteria('commercialPropertyListings')"
|
||||
>Properties</a
|
||||
>
|
||||
</li>
|
||||
@@ -226,7 +226,7 @@
|
||||
routerLink="/brokerListings"
|
||||
[ngClass]="{ 'bg-blue-700 text-white md:text-blue-700 md:bg-transparent md:dark:text-blue-500': isActive('/brokerListings') }"
|
||||
class="block py-2 px-3 rounded hover:bg-gray-100 md:hover:bg-transparent md:hover:text-blue-700 md:p-0 dark:text-white md:dark:hover:text-blue-500 dark:hover:bg-gray-700 dark:hover:text-white md:dark:hover:bg-transparent dark:border-gray-700"
|
||||
(click)="closeMenus()"
|
||||
(click)="closeMenusAndSetCriteria('brokerListings')"
|
||||
>Professionals</a
|
||||
>
|
||||
</li>
|
||||
@@ -247,141 +247,3 @@
|
||||
</div>
|
||||
}
|
||||
</nav>
|
||||
|
||||
<!-- ############################### -->
|
||||
<!-- Filter Dropdown -->
|
||||
<!-- ############################### -->
|
||||
<!-- <app-dropdown [triggerEl]="triggerButton" [triggerType]="'click'">
|
||||
<div id="filterDropdown" class="z-[50] w-80 p-3 bg-slate-200 rounded-lg shadow-lg dark:bg-gray-700">
|
||||
<div class="mb-4">
|
||||
<label for="price-range" class="block text-sm font-medium text-gray-900 dark:text-white">Price Range</label>
|
||||
<div class="flex items-center space-x-4">
|
||||
<input
|
||||
type="number"
|
||||
id="price-from"
|
||||
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
||||
placeholder="From"
|
||||
value="300"
|
||||
/>
|
||||
<input
|
||||
type="number"
|
||||
id="price-to"
|
||||
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
||||
placeholder="To"
|
||||
value="3500"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<label for="sales-range" class="block text-sm font-medium text-gray-900 dark:text-white">Sales Revenue</label>
|
||||
<div class="flex items-center space-x-4">
|
||||
<input
|
||||
type="number"
|
||||
id="sales-from"
|
||||
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
||||
placeholder="From"
|
||||
value="1"
|
||||
/>
|
||||
<input
|
||||
type="number"
|
||||
id="sales-to"
|
||||
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
||||
placeholder="To"
|
||||
value="100"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<label class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Category</label>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<button
|
||||
class="px-3 py-1 text-sm font-medium text-gray-900 bg-white border border-gray-200 rounded-lg hover:bg-gray-100 hover:text-blue-700 focus:z-10 focus:ring-2 focus:ring-blue-700 focus:text-blue-700 dark:bg-gray-700 dark:border-gray-600 dark:text-white dark:hover:text-white dark:hover:bg-gray-600 dark:focus:ring-blue-500 dark:focus:text-white"
|
||||
>
|
||||
Gaming
|
||||
</button>
|
||||
<button
|
||||
class="px-3 py-1 text-sm font-medium text-gray-900 bg-white border border-gray-200 rounded-lg hover:bg-gray-100 hover:text-blue-700 focus:z-10 focus:ring-2 focus:ring-blue-700 focus:text-blue-700 dark:bg-gray-700 dark:border-gray-600 dark:text-white dark:hover:text-white dark:hover:bg-gray-600 dark:focus:ring-blue-500 dark:focus:text-white"
|
||||
>
|
||||
Electronics
|
||||
</button>
|
||||
<button
|
||||
class="px-3 py-1 text-sm font-medium text-white bg-blue-700 border border-blue-700 rounded-lg hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 dark:bg-blue-600 dark:hover:bg-blue-700 focus:outline-none dark:focus:ring-blue-800"
|
||||
>
|
||||
Phone
|
||||
</button>
|
||||
<button
|
||||
class="px-3 py-1 text-sm font-medium text-white bg-blue-700 border border-blue-700 rounded-lg hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 dark:bg-blue-600 dark:hover:bg-blue-700 focus:outline-none dark:focus:ring-blue-800"
|
||||
>
|
||||
TV/Monitor
|
||||
</button>
|
||||
<button
|
||||
class="px-3 py-1 text-sm font-medium text-gray-900 bg-white border border-gray-200 rounded-lg hover:bg-gray-100 hover:text-blue-700 focus:z-10 focus:ring-2 focus:ring-blue-700 focus:text-blue-700 dark:bg-gray-700 dark:border-gray-600 dark:text-white dark:hover:text-white dark:hover:bg-gray-600 dark:focus:ring-blue-500 dark:focus:text-white"
|
||||
>
|
||||
Laptop
|
||||
</button>
|
||||
<button
|
||||
class="px-3 py-1 text-sm font-medium text-white bg-blue-700 border border-blue-700 rounded-lg hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 dark:bg-blue-600 dark:hover:bg-blue-700 focus:outline-none dark:focus:ring-blue-800"
|
||||
>
|
||||
Watch
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<label class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">State</label>
|
||||
<ul class="w-48 text-sm font-medium text-gray-900 bg-white border border-gray-200 rounded-lg dark:bg-gray-700 dark:border-gray-600 dark:text-white">
|
||||
<li class="w-full border-b border-gray-200 rounded-t-lg dark:border-gray-600">
|
||||
<div class="flex items-center ps-3">
|
||||
<input
|
||||
id="state-all"
|
||||
type="radio"
|
||||
value="all"
|
||||
name="state"
|
||||
class="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-700 dark:focus:ring-offset-gray-700 focus:ring-2 dark:bg-gray-600 dark:border-gray-500"
|
||||
checked
|
||||
/>
|
||||
<label for="state-all" class="w-full py-3 ms-2 text-sm font-medium text-gray-900 dark:text-gray-300">All</label>
|
||||
</div>
|
||||
</li>
|
||||
<li class="w-full border-b border-gray-200 rounded-t-lg dark:border-gray-600">
|
||||
<div class="flex items-center ps-3">
|
||||
<input
|
||||
id="state-new"
|
||||
type="radio"
|
||||
value="new"
|
||||
name="state"
|
||||
class="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-700 dark:focus:ring-offset-gray-700 focus:ring-2 dark:bg-gray-600 dark:border-gray-500"
|
||||
/>
|
||||
<label for="state-new" class="w-full py-3 ms-2 text-sm font-medium text-gray-900 dark:text-gray-300">New</label>
|
||||
</div>
|
||||
</li>
|
||||
<li class="w-full border-b border-gray-200 rounded-t-lg dark:border-gray-600">
|
||||
<div class="flex items-center ps-3">
|
||||
<input
|
||||
id="state-refurbished"
|
||||
type="radio"
|
||||
value="refurbished"
|
||||
name="state"
|
||||
class="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-700 dark:focus:ring-offset-gray-700 focus:ring-2 dark:bg-gray-600 dark:border-gray-500"
|
||||
/>
|
||||
<label for="state-refurbished" class="w-full py-3 ms-2 text-sm font-medium text-gray-900 dark:text-gray-300">Refurbished</label>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-between">
|
||||
<button
|
||||
type="button"
|
||||
class="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 dark:bg-blue-600 dark:hover:bg-blue-700 focus:outline-none dark:focus:ring-blue-800"
|
||||
>
|
||||
Show 32 Results
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="py-2.5 px-5 text-sm font-medium text-gray-900 focus:outline-none bg-white rounded-lg border border-gray-200 hover:bg-gray-100 hover:text-blue-700 focus:z-10 focus:ring-4 focus:ring-gray-200 dark:focus:ring-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700"
|
||||
>
|
||||
Reset
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</app-dropdown> -->
|
||||
|
||||
@@ -6,7 +6,6 @@ import { NavigationEnd, Router, RouterModule } from '@angular/router';
|
||||
import { faUserGear } from '@fortawesome/free-solid-svg-icons';
|
||||
import { Collapse, Dropdown, initFlowbite } from 'flowbite';
|
||||
import { KeycloakService } from 'keycloak-angular';
|
||||
import onChange from 'on-change';
|
||||
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';
|
||||
@@ -15,7 +14,7 @@ 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 { compareObjects, createEmptyBusinessListingCriteria, createEmptyCommercialPropertyListingCriteria, createEmptyUserListingCriteria, getCriteriaStateObject, map2User } from '../../utils/utils';
|
||||
import { compareObjects, createEmptyBusinessListingCriteria, createEmptyCommercialPropertyListingCriteria, createEmptyUserListingCriteria, getCriteriaProxy, map2User } from '../../utils/utils';
|
||||
import { DropdownComponent } from '../dropdown/dropdown.component';
|
||||
import { ModalService } from '../search-modal/modal.service';
|
||||
@Component({
|
||||
@@ -80,43 +79,43 @@ export class HeaderComponent {
|
||||
private checkCurrentRoute(url: string): void {
|
||||
this.baseRoute = url.split('/')[1]; // Nimmt den ersten Teil der Route nach dem ersten '/'
|
||||
const specialRoutes = [, '', ''];
|
||||
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;
|
||||
}
|
||||
this.criteria = getCriteriaProxy(this.baseRoute, this);
|
||||
this.searchService.search(this.criteria);
|
||||
}
|
||||
private createEnhancedProxy(obj: any) {
|
||||
const component = this;
|
||||
// getCriteriaProxy(path:string):BusinessListingCriteria | CommercialPropertyListingCriteria | UserListingCriteria{
|
||||
// if ('businessListings' === path) {
|
||||
// return this.createEnhancedProxy(getCriteriaStateObject('business'));
|
||||
// } else if ('commercialPropertyListings' === path) {
|
||||
// return this.createEnhancedProxy(getCriteriaStateObject('commercialProperty'));
|
||||
// } else if ('brokerListings' === path) {
|
||||
// return this.createEnhancedProxy(getCriteriaStateObject('broker'));
|
||||
// } else {
|
||||
// return 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));
|
||||
};
|
||||
// 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);
|
||||
// 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();
|
||||
});
|
||||
}
|
||||
// // Notify about the criteria change using the component's context
|
||||
// component.criteriaChangeService.notifyCriteriaChange();
|
||||
// });
|
||||
// }
|
||||
|
||||
ngAfterViewInit() {}
|
||||
|
||||
@@ -161,9 +160,12 @@ export class HeaderComponent {
|
||||
collapse.collapse();
|
||||
}
|
||||
}
|
||||
closeMenus() {
|
||||
closeMenusAndSetCriteria(path: string) {
|
||||
this.closeDropdown();
|
||||
this.closeMobileMenu();
|
||||
const criteria = getCriteriaProxy(path, this);
|
||||
criteria.page = 1;
|
||||
criteria.start = 0;
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
@@ -171,11 +173,11 @@ export class HeaderComponent {
|
||||
this.destroy$.complete();
|
||||
}
|
||||
getNumberOfFiltersSet() {
|
||||
if (this.criteria?.criteriaType === 'broker') {
|
||||
if (this.criteria?.criteriaType === 'brokerListings') {
|
||||
return compareObjects(createEmptyUserListingCriteria(), this.criteria, ['start', 'length', 'page', 'searchType', 'radius']);
|
||||
} else if (this.criteria?.criteriaType === 'business') {
|
||||
} else if (this.criteria?.criteriaType === 'businessListings') {
|
||||
return compareObjects(createEmptyBusinessListingCriteria(), this.criteria, ['start', 'length', 'page', 'searchType', 'radius']);
|
||||
} else if (this.criteria?.criteriaType === 'commercialProperty') {
|
||||
} else if (this.criteria?.criteriaType === 'commercialPropertyListings') {
|
||||
return compareObjects(createEmptyCommercialPropertyListingCriteria(), this.criteria, ['start', 'length', 'page', 'searchType', 'radius']);
|
||||
} else {
|
||||
return 0;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<button class="text-blue-600 font-medium border-b-2 border-blue-600 pb-2">Classic Search</button>
|
||||
<button class="text-gray-500">AI Search <span class="bg-gray-200 text-xs font-semibold px-2 py-1 rounded">BETA</span></button>
|
||||
</div>
|
||||
@if(criteria.criteriaType==='business'){
|
||||
@if(criteria.criteriaType==='businessListings'){
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||
<div class="space-y-4">
|
||||
<div>
|
||||
@@ -233,7 +233,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
} @if(criteria.criteriaType==='commercialProperty'){
|
||||
} @if(criteria.criteriaType==='commercialPropertyListings'){
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||
<div class="space-y-4">
|
||||
<div>
|
||||
@@ -341,7 +341,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
} @if(criteria.criteriaType==='broker'){
|
||||
} @if(criteria.criteriaType==='brokerListings'){
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||
<div class="space-y-4">
|
||||
<div>
|
||||
|
||||
@@ -46,6 +46,7 @@ export class SearchModalComponent {
|
||||
this.modalService.modalVisible$.pipe(untilDestroyed(this)).subscribe(val => {
|
||||
if (val) {
|
||||
this.criteria.page = 1;
|
||||
this.criteria.start = 0;
|
||||
}
|
||||
});
|
||||
this.loadCities();
|
||||
@@ -137,9 +138,9 @@ export class SearchModalComponent {
|
||||
setTotalNumberOfResults() {
|
||||
if (this.criteria) {
|
||||
console.log(`Getting total number of results for ${this.criteria.criteriaType}`);
|
||||
if (this.criteria.criteriaType === 'business' || this.criteria.criteriaType === 'commercialProperty') {
|
||||
this.numberOfResults$ = this.listingService.getNumberOfListings(this.criteria, this.criteria.criteriaType);
|
||||
} else if (this.criteria.criteriaType === 'broker') {
|
||||
if (this.criteria.criteriaType === 'businessListings' || this.criteria.criteriaType === 'commercialPropertyListings') {
|
||||
this.numberOfResults$ = this.listingService.getNumberOfListings(this.criteria, this.criteria.criteriaType === 'businessListings' ? 'business' : 'commercialProperty');
|
||||
} else if (this.criteria.criteriaType === 'brokerListings') {
|
||||
this.numberOfResults$ = this.userService.getNumberOfBroker(this.criteria);
|
||||
} else {
|
||||
this.numberOfResults$ = of();
|
||||
|
||||
Reference in New Issue
Block a user