Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix-6156]: Fix bug with parsing templates in descriptions #2963

Merged
merged 6 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -90,7 +94,7 @@ export const AssetLayer: FC = () => {
const item: Item = {
id: id.toString(),
type: typeValue,
description,
description: parsedDescription,
status: featureStatusType?.typeValue,
label,
coordinates,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading