Skip to content

Commit

Permalink
✨ [open-formulieren/open-forms#2177] added interaction configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
robinmolen committed Jan 6, 2025
1 parent 2d64b61 commit 0f8a233
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/registry/map/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
import {LABELS} from '@/components/builder/messages';
import {Checkbox, Select, TabList, TabPanel, Tabs} from '@/components/formio';
import {BuilderContext} from '@/context';
import InteractionConfiguration from '@/registry/map/interaction-configuration';
import {useErrorChecker} from '@/utils/errors';

import {EditFormDefinition} from '../types';
Expand Down Expand Up @@ -65,7 +66,8 @@ const EditForm: EditFormDefinition<MapComponentSchema> = () => {
'useConfigDefaultMapSettings',
'defaultZoom',
'initialCenter',
'tileLayerIdentifier'
'tileLayerIdentifier',
'interactions'
)}
/>
<BuilderTabs.Advanced hasErrors={hasAnyError('conditional')} />
Expand All @@ -87,6 +89,7 @@ const EditForm: EditFormDefinition<MapComponentSchema> = () => {
<UseConfigDefaultMapSettings />
{!values.useConfigDefaultMapSettings && <MapConfiguration />}
<TileLayer />
<InteractionConfiguration />
</TabPanel>

{/* Advanced tab */}
Expand Down Expand Up @@ -139,6 +142,11 @@ EditForm.defaultValues = {
lng: undefined,
},
tileLayerIdentifier: undefined,
interactions: {
polygon: false,
polyline: false,
marker: true,
},
defaultValue: null,
// Advanced tab
conditional: {
Expand Down
80 changes: 80 additions & 0 deletions src/registry/map/interaction-configuration.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import {FormattedMessage, useIntl} from 'react-intl';

import {Checkbox, Panel} from '@/components/formio';

const PolygonInteraction: React.FC = () => {
const intl = useIntl();
const tooltip = intl.formatMessage({
description: "Tooltip for 'interactions.polygon' builder field",
defaultMessage: 'Allowing users to draw a polygon when using the map component',
});
return (
<Checkbox
name="interactions.polygon"
label={
<FormattedMessage
description="Label for 'interactions.polygon' builder field"
defaultMessage="Polygon interactions"
/>
}
tooltip={tooltip}
/>
);
};

const PolylineInteraction: React.FC = () => {
const intl = useIntl();
const tooltip = intl.formatMessage({
description: "Tooltip for 'interactions.polyline' builder field",
defaultMessage: 'Allowing users to draw a line when using the map component',
});
return (
<Checkbox
name="interactions.polyline"
label={
<FormattedMessage
description="Label for 'interactions.polyline' builder field"
defaultMessage="Line interactions"
/>
}
tooltip={tooltip}
/>
);
};

const MarkerInteraction: React.FC = () => {
const intl = useIntl();
const tooltip = intl.formatMessage({
description: "Tooltip for 'interactions.marker' builder field",
defaultMessage: 'Allowing users to set a marker when using the map component',
});
return (
<Checkbox
name="interactions.marker"
label={
<FormattedMessage
description="Label for 'interactions.marker' builder field"
defaultMessage="Marker interactions"
/>
}
tooltip={tooltip}
/>
);
};

const InteractionConfiguration: React.FC = () => (
<Panel
title={
<FormattedMessage
description="Interaction configuration panel title"
defaultMessage="Available map interactions"
/>
}
>
<PolygonInteraction />
<PolylineInteraction />
<MarkerInteraction />
</Panel>
);

export default InteractionConfiguration;

0 comments on commit 0f8a233

Please sign in to comment.