Skip to content

Commit

Permalink
Merge branch 'feature/AB#17270' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefwint committed Jun 18, 2024
2 parents 7770a15 + dcd2fdd commit 50ef813
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 29 deletions.
2 changes: 1 addition & 1 deletion src/api/axiosGeoJSON.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const getGeoJsonData = async (
service: 'wfs',
version: api_version,
request: 'GetFeature',
typeNames: `Omgevingsbeleid:${type}`,
typeNames: getGeoserverLayer(),
cql_filter: `UUID='${UUID}'`,
outputFormat: 'application/json',
}
Expand Down
23 changes: 13 additions & 10 deletions src/components/DynamicObject/ObjectRevision/ObjectRevision.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ const ObjectRevision = ({
)
})}

{(!!compareA.Gebied || !!compareB.Gebied) && (
{(!!compareA.Werkingsgebied_Statics ||
!!compareB.Werkingsgebied_Statics) && (
<>
<Divider className="mb-6 mt-0" />

Expand All @@ -100,22 +101,24 @@ const ObjectRevision = ({
</Heading>

<Text className="mb-3">
{compareA.Gebied?.UUID === compareB.Gebied?.UUID
? `Het gebied '${compareA.Gebied?.Title}' in ${singularReadable} '${compareA.Title}' is ongewijzigd.`
: !!compareA.Gebied?.UUID && !!compareB.Gebied?.UUID
? `${singularCapitalize} '${compareA.Title}' is gewijzigd van gebied '${compareA.Gebied?.Title}' naar gebied '${compareB.Gebied?.Title}'`
: !!compareA.Gebied?.UUID
? `Het gebied '${compareA.Gebied?.Title}' in ${singularReadable} '${compareA.Title}' is verwijderd.`
: `Het gebied '${compareB.Gebied?.Title}' in ${singularReadable} '${compareA.Title}' is toegevoegd.`}
{compareA.Werkingsgebied_Statics?.Object_ID ===
compareB.Werkingsgebied_Statics?.Object_ID
? `Het gebied '${compareA.Werkingsgebied_Statics?.Cached_Title}' in ${singularReadable} '${compareA.Title}' is ongewijzigd.`
: !!compareA.Werkingsgebied_Statics?.Object_ID &&
!!compareB.Werkingsgebied_Statics?.Object_ID
? `${singularCapitalize} '${compareA.Title}' is gewijzigd van gebied '${compareA.Werkingsgebied_Statics?.Cached_Title}' naar gebied '${compareB.Werkingsgebied_Statics?.Cached_Title}'`
: !!compareA.Werkingsgebied_Statics?.Object_ID
? `Het gebied '${compareA.Werkingsgebied_Statics?.Cached_Title}' in ${singularReadable} '${compareA.Title}' is verwijderd.`
: `Het gebied '${compareB.Werkingsgebied_Statics?.Cached_Title}' in ${singularReadable} '${compareA.Title}' is toegevoegd.`}
</Text>

<div className="h-[320px] overflow-hidden rounded-lg">
<LeafletRevisionOverview
id={`revision-map-${initialObject?.UUID}`}
area={{
type: 'Werkingsgebieden',
old: compareB.Gebied?.UUID,
new: compareA.Gebied?.UUID,
old: compareB.Werkingsgebied_Statics?.Object_ID,
new: compareA.Werkingsgebied_Statics?.Object_ID,
}}
/>
</div>
Expand Down
5 changes: 1 addition & 4 deletions src/components/Leaflet/LeafletLayers/LeafletAreaLayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ const LeafletAreaLayer = ({
}}
/>

<span>
{layer.feature.properties.Onderverdeling ||
layer.feature.properties.Werkingsgebied}
</span>
<span>{layer.feature.properties.Source_Title}</span>
</div>
<div className="ml-2 flex w-5 align-middle">
{isActive ? <Eye size={18} /> : <EyeSlash size={18} />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useCallback, useEffect, useMemo, useState } from 'react'
import { useMap } from 'react-leaflet'

import { getGeoJsonData } from '@/api/axiosGeoJSON'
import { useWerkingsgebiedenLatestLineageIdGet } from '@/api/fetchers'
import ToggleableSection from '@/components/ToggleableSection'

import { LeafletAreaLayer, LeafletControlLayer } from '../LeafletLayers'
Expand All @@ -16,8 +17,8 @@ import LeafletMap from '../LeafletMap'

interface LeafletRevisionOverviewProps {
area: {
old?: string
new?: string
old?: number
new?: number
type: string
}
id?: string
Expand Down Expand Up @@ -49,17 +50,31 @@ const LeafletRevisionOverviewInner = ({

const [werkingsgebied, setWerkingsgebied] = useState<any[]>([])

const { data: oldUUID } = useWerkingsgebiedenLatestLineageIdGet(area.old!, {
query: {
enabled: !!area.old,
select: data => data.Area_UUID,
},
})

const { data: newUUID } = useWerkingsgebiedenLatestLineageIdGet(area.new!, {
query: {
enabled: !!area.new,
select: data => data.Area_UUID,
},
})

const geoQueries = useQueries({
queries: [
{
queryKey: ['mainDataFrom', area.type, area.old],
queryFn: () => getGeoJsonData(area.type, area.old!, { signal }),
enabled: !!area.type && !!area.old,
queryKey: ['mainDataFrom', area.type, oldUUID],
queryFn: () => getGeoJsonData(area.type, oldUUID!, { signal }),
enabled: !!area.type && !!oldUUID,
},
{
queryKey: ['mainDataTo', area.type, area.new],
queryFn: () => getGeoJsonData(area.type, area.new!, { signal }),
enabled: !!area.type && !!area.new && area.old !== area.new,
queryKey: ['mainDataTo', area.type, newUUID],
queryFn: () => getGeoJsonData(area.type, newUUID!, { signal }),
enabled: !!area.type && !!newUUID && area.old !== area.new,
},
],
})
Expand Down Expand Up @@ -95,8 +110,8 @@ const LeafletRevisionOverviewInner = ({
onEachFeature: (feature, layer) => {
if (feature.properties) {
layer.bindPopup(
feature.properties.Gebied
? feature.properties.Gebied
feature.properties.Source_Title
? feature.properties.Source_Title
: 'Deze laag heeft nog geen titel'
)
}
Expand All @@ -116,8 +131,8 @@ const LeafletRevisionOverviewInner = ({
onEachFeature: (feature, layer) => {
if (feature.properties) {
layer.bindPopup(
feature.properties.Gebied
? feature.properties.Gebied
feature.properties.Source_Title
? feature.properties.Source_Title
: 'Deze laag heeft nog geen titel'
)
}
Expand Down
4 changes: 2 additions & 2 deletions src/pages/public/DynamicObject/DynamicObject.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ const DynamicObject = ({ model, isRevision }: DynamicObjectProps) => {
!model.acknowledgedRelation && (
<div
className={classNames('order-8', {
'mt-4 md:mt-8': !!data?.Gebied,
'mt-4 md:mt-8': !!data?.Werkingsgebied_Statics,
})}>
<ObjectConnectionsPublic
model={model}
Expand All @@ -246,7 +246,7 @@ const DynamicObject = ({ model, isRevision }: DynamicObjectProps) => {
!!model.acknowledgedRelation && (
<div
className={classNames('order-9', {
'mt-4 md:mt-8': !!data?.Gebied,
'mt-4 md:mt-8': !!data?.Werkingsgebied_Statics,
})}>
<ObjectRelationsPublic
model={model}
Expand Down

0 comments on commit 50ef813

Please sign in to comment.