From 5a403b0557ca6a2e4dbff97b2ace044d0e944415 Mon Sep 17 00:00:00 2001 From: robinvandermolen Date: Tue, 3 Dec 2024 18:05:15 +0100 Subject: [PATCH] :sparkles: [open-formulieren/open-forms#2177] added interaction configuration --- src/registry/map/edit.tsx | 11 +- .../map/interaction-configuration.tsx | 100 ++++++++++++++++++ 2 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 src/registry/map/interaction-configuration.tsx diff --git a/src/registry/map/edit.tsx b/src/registry/map/edit.tsx index f4613db4..54a0a89d 100644 --- a/src/registry/map/edit.tsx +++ b/src/registry/map/edit.tsx @@ -25,6 +25,7 @@ import {useErrorChecker} from '@/utils/errors'; import {EditFormDefinition} from '../types'; import MapConfiguration from './map-configuration'; +import InteractionConfiguration from '@/registry/map/interaction-configuration'; /** * Form to configure a Formio 'map' type component. @@ -62,7 +63,8 @@ const EditForm: EditFormDefinition = () => { 'isSensitiveData', 'useConfigDefaultMapSettings', 'defaultZoom', - 'initialCenter' + 'initialCenter', + 'interactions' )} /> @@ -83,6 +85,7 @@ const EditForm: EditFormDefinition = () => { {!values.useConfigDefaultMapSettings && } + {/* Advanced tab */} @@ -134,6 +137,12 @@ EditForm.defaultValues = { lat: undefined, lng: undefined, }, + interactions: { + circle: false, + polygon: false, + polyline: false, + marker: true, + }, defaultValue: null, // Advanced tab conditional: { diff --git a/src/registry/map/interaction-configuration.tsx b/src/registry/map/interaction-configuration.tsx new file mode 100644 index 00000000..8e81f548 --- /dev/null +++ b/src/registry/map/interaction-configuration.tsx @@ -0,0 +1,100 @@ +import {FormattedMessage, useIntl} from 'react-intl'; +import {Checkbox, Panel} from '@/components/formio'; + +const CircleInteraction: React.FC = () => { + const intl = useIntl(); + const tooltip = intl.formatMessage({ + description: "Tooltip for 'interactions.circle' builder field", + defaultMessage: 'Whether to allow this type of interaction in the map', + }); + return ( + + } + tooltip={tooltip} + /> + ); +}; + +const PolygonInteraction: React.FC = () => { + const intl = useIntl(); + const tooltip = intl.formatMessage({ + description: "Tooltip for 'interactions.polygon' builder field", + defaultMessage: 'Whether to allow this type of interaction in the map', + }); + return ( + + } + tooltip={tooltip} + /> + ); +}; + +const PolylineInteraction: React.FC = () => { + const intl = useIntl(); + const tooltip = intl.formatMessage({ + description: "Tooltip for 'interactions.polyline' builder field", + defaultMessage: 'Whether to allow this type of interaction in the map', + }); + return ( + + } + tooltip={tooltip} + /> + ); +}; + +const MarkerInteraction: React.FC = () => { + const intl = useIntl(); + const tooltip = intl.formatMessage({ + description: "Tooltip for 'interactions.marker' builder field", + defaultMessage: 'Whether to allow this type of interaction in the map', + }); + return ( + + } + tooltip={tooltip} + /> + ); +}; + +const InteractionConfiguration: React.FC = () => ( + + } + > + + + + + +); + +export default InteractionConfiguration;