location eingebaut, back buttons angeglichen, paging & criteria korrigiert

This commit is contained in:
2024-08-08 17:25:00 +02:00
parent 7df5d32cc4
commit 69b0a83b1e
21 changed files with 196 additions and 328 deletions

View File

@@ -97,7 +97,7 @@ export function createEmptyBusinessListingCriteria(): BusinessListingCriteria {
city: '',
types: [],
prompt: '',
criteriaType: 'business',
criteriaType: 'businessListings',
minPrice: null,
maxPrice: null,
minRevenue: null,
@@ -127,7 +127,7 @@ export function createEmptyCommercialPropertyListingCriteria(): CommercialProper
city: '',
types: [],
prompt: '',
criteriaType: 'commercialProperty',
criteriaType: 'commercialPropertyListings',
minPrice: null,
maxPrice: null,
title: '',
@@ -144,7 +144,7 @@ export function createEmptyUserListingCriteria(): UserListingCriteria {
city: '',
types: [],
prompt: '',
criteriaType: 'broker',
criteriaType: 'brokerListings',
firstname: '',
lastname: '',
companyName: '',
@@ -184,16 +184,16 @@ export const getSessionStorageHandlerWrapper = param => {
};
};
export function getCriteriaStateObject(criteriaType: 'business' | 'commercialProperty' | 'broker') {
export function getCriteriaStateObject(criteriaType: 'businessListings' | 'commercialPropertyListings' | 'brokerListings') {
let initialState;
if (criteriaType === 'business') {
if (criteriaType === 'businessListings') {
initialState = createEmptyBusinessListingCriteria();
} else if (criteriaType === 'commercialProperty') {
} else if (criteriaType === 'commercialPropertyListings') {
initialState = createEmptyCommercialPropertyListingCriteria();
} else {
initialState = createEmptyUserListingCriteria();
}
const storedState = sessionStorage.getItem(`${criteriaType}_criteria`);
const storedState = sessionStorage.getItem(`${criteriaType}`);
return storedState ? JSON.parse(storedState) : initialState;
}
@@ -242,6 +242,7 @@ export function getDialogWidth(dimensions): string {
}
import { initFlowbite } from 'flowbite';
import onChange from 'on-change';
import { Subject, concatMap, delay, of } from 'rxjs';
const flowbiteQueue = new Subject<() => void>();
@@ -370,3 +371,41 @@ function arraysEqual(arr1: any[] | null | undefined, arr2: any[] | null | undefi
}
return true;
}
// -----------------------------
// Criteria Proxy
// -----------------------------
export function getCriteriaProxy(path: string, component: any): BusinessListingCriteria | CommercialPropertyListingCriteria | UserListingCriteria {
if ('businessListings' === path) {
return createEnhancedProxy(getCriteriaStateObject('businessListings'), component);
} else if ('commercialPropertyListings' === path) {
return createEnhancedProxy(getCriteriaStateObject('commercialPropertyListings'), component);
} else if ('brokerListings' === path) {
return createEnhancedProxy(getCriteriaStateObject('brokerListings'), component);
} else {
return undefined;
}
}
export function createEnhancedProxy(obj: BusinessListingCriteria | CommercialPropertyListingCriteria | UserListingCriteria, component: 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(`${obj.criteriaType}`, 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();
});
}