From 4ed91227097a2cbb0fe9fb1dc5cc6342e86506a5 Mon Sep 17 00:00:00 2001 From: Smith Date: Wed, 18 Oct 2023 18:54:21 -0700 Subject: [PATCH] allow markers with no pids to be opened/viewed. --- .../common/mapFSM/MapStateMachineContext.tsx | 2 +- .../common/mapFSM/useLocationFeatureLoader.tsx | 12 +++++++++++- source/frontend/src/constants/API.ts | 1 + .../mapSideBar/property/MotiInventoryContainer.tsx | 3 ++- source/frontend/src/hooks/layer-api/layerUtils.ts | 5 ++++- .../src/hooks/repositories/useMapProperties.tsx | 1 + 6 files changed, 20 insertions(+), 4 deletions(-) diff --git a/source/frontend/src/components/common/mapFSM/MapStateMachineContext.tsx b/source/frontend/src/components/common/mapFSM/MapStateMachineContext.tsx index 4af97f3df4..8c1e9a30ff 100644 --- a/source/frontend/src/components/common/mapFSM/MapStateMachineContext.tsx +++ b/source/frontend/src/components/common/mapFSM/MapStateMachineContext.tsx @@ -101,7 +101,7 @@ export const MapStateMachineProvider: React.FC> } else if (event.type === 'MAP_MARKER_CLICK') { latLng = event.featureSelected.latlng; } - const result = locationLoader.loadLocationDetails(latLng); + const result = locationLoader.loadLocationDetails(latLng, event.featureSelected); return result; }, diff --git a/source/frontend/src/components/common/mapFSM/useLocationFeatureLoader.tsx b/source/frontend/src/components/common/mapFSM/useLocationFeatureLoader.tsx index 7ba9862365..1a4857870b 100644 --- a/source/frontend/src/components/common/mapFSM/useLocationFeatureLoader.tsx +++ b/source/frontend/src/components/common/mapFSM/useLocationFeatureLoader.tsx @@ -12,6 +12,8 @@ import { WHSE_Municipalities_Feature_Properties } from '@/models/layers/municipa import { PMBC_FullyAttributed_Feature_Properties } from '@/models/layers/parcelMapBC'; import { PIMS_Property_Location_View } from '@/models/layers/pimsPropertyLocationView'; +import { FeatureSelected } from './models'; + export interface LocationFeatureDataset { location: LatLngLiteral; pimsFeature: Feature | null; @@ -37,7 +39,10 @@ const useLocationFeatureLoader = () => { adminLegalBoundaryLayerService.findOneMunicipality; const loadLocationDetails = useCallback( - async (latLng: LatLngLiteral): Promise => { + async ( + latLng: LatLngLiteral, + selectedFeature: FeatureSelected, + ): Promise => { const result: LocationFeatureDataset = { location: latLng, pimsFeature: null, @@ -63,6 +68,11 @@ const useLocationFeatureLoader = () => { | undefined = undefined; // Load PimsProperties + if (selectedFeature?.pimsLocationFeature?.PROPERTY_ID) { + pimsLocationProperties = await loadProperties({ + PROPERTY_ID: selectedFeature.pimsLocationFeature.PROPERTY_ID, + }); + } if (parcelFeature !== undefined) { pimsLocationProperties = await loadProperties({ PID: parcelFeature.properties?.PID || '', diff --git a/source/frontend/src/constants/API.ts b/source/frontend/src/constants/API.ts index 969bfbcd97..55a5236259 100644 --- a/source/frontend/src/constants/API.ts +++ b/source/frontend/src/constants/API.ts @@ -45,6 +45,7 @@ export interface IGeoSearchParams { PIN?: string; SURVEY_PLAN_NUMBER?: string; BBOX?: string; + PROPERTY_ID?: string; latitude?: number | string; longitude?: number | string; forceExactMatch?: boolean; diff --git a/source/frontend/src/features/mapSideBar/property/MotiInventoryContainer.tsx b/source/frontend/src/features/mapSideBar/property/MotiInventoryContainer.tsx index 98ba1c246b..7e59b96a06 100644 --- a/source/frontend/src/features/mapSideBar/property/MotiInventoryContainer.tsx +++ b/source/frontend/src/features/mapSideBar/property/MotiInventoryContainer.tsx @@ -36,7 +36,8 @@ export const MotiInventoryContainer: React.FunctionComponent< const composedPropertyState = useComposedProperties({ id: props.id, - pid: props?.pid === undefined || isNaN(+props.pid) ? undefined : +props.pid, + pid: + props?.pid === undefined || props?.pid === '' || isNaN(+props.pid) ? undefined : +props.pid, propertyTypes: [ PROPERTY_TYPES.ASSOCIATIONS, PROPERTY_TYPES.LTSA, diff --git a/source/frontend/src/hooks/layer-api/layerUtils.ts b/source/frontend/src/hooks/layer-api/layerUtils.ts index b15db238e4..cba5bfca02 100644 --- a/source/frontend/src/hooks/layer-api/layerUtils.ts +++ b/source/frontend/src/hooks/layer-api/layerUtils.ts @@ -23,7 +23,10 @@ export const toCqlFilterValue = (object: Record, flags?: IWfsCql const cql: string[] = []; Object.keys(object).forEach((key: string) => { if (object[key]) { - if ( + if (key === 'PROPERTY_ID') { + cql.push(`${key} = '${object[key]}'`); + return; + } else if ( ((key === 'PID' || key === 'PID_PADDED') && object[key]?.length === 9) || flags?.forceExactMatch ) { diff --git a/source/frontend/src/hooks/repositories/useMapProperties.tsx b/source/frontend/src/hooks/repositories/useMapProperties.tsx index c7fdf17c13..4334db974d 100644 --- a/source/frontend/src/hooks/repositories/useMapProperties.tsx +++ b/source/frontend/src/hooks/repositories/useMapProperties.tsx @@ -20,6 +20,7 @@ export const useMapProperties = () => { STREET_ADDRESS_1: params?.STREET_ADDRESS_1, PID_PADDED: params?.PID?.replace(/[-\s]/g, ''), PIN: params?.PIN, + PROPERTY_ID: params?.PROPERTY_ID, }; const url = `${propertiesUrl}${ geoserver_params ? toCqlFilter(geoserver_params, params?.forceExactMatch) : ''