diff --git a/src/openforms/js/components/admin/form_design/variables/prefill/PrefillConfigurationForm.js b/src/openforms/js/components/admin/form_design/variables/prefill/PrefillConfigurationForm.js index 303fd2d557..8302413066 100644 --- a/src/openforms/js/components/admin/form_design/variables/prefill/PrefillConfigurationForm.js +++ b/src/openforms/js/components/admin/form_design/variables/prefill/PrefillConfigurationForm.js @@ -273,8 +273,8 @@ const ObjectsAPIPrefillFields = ({values, errors}) => { {/* TODO copied from V2ConfigFields, should probably be reused */} { if (values.prefillOptions.variablesMapping.length === 0) return true; @@ -300,7 +300,9 @@ const ObjectsAPIPrefillFields = ({values, errors}) => { } > { if (values.prefillOptions.variablesMapping.length === 0) return true; const confirmSwitch = window.confirm( @@ -326,7 +328,11 @@ const ObjectsAPIPrefillFields = ({values, errors}) => { /> } > - + diff --git a/src/openforms/js/components/admin/forms/objects_api/ObjectTypeSelect.js b/src/openforms/js/components/admin/forms/objects_api/ObjectTypeSelect.js index bf15fac484..7b7f7c27ed 100644 --- a/src/openforms/js/components/admin/forms/objects_api/ObjectTypeSelect.js +++ b/src/openforms/js/components/admin/forms/objects_api/ObjectTypeSelect.js @@ -20,16 +20,20 @@ const getAvailableObjectTypes = async apiGroupID => { return response.data; }; -const ObjectTypeSelect = ({onChangeCheck, prefix = undefined}) => { - const namePrefix = prefix ? `${prefix}.` : ''; - const [fieldProps, , fieldHelpers] = useField(`${namePrefix}objecttype`); +const ObjectTypeSelect = ({ + onChangeCheck, + objectTypeName = 'objecttype', + objectTypeVersionName = 'objecttypeVersion', + apiGroupName = 'objectsApiGroup', +}) => { + const [fieldProps, , fieldHelpers] = useField(objectTypeName); const { values, setFieldValue, getFieldProps, initialValues: {objecttype: initialObjecttype}, } = useFormikContext(); - const objectsApiGroup = getFieldProps(`${namePrefix}objectsApiGroup`).value ?? null; + const objectsApiGroup = getFieldProps(apiGroupName).value ?? null; const {value} = fieldProps; const {setValue} = fieldHelpers; @@ -51,7 +55,7 @@ const ObjectTypeSelect = ({onChangeCheck, prefix = undefined}) => { ]); const options = choices.map(([value, label]) => ({value, label})); - useSynchronizeSelect(`${namePrefix}objecttype`, loading, choices); + useSynchronizeSelect(objectTypeName, loading, choices); const previousValue = usePrevious(value); @@ -59,13 +63,13 @@ const ObjectTypeSelect = ({onChangeCheck, prefix = undefined}) => { useUpdateEffect(() => { if (loading) return; if (value === initialObjecttype || value === previousValue) return; - setFieldValue(`${namePrefix}objecttypeVersion`, undefined); // clears the value + setFieldValue(objectTypeVersionName, undefined); // clears the value }, [loading, value]); return ( { noManageChildProps > { return versions.sort((v1, v2) => v2.version - v1.version); }; -const ObjectTypeVersionSelect = ({prefix = undefined}) => { - const namePrefix = prefix ? `${prefix}.` : ''; +const ObjectTypeVersionSelect = ({ + objectTypeName = 'objecttype', + objectTypeVersionName = 'objecttypeVersion', + apiGroupName = 'objectsApiGroup', +}) => { const {values} = useFormikContext(); - const objectsApiGroup = _.get(values, `${namePrefix}objectsApiGroup`, null); - const objecttype = _.get(values, `${namePrefix}objecttype`, ''); + const objectsApiGroup = _.get(values, apiGroupName, null); + const objecttype = _.get(values, objectTypeName, ''); const { loading, @@ -45,13 +48,13 @@ const ObjectTypeVersionSelect = ({prefix = undefined}) => { ? [] : versions.map(version => [version.version, `${version.version} (${version.status})`]); - useSynchronizeSelect(`${namePrefix}objecttypeVersion`, loading, choices); + useSynchronizeSelect(objectTypeVersionName, loading, choices); const options = choices.map(([value, label]) => ({value, label})); return ( { noManageChildProps > { - const namePrefix = prefix ? `${prefix}.` : ''; - const [{onChange: onChangeFormik, ...fieldProps}, , {setValue}] = useField( - `${namePrefix}objectsApiGroup` - ); +const ObjectsAPIGroup = ({apiGroupChoices, onChangeCheck, apiGroupName = 'objectsApiGroup'}) => { + const [{onChange: onChangeFormik, ...fieldProps}, , {setValue}] = useField(apiGroupName); const {setValues} = useFormikContext(); const {value} = fieldProps; @@ -34,7 +31,7 @@ const ObjectsAPIGroup = ({apiGroupChoices, onChangeCheck, prefix = undefined}) = return ( {