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 Dec 9, 2024
1 parent e130091 commit 0cf728c
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/registry/map/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -62,7 +63,8 @@ const EditForm: EditFormDefinition<MapComponentSchema> = () => {
'isSensitiveData',
'useConfigDefaultMapSettings',
'defaultZoom',
'initialCenter'
'initialCenter',
'interactions'

Check failure on line 67 in src/registry/map/edit.tsx

View workflow job for this annotation

GitHub Actions / Create 'production' build

Argument of type '"interactions"' is not assignable to parameter of type '"type" | "key" | "id" | "hidden" | "label" | "description" | "tooltip" | "defaultValue" | "validate" | "clearOnHide" | "conditional" | "errors" | "validateOn" | "showInSummary" | "showInEmail" | "showInPDF" | "isSensitiveData" | "openForms" | "registration" | "translatedErrors" | "registration.attribute" | "defaultZoom" | "initialCenter" | "useConfigDefaultMapSettings" | "validate.required" | "validate.plugins" | "conditional.show" | "conditional.json" | "conditional.when" | "conditional.eq" | "errors.required" | "translatedErrors.en" | "translatedErrors.nl" | "openForms.translations" | "openForms.translations.en" | "openForms.translations.nl" | "openForms.translations.en.label" | "openForms.translations.en.description" | "openForms.translations.en.tooltip" | "openForms.translations.nl.label" | "openForms.translations.nl.description" | "openForms.translations.nl.tooltip" | "translatedErrors.en.required" | "translatedErrors.nl.required" | "initialCenter.lat" | "initialCenter.lng"'.

Check failure on line 67 in src/registry/map/edit.tsx

View workflow job for this annotation

GitHub Actions / Create 'production' build

Argument of type '"interactions"' is not assignable to parameter of type '"type" | "key" | "id" | "hidden" | "label" | "description" | "tooltip" | "defaultValue" | "validate" | "clearOnHide" | "conditional" | "errors" | "validateOn" | "showInSummary" | "showInEmail" | "showInPDF" | "isSensitiveData" | "openForms" | "registration" | "translatedErrors" | "registration.attribute" | "defaultZoom" | "initialCenter" | "useConfigDefaultMapSettings" | "validate.required" | "validate.plugins" | "conditional.show" | "conditional.json" | "conditional.when" | "conditional.eq" | "errors.required" | "translatedErrors.en" | "translatedErrors.nl" | "openForms.translations" | "openForms.translations.en" | "openForms.translations.nl" | "openForms.translations.en.label" | "openForms.translations.en.description" | "openForms.translations.en.tooltip" | "openForms.translations.nl.label" | "openForms.translations.nl.description" | "openForms.translations.nl.tooltip" | "translatedErrors.en.required" | "translatedErrors.nl.required" | "initialCenter.lat" | "initialCenter.lng"'.
)}
/>
<BuilderTabs.Advanced hasErrors={hasAnyError('conditional')} />
Expand All @@ -83,6 +85,7 @@ const EditForm: EditFormDefinition<MapComponentSchema> = () => {
<IsSensitiveData />
<UseConfigDefaultMapSettings />
{!values.useConfigDefaultMapSettings && <MapConfiguration />}
<InteractionConfiguration />
</TabPanel>

{/* Advanced tab */}
Expand Down Expand Up @@ -134,6 +137,12 @@ EditForm.defaultValues = {
lat: undefined,
lng: undefined,
},
interactions: {

Check failure on line 140 in src/registry/map/edit.tsx

View workflow job for this annotation

GitHub Actions / Create 'production' build

Type '{ label: string; key: string; description: string; tooltip: string; showInSummary: true; showInEmail: false; showInPDF: true; hidden: false; clearOnHide: true; isSensitiveData: true; useConfigDefaultMapSettings: false; defaultZoom: undefined; initialCenter: { lat: undefined; lng: undefined; }; interactions: { circle: boolean; polygon: boolean; polyline: boolean; marker: boolean; }; defaultValue: null; conditional: { show: undefined; when: string; eq: string; }; validate: { required: false; plugins: never[]; }; translatedErrors: {}; registration: { attribute: string; }; }' is not assignable to type 'Omit<MapComponentSchema, "type" | "id">'.

Check failure on line 140 in src/registry/map/edit.tsx

View workflow job for this annotation

GitHub Actions / Create 'production' build

Type '{ label: string; key: string; description: string; tooltip: string; showInSummary: true; showInEmail: false; showInPDF: true; hidden: false; clearOnHide: true; isSensitiveData: true; useConfigDefaultMapSettings: false; defaultZoom: undefined; initialCenter: { lat: undefined; lng: undefined; }; interactions: { circle: boolean; polygon: boolean; polyline: boolean; marker: boolean; }; defaultValue: null; conditional: { show: undefined; when: string; eq: string; }; validate: { required: false; plugins: never[]; }; translatedErrors: {}; registration: { attribute: string; }; }' is not assignable to type 'Omit<MapComponentSchema, "type" | "id">'.
circle: false,
polygon: false,
polyline: false,
marker: true,
},
defaultValue: null,
// Advanced tab
conditional: {
Expand Down
100 changes: 100 additions & 0 deletions src/registry/map/interaction-configuration.tsx
Original file line number Diff line number Diff line change
@@ -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 users are allowed to draw a circle when working with the map',
});
return (
<Checkbox
name="interactions.circle"
label={
<FormattedMessage
description="Label for 'interactions.circle' builder field"
defaultMessage="Allow circle interactions"
/>
}
tooltip={tooltip}
/>
);
};

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

const PolylineInteraction: React.FC = () => {
const intl = useIntl();
const tooltip = intl.formatMessage({
description: "Tooltip for 'interactions.polyline' builder field",
defaultMessage: 'Whether users are allowed to draw a polyline when working with the map',
});
return (
<Checkbox
name="interactions.polyline"
label={
<FormattedMessage
description="Label for 'interactions.polyline' builder field"
defaultMessage="Allow polyline interactions"
/>
}
tooltip={tooltip}
/>
);
};

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

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

export default InteractionConfiguration;

0 comments on commit 0cf728c

Please sign in to comment.