From 892790c7ae5df77e93712213d69267f88f391ab1 Mon Sep 17 00:00:00 2001 From: alimpens Date: Tue, 17 Sep 2024 12:50:56 +0200 Subject: [PATCH 1/6] Reproduce bug --- .../wizard-step-2-vulaan/straatverlichting-klokken.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/signals/incident/definitions/wizard-step-2-vulaan/straatverlichting-klokken.ts b/src/signals/incident/definitions/wizard-step-2-vulaan/straatverlichting-klokken.ts index 4024334829..8ae4f7d27e 100644 --- a/src/signals/incident/definitions/wizard-step-2-vulaan/straatverlichting-klokken.ts +++ b/src/signals/incident/definitions/wizard-step-2-vulaan/straatverlichting-klokken.ts @@ -60,7 +60,8 @@ const straatverlichtingKlokken = { featureTypes: [ { label: 'Grachtmast', - description: 'Grachtmast', + description: + 'Grachtmast - hier moet een nr komen te staan {{ objecttype }}', icon: { options, iconUrl: '/assets/images/openbare_verlichting/grachtmast.svg', From d2b08f52de66fed9c423d4c7286db898c84a0a22 Mon Sep 17 00:00:00 2001 From: alimpens Date: Tue, 17 Sep 2024 16:47:57 +0200 Subject: [PATCH 2/6] Use parsed label as description --- .../MapSelectors/Asset/AssetList/hooks/useSelectionProps.tsx | 1 + .../Asset/Selector/WfsLayer/AssetLayer/AssetLayer.tsx | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/signals/incident/components/form/MapSelectors/Asset/AssetList/hooks/useSelectionProps.tsx b/src/signals/incident/components/form/MapSelectors/Asset/AssetList/hooks/useSelectionProps.tsx index 99130afd82..4e63011a25 100644 --- a/src/signals/incident/components/form/MapSelectors/Asset/AssetList/hooks/useSelectionProps.tsx +++ b/src/signals/incident/components/form/MapSelectors/Asset/AssetList/hooks/useSelectionProps.tsx @@ -38,6 +38,7 @@ export const useSelectionProps = ({ const item: Item = { ...feature, address: undefined, + description: feature.label, // Use label as description, because label already has parsed template strings. status: featureStatusType?.typeValue, } diff --git a/src/signals/incident/components/form/MapSelectors/Asset/Selector/WfsLayer/AssetLayer/AssetLayer.tsx b/src/signals/incident/components/form/MapSelectors/Asset/Selector/WfsLayer/AssetLayer/AssetLayer.tsx index b48da4bffd..80ab64490f 100644 --- a/src/signals/incident/components/form/MapSelectors/Asset/Selector/WfsLayer/AssetLayer/AssetLayer.tsx +++ b/src/signals/incident/components/form/MapSelectors/Asset/Selector/WfsLayer/AssetLayer/AssetLayer.tsx @@ -90,7 +90,7 @@ export const AssetLayer: FC = () => { const item: Item = { id: id.toString(), type: typeValue, - description, + description: label, // Use label as description, because label already has parsed template strings. status: featureStatusType?.typeValue, label, coordinates, From 9b78d64ddf26b752464489ed6ebc0e113a736bdb Mon Sep 17 00:00:00 2001 From: alimpens Date: Tue, 17 Sep 2024 16:49:46 +0200 Subject: [PATCH 3/6] Reset test case --- .../wizard-step-2-vulaan/straatverlichting-klokken.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/signals/incident/definitions/wizard-step-2-vulaan/straatverlichting-klokken.ts b/src/signals/incident/definitions/wizard-step-2-vulaan/straatverlichting-klokken.ts index 8ae4f7d27e..4024334829 100644 --- a/src/signals/incident/definitions/wizard-step-2-vulaan/straatverlichting-klokken.ts +++ b/src/signals/incident/definitions/wizard-step-2-vulaan/straatverlichting-klokken.ts @@ -60,8 +60,7 @@ const straatverlichtingKlokken = { featureTypes: [ { label: 'Grachtmast', - description: - 'Grachtmast - hier moet een nr komen te staan {{ objecttype }}', + description: 'Grachtmast', icon: { options, iconUrl: '/assets/images/openbare_verlichting/grachtmast.svg', From 5d2b5bbcc5ed180e1c6d6a544c7e1d8dc8eec967 Mon Sep 17 00:00:00 2001 From: alimpens Date: Tue, 17 Sep 2024 17:41:12 +0200 Subject: [PATCH 4/6] Group use of parse function --- .../Asset/AssetList/hooks/useSelectionProps.tsx | 1 - .../Asset/Selector/WfsLayer/AssetLayer/AssetLayer.tsx | 6 +++++- .../Selector/WfsLayer/utils/map-to-selectable-feature.ts | 6 +++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/signals/incident/components/form/MapSelectors/Asset/AssetList/hooks/useSelectionProps.tsx b/src/signals/incident/components/form/MapSelectors/Asset/AssetList/hooks/useSelectionProps.tsx index 4e63011a25..99130afd82 100644 --- a/src/signals/incident/components/form/MapSelectors/Asset/AssetList/hooks/useSelectionProps.tsx +++ b/src/signals/incident/components/form/MapSelectors/Asset/AssetList/hooks/useSelectionProps.tsx @@ -38,7 +38,6 @@ export const useSelectionProps = ({ const item: Item = { ...feature, address: undefined, - description: feature.label, // Use label as description, because label already has parsed template strings. status: featureStatusType?.typeValue, } diff --git a/src/signals/incident/components/form/MapSelectors/Asset/Selector/WfsLayer/AssetLayer/AssetLayer.tsx b/src/signals/incident/components/form/MapSelectors/Asset/Selector/WfsLayer/AssetLayer/AssetLayer.tsx index 80ab64490f..c8b41ba591 100644 --- a/src/signals/incident/components/form/MapSelectors/Asset/Selector/WfsLayer/AssetLayer/AssetLayer.tsx +++ b/src/signals/incident/components/form/MapSelectors/Asset/Selector/WfsLayer/AssetLayer/AssetLayer.tsx @@ -74,6 +74,10 @@ export const AssetLayer: FC = () => { isSelected ? ', is geselecteerd' : '' } (${id})` + const parsedDescription = isTemplateString(description) + ? parseTemplateString(description, feature.properties) + : description + const onClick = async () => { ;(window as any)?.dataLayer?.push({ event: 'interaction.generic.component.mapInteraction', @@ -90,7 +94,7 @@ export const AssetLayer: FC = () => { const item: Item = { id: id.toString(), type: typeValue, - description: label, // Use label as description, because label already has parsed template strings. + description: parsedDescription, status: featureStatusType?.typeValue, label, coordinates, diff --git a/src/signals/incident/components/form/MapSelectors/Asset/Selector/WfsLayer/utils/map-to-selectable-feature.ts b/src/signals/incident/components/form/MapSelectors/Asset/Selector/WfsLayer/utils/map-to-selectable-feature.ts index 2e989a0f0e..f74d1fcf51 100644 --- a/src/signals/incident/components/form/MapSelectors/Asset/Selector/WfsLayer/utils/map-to-selectable-feature.ts +++ b/src/signals/incident/components/form/MapSelectors/Asset/Selector/WfsLayer/utils/map-to-selectable-feature.ts @@ -24,10 +24,14 @@ export const mapToSelectableFeature = ( ? parseTemplateString(description, feature.properties) : [description, id].filter(Boolean).join(' - ') + const parsedDescription = isTemplateString(description) + ? parseTemplateString(description, feature.properties) + : description + const selectableFeature = { id: id.toString(), type: typeValue, - description, + description: parsedDescription, status: featureStatusType?.typeValue, label, coordinates, From 99229ef3e27bc0ae6865879e5749636c73fbab77 Mon Sep 17 00:00:00 2001 From: alimpens Date: Thu, 19 Sep 2024 14:14:51 +0200 Subject: [PATCH 5/6] Update tests --- .../Asset/Selector/WfsLayer/AssetLayer/AssetLayer.test.tsx | 2 +- .../WfsLayer/utils/map-data-to-selectable-feature.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/signals/incident/components/form/MapSelectors/Asset/Selector/WfsLayer/AssetLayer/AssetLayer.test.tsx b/src/signals/incident/components/form/MapSelectors/Asset/Selector/WfsLayer/AssetLayer/AssetLayer.test.tsx index ecd68de21b..2217fca8c9 100644 --- a/src/signals/incident/components/form/MapSelectors/Asset/Selector/WfsLayer/AssetLayer/AssetLayer.test.tsx +++ b/src/signals/incident/components/form/MapSelectors/Asset/Selector/WfsLayer/AssetLayer/AssetLayer.test.tsx @@ -176,7 +176,7 @@ describe('AssetLayer', () => { featureTypes: [ { label: 'Papier', - description: 'Papier met nummer: {{ id_nummer }}', + description: 'Papier met nummer: PAB00022', icon: { options: [Object], iconUrl: '/assets/images/afval/paper.svg', diff --git a/src/signals/incident/components/form/MapSelectors/Asset/Selector/WfsLayer/utils/map-data-to-selectable-feature.test.ts b/src/signals/incident/components/form/MapSelectors/Asset/Selector/WfsLayer/utils/map-data-to-selectable-feature.test.ts index 5d261a45d5..0a7132556e 100644 --- a/src/signals/incident/components/form/MapSelectors/Asset/Selector/WfsLayer/utils/map-data-to-selectable-feature.test.ts +++ b/src/signals/incident/components/form/MapSelectors/Asset/Selector/WfsLayer/utils/map-data-to-selectable-feature.test.ts @@ -95,7 +95,7 @@ describe('mapDataToSelectableFeature', () => { { id: '230281', type: undefined, - description: 'Lichtpunt {{ MastCode }} ', + description: 'Lichtpunt Koningskade-0542 ', status: undefined, label: 'Lichtpunt Koningskade-0542 ', coordinates: { lat: 52.08410811, lng: 4.31817273 }, From 5b2f5c0e93ead1391e0b1d3b13fa47b48067644a Mon Sep 17 00:00:00 2001 From: alimpens Date: Thu, 19 Sep 2024 14:42:39 +0200 Subject: [PATCH 6/6] Fix tests --- .../Selector/WfsLayer/AssetLayer/AssetLayer.test.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/signals/incident/components/form/MapSelectors/Asset/Selector/WfsLayer/AssetLayer/AssetLayer.test.tsx b/src/signals/incident/components/form/MapSelectors/Asset/Selector/WfsLayer/AssetLayer/AssetLayer.test.tsx index 2217fca8c9..471ac43775 100644 --- a/src/signals/incident/components/form/MapSelectors/Asset/Selector/WfsLayer/AssetLayer/AssetLayer.test.tsx +++ b/src/signals/incident/components/form/MapSelectors/Asset/Selector/WfsLayer/AssetLayer/AssetLayer.test.tsx @@ -190,14 +190,16 @@ describe('AssetLayer', () => { }) ) - const container = screen.getByAltText(`Papier met nummer: ${featureId}`) + const container = screen.getByAltText( + `Papier met nummer: ${featureId} (${featureId})` + ) userEvent.click(container) const item = { id: 'PAB00022', type: 'Papier', - description: 'Papier met nummer: {{ id_nummer }}', - label: 'Papier met nummer: PAB00022', + description: 'Papier met nummer: PAB00022', + label: 'Papier met nummer: PAB00022 - PAB00022', status: undefined, coordinates, }