diff --git a/src/openapi.yaml b/src/openapi.yaml index 6559baa1c7..0bb6e50e26 100644 --- a/src/openapi.yaml +++ b/src/openapi.yaml @@ -9669,7 +9669,9 @@ components: title: Required authentication attribute description: The authentication attribute required for this plugin to lookup remote data. + extraData: {} required: + - extraData - id - label - requiresAuth diff --git a/src/openforms/js/components/admin/form_design/logic/actions/dmn/DMNParametersForm.js b/src/openforms/js/components/admin/form_design/logic/actions/dmn/DMNParametersForm.js index 46097e157e..0bd611d272 100644 --- a/src/openforms/js/components/admin/form_design/logic/actions/dmn/DMNParametersForm.js +++ b/src/openforms/js/components/admin/form_design/logic/actions/dmn/DMNParametersForm.js @@ -101,6 +101,7 @@ const processInputParams = params => { }; const DMNParametersForm = () => { + const intl = useIntl(); const {values, setValues} = useFormikContext(); const {pluginId, decisionDefinitionId, decisionDefinitionVersion, inputMapping, outputMapping} = values; @@ -172,6 +173,15 @@ const DMNParametersForm = () => { dmnParams, ]); + const dmnVariableColumnLabel = intl.formatMessage({ + description: 'DMN variable label', + defaultMessage: 'DMN variable', + }); + const dmnVariableSelectAriaLabel = intl.formatMessage({ + description: 'Accessible label for DMN variable dropdown', + defaultMessage: 'DMN variable', + }); + return (
@@ -182,7 +192,11 @@ const DMNParametersForm = () => { mapping.dmnVariable)} includeStaticVariables /> @@ -195,7 +209,11 @@ const DMNParametersForm = () => { mapping.dmnVariable)} />
diff --git a/src/openforms/js/components/admin/form_design/logic/actions/dmn/VariableMapping.js b/src/openforms/js/components/admin/form_design/logic/actions/dmn/VariableMapping.js index 818eee9fe2..158c0e3896 100644 --- a/src/openforms/js/components/admin/form_design/logic/actions/dmn/VariableMapping.js +++ b/src/openforms/js/components/admin/form_design/logic/actions/dmn/VariableMapping.js @@ -1,4 +1,5 @@ import {FieldArray, useFormikContext} from 'formik'; +import get from 'lodash/get'; import PropTypes from 'prop-types'; import React from 'react'; import {FormattedMessage, useIntl} from 'react-intl'; @@ -15,8 +16,10 @@ const VariableMappingRow = ({ loading, prefix, onRemove, + targets, + targetsFieldName, + selectAriaLabel, includeStaticVariables = false, - dmnVariables, alreadyMapped = [], }) => { const intl = useIntl(); @@ -27,10 +30,9 @@ const VariableMappingRow = ({ defaultMessage: 'Are you sure that you want to remove this mapping?', }); - const dmnVariableProps = getFieldProps(`${prefix}.dmnVariable`); - - const dmnVariableChoices = dmnVariables.filter( - ([value]) => value === dmnVariableProps.value || !alreadyMapped.includes(value) + const targetsProps = getFieldProps(`${prefix}.${targetsFieldName}`); + const targetsChoices = targets.filter( + ([value]) => value === targetsProps.value || !alreadyMapped.includes(value) ); const mapping = getFieldProps(prefix).value; @@ -51,17 +53,14 @@ const VariableMappingRow = ({ - + ; }; -const AttributeField = () => { +const AttributeField = ({prefillAttributes}) => { const [fieldProps] = useField('attribute'); const { values: {plugin}, } = useFormikContext(); + return ( + + ); +}; + +const PrefillFields = ({values, errors}) => { // Load the possible prefill attributes // XXX: this would benefit from client-side caching + const plugin = values.plugin; const { loading, value = [], @@ -152,29 +152,197 @@ const AttributeField = () => { // throw errors to the nearest error boundary if (error) throw error; - const choices = loading ? LOADING_OPTION : value; + const prefillAttributes = loading ? LOADING_OPTION : value; + return ( - + <> +
+ + + } + errors={errors.plugin} + > + + + + + {/* TODO copied from V2ConfigFields, should probably be reused */} + { + if (values.prefillOptions.variablesMapping.length === 0) return true; + const confirmSwitch = window.confirm( + intl.formatMessage({ + description: + 'Objects API registration options: warning message when changing the api group', + defaultMessage: `Changing the api group will remove the existing variables mapping. + Are you sure you want to continue?`, + }) + ); + if (!confirmSwitch) return false; + setFieldValue('prefillOptions.variablesMapping', []); + return true; + }} + /> + + } + > + { + if (values.prefillOptions.variablesMapping.length === 0) return true; + const confirmSwitch = window.confirm( + intl.formatMessage({ + description: + 'Objects API registration options: warning message when changing the object type', + defaultMessage: `Changing the objecttype will remove the existing variables mapping. + Are you sure you want to continue?`, + }) + ); + if (!confirmSwitch) return false; + setFieldValue('prefillOptions.variablesMapping', []); + return true; + }} + /> + + + + } + > + + +
+ +
+ } + > + + mapping.prefillAttribute + )} + /> + +
+ ); }; diff --git a/src/openforms/js/components/admin/form_design/variables/prefill/PrefillSummary.js b/src/openforms/js/components/admin/form_design/variables/prefill/PrefillSummary.js index 2f86590168..9ed029eac8 100644 --- a/src/openforms/js/components/admin/form_design/variables/prefill/PrefillSummary.js +++ b/src/openforms/js/components/admin/form_design/variables/prefill/PrefillSummary.js @@ -14,6 +14,7 @@ const PrefillSummary = ({ plugin = '', attribute = '', identifierRole = 'main', + prefillOptions = undefined, onChange = undefined, errors = {}, }) => { @@ -90,6 +91,7 @@ const PrefillSummary = ({ plugin={plugin} attribute={attribute} identifierRole={identifierRole} + prefillOptions={prefillOptions} onSubmit={values => { onChange(values); setModalOpen(false); diff --git a/src/openforms/prefill/api/serializers.py b/src/openforms/prefill/api/serializers.py index a5f902ca43..82756fe671 100644 --- a/src/openforms/prefill/api/serializers.py +++ b/src/openforms/prefill/api/serializers.py @@ -19,6 +19,7 @@ class PrefillPluginSerializer(PluginBaseSerializer): ), allow_null=True, ) + extra_data = serializers.JSONField() class PrefillPluginQueryParameterSerializer(serializers.Serializer): diff --git a/src/openforms/prefill/api/tests/test_endpoints.py b/src/openforms/prefill/api/tests/test_endpoints.py index a370468559..6787eb966e 100644 --- a/src/openforms/prefill/api/tests/test_endpoints.py +++ b/src/openforms/prefill/api/tests/test_endpoints.py @@ -112,16 +112,19 @@ def test_prefill_list(self): "id": "test", "label": "Test", "requiresAuth": AuthAttribute.bsn, + "extraData": None, }, { "id": "onlyvars", "label": "Only Vars", "requiresAuth": AuthAttribute.bsn, + "extraData": None, }, { "id": "vanityplates", "label": "Vanity Plates", "requiresAuth": AuthAttribute.bsn, + "extraData": None, }, ] @@ -139,12 +142,14 @@ def test_prefill_list_for_component_type(self): "id": "test", "label": "Test", "requiresAuth": AuthAttribute.bsn, + "extraData": None, }, # spec'd for licenseplate { "id": "vanityplates", "label": "Vanity Plates", "requiresAuth": AuthAttribute.bsn, + "extraData": None, }, ] diff --git a/src/openforms/prefill/base.py b/src/openforms/prefill/base.py index 4d7eacda8c..73c1ea702a 100644 --- a/src/openforms/prefill/base.py +++ b/src/openforms/prefill/base.py @@ -89,3 +89,7 @@ def get_identifier_value( and submission.auth_info.attribute == cls.requires_auth ): return submission.auth_info.value + + @property + def extra_data(self): + return None diff --git a/src/openforms/prefill/contrib/objects_api/plugin.py b/src/openforms/prefill/contrib/objects_api/plugin.py index 2320515d1f..80ad566e39 100644 --- a/src/openforms/prefill/contrib/objects_api/plugin.py +++ b/src/openforms/prefill/contrib/objects_api/plugin.py @@ -4,7 +4,10 @@ from django.utils.translation import gettext_lazy as _ from openforms.contrib.objects_api.checks import check_config -from openforms.registrations.contrib.objects_api.models import ObjectsAPIConfig +from openforms.registrations.contrib.objects_api.models import ( + ObjectsAPIConfig, + ObjectsAPIGroupConfig, +) from ...base import BasePlugin from ...registry import register @@ -37,3 +40,11 @@ def get_config_actions(self): ), ), ] + + @property + def extra_data(self): + return { + "api_groups": [ + (group.pk, group.name) for group in ObjectsAPIGroupConfig.objects.all() + ] + }