From 084e492a5c6ae4067d8f5dd9a0a55fb53357624b Mon Sep 17 00:00:00 2001
From: Viicos <65306057+Viicos@users.noreply.github.com>
Date: Tue, 2 Jul 2024 16:08:34 +0200
Subject: [PATCH 1/2] [#4267] Clear variables mapping when changing Objects API
configuration
---
.../objectsapi/LegacyConfigFields.js | 33 +++++++-----
.../objectsapi/ObjectsApiOptionsFormFields.js | 5 +-
.../objectsapi/V2ConfigFields.js | 54 +++++++++++++++----
3 files changed, 66 insertions(+), 26 deletions(-)
diff --git a/src/openforms/js/components/admin/form_design/registrations/objectsapi/LegacyConfigFields.js b/src/openforms/js/components/admin/form_design/registrations/objectsapi/LegacyConfigFields.js
index 1f130abd88..ba8cd14913 100644
--- a/src/openforms/js/components/admin/form_design/registrations/objectsapi/LegacyConfigFields.js
+++ b/src/openforms/js/components/admin/form_design/registrations/objectsapi/LegacyConfigFields.js
@@ -9,7 +9,7 @@ import {ValidationErrorContext} from 'components/admin/forms/ValidationErrors';
import {getChoicesFromSchema, getErrorMarkup, getFieldErrors} from './utils';
-const LegacyConfigFields = ({index, name, schema, formData, onChange}) => {
+const LegacyConfigFields = ({index, name, schema, formData, onFieldChange}) => {
const intl = useIntl();
const validationErrors = useContext(ValidationErrorContext);
@@ -34,7 +34,7 @@ const LegacyConfigFields = ({index, name, schema, formData, onChange}) => {
useEffect(() => {
if (schema.properties.objectsApiGroup.enum.length === 1 && objectsApiGroup === '') {
- onChange({
+ onFieldChange({
target: {name: 'objectsApiGroup', value: schema.properties.objectsApiGroup.enum[0]},
});
}
@@ -65,7 +65,7 @@ const LegacyConfigFields = ({index, name, schema, formData, onChange}) => {
schema.properties.objectsApiGroup.enumNames
)}
value={objectsApiGroup}
- onChange={onChange}
+ onChange={onFieldChange}
allowBlank
/>
@@ -85,7 +85,12 @@ const LegacyConfigFields = ({index, name, schema, formData, onChange}) => {
displayLabel
required
>
-
+
{
id="root_objecttypeVersion"
name="objecttypeVersion"
value={objecttypeVersion}
- onChange={onChange}
+ onChange={onFieldChange}
/>
{
id="root_productaanvraagType"
name="productaanvraagType"
value={productaanvraagType}
- onChange={onChange}
+ onChange={onFieldChange}
/>
{
id="root_informatieobjecttypeSubmissionReport"
name="informatieobjecttypeSubmissionReport"
value={informatieobjecttypeSubmissionReport}
- onChange={onChange}
+ onChange={onFieldChange}
/>
{
id="root_uploadSubmissionCsv"
name="uploadSubmissionCsv"
value={uploadSubmissionCsv}
- onChange={onChange}
+ onChange={onFieldChange}
/>
{
id="root_informatieobjecttypeSubmissionCsv"
name="informatieobjecttypeSubmissionCsv"
value={informatieobjecttypeSubmissionCsv}
- onChange={onChange}
+ onChange={onFieldChange}
/>
{
id="root_informatieobjecttypeAttachment"
name="informatieobjecttypeAttachment"
value={informatieobjecttypeAttachment}
- onChange={onChange}
+ onChange={onFieldChange}
/>
{
id="root_organisatieRsin"
name="organisatieRsin"
value={organisatieRsin}
- onChange={onChange}
+ onChange={onFieldChange}
/>
{
id="root_contentJson"
name="contentJson"
value={contentJson}
- onChange={onChange}
+ onChange={onFieldChange}
/>
{
id="root_paymentStatusUpdateJson"
name="paymentStatusUpdateJson"
value={paymentStatusUpdateJson}
- onChange={onChange}
+ onChange={onFieldChange}
/>
>
@@ -321,7 +326,7 @@ LegacyConfigFields.propTypes = {
contentJson: PropTypes.string,
paymentStatusUpdateJson: PropTypes.string,
}),
- onChange: PropTypes.func.isRequired,
+ onFieldChange: PropTypes.func.isRequired,
};
export default LegacyConfigFields;
diff --git a/src/openforms/js/components/admin/form_design/registrations/objectsapi/ObjectsApiOptionsFormFields.js b/src/openforms/js/components/admin/form_design/registrations/objectsapi/ObjectsApiOptionsFormFields.js
index c4726b2563..f8cefd0d9e 100644
--- a/src/openforms/js/components/admin/form_design/registrations/objectsapi/ObjectsApiOptionsFormFields.js
+++ b/src/openforms/js/components/admin/form_design/registrations/objectsapi/ObjectsApiOptionsFormFields.js
@@ -101,7 +101,7 @@ const ObjectsApiOptionsFormFields = ({index, name, schema, formData, onChange})
name={name}
schema={schema}
formData={formData}
- onChange={onFieldChange}
+ onFieldChange={onFieldChange}
/>
@@ -114,7 +114,8 @@ const ObjectsApiOptionsFormFields = ({index, name, schema, formData, onChange})
name={name}
schema={schema}
formData={formData}
- onChange={onFieldChange}
+ onFieldChange={onFieldChange}
+ onChange={onChange}
/>
diff --git a/src/openforms/js/components/admin/form_design/registrations/objectsapi/V2ConfigFields.js b/src/openforms/js/components/admin/form_design/registrations/objectsapi/V2ConfigFields.js
index 8fed2ef3af..fa29d4c6e2 100644
--- a/src/openforms/js/components/admin/form_design/registrations/objectsapi/V2ConfigFields.js
+++ b/src/openforms/js/components/admin/form_design/registrations/objectsapi/V2ConfigFields.js
@@ -1,3 +1,4 @@
+import {produce} from 'immer';
import PropTypes from 'prop-types';
import React, {useContext, useEffect} from 'react';
import {FormattedMessage, useIntl} from 'react-intl';
@@ -13,7 +14,7 @@ import ObjectTypeVersionSelect from './ObjectTypeVersionSelect';
import {useGetAvailableObjectTypes} from './hooks';
import {getChoicesFromSchema, getErrorMarkup, getFieldErrors} from './utils';
-const V2ConfigFields = ({index, name, schema, formData, onChange}) => {
+const V2ConfigFields = ({index, name, schema, formData, onFieldChange, onChange}) => {
const intl = useIntl();
const validationErrors = useContext(ValidationErrorContext);
@@ -26,6 +27,7 @@ const V2ConfigFields = ({index, name, schema, formData, onChange}) => {
informatieobjecttypeSubmissionCsv = '',
informatieobjecttypeAttachment = '',
organisatieRsin = '',
+ variablesMapping = [],
} = formData;
// Track available object types and versions in this component so the state can be
@@ -39,12 +41,31 @@ const V2ConfigFields = ({index, name, schema, formData, onChange}) => {
useEffect(() => {
if (schema.properties.objectsApiGroup.enum.length === 1 && objectsApiGroup === '') {
- onChange({
+ onFieldChange({
target: {name: 'objectsApiGroup', value: schema.properties.objectsApiGroup.enum[0]},
});
}
}, []);
+ const clearMappingOnChange = message => {
+ return event => {
+ if (variablesMapping.length === 0) {
+ onFieldChange(event);
+ } else {
+ const confirmSwitch = window.confirm(message);
+ if (confirmSwitch) {
+ const {name, value} = event.target;
+ onChange(
+ produce(formData, draft => {
+ draft.variablesMapping = [];
+ draft[name] = value;
+ })
+ );
+ }
+ }
+ };
+ };
+
const loadingError = !!availableObjectTypesState.error;
if (loadingError) {
return (
@@ -82,7 +103,13 @@ const V2ConfigFields = ({index, name, schema, formData, onChange}) => {
schema.properties.objectsApiGroup.enumNames
)}
value={objectsApiGroup}
- onChange={onChange}
+ onChange={clearMappingOnChange(
+ intl.formatMessage({
+ defaultMessage: `Changing the Objects API group will remove the existing variables mapping.
+ Are you sure you want to continue?`,
+ description: 'Changing Objects API group warning message',
+ })
+ )}
allowBlank
/>
@@ -106,7 +133,13 @@ const V2ConfigFields = ({index, name, schema, formData, onChange}) => {
{
availableObjecttypes={availableObjectTypesState.availableObjecttypes}
selectedObjecttype={objecttype}
selectedVersion={objecttypeVersion}
- onChange={onChange}
+ onChange={onFieldChange}
/>
{
id="root_informatieobjecttypeSubmissionReport"
name="informatieobjecttypeSubmissionReport"
value={informatieobjecttypeSubmissionReport}
- onChange={onChange}
+ onChange={onFieldChange}
/>
{
id="root_uploadSubmissionCsv"
name="uploadSubmissionCsv"
value={uploadSubmissionCsv}
- onChange={onChange}
+ onChange={onFieldChange}
/>
{
id="root_informatieobjecttypeSubmissionCsv"
name="informatieobjecttypeSubmissionCsv"
value={informatieobjecttypeSubmissionCsv}
- onChange={onChange}
+ onChange={onFieldChange}
/>
{
id="root_informatieobjecttypeAttachment"
name="informatieobjecttypeAttachment"
value={informatieobjecttypeAttachment}
- onChange={onChange}
+ onChange={onFieldChange}
/>
{
id="root_organisatieRsin"
name="organisatieRsin"
value={organisatieRsin}
- onChange={onChange}
+ onChange={onFieldChange}
/>
>
@@ -278,6 +311,7 @@ V2ConfigFields.propTypes = {
contentJson: PropTypes.string,
paymentStatusUpdateJson: PropTypes.string,
}),
+ onFieldChange: PropTypes.func.isRequired,
onChange: PropTypes.func.isRequired,
};
From c1b0d575b2c0cd79564d14226dc1e7c61bddac62 Mon Sep 17 00:00:00 2001
From: Viicos <65306057+Viicos@users.noreply.github.com>
Date: Tue, 2 Jul 2024 16:10:08 +0200
Subject: [PATCH 2/2] [#4267] Make messages
---
src/openforms/js/compiled-lang/en.json | 36 +++++++++++++++++---------
src/openforms/js/compiled-lang/nl.json | 36 +++++++++++++++++---------
src/openforms/js/lang/en.json | 10 +++++++
src/openforms/js/lang/nl.json | 10 +++++++
4 files changed, 68 insertions(+), 24 deletions(-)
diff --git a/src/openforms/js/compiled-lang/en.json b/src/openforms/js/compiled-lang/en.json
index ab34a8b6c7..b14d4ec0e0 100644
--- a/src/openforms/js/compiled-lang/en.json
+++ b/src/openforms/js/compiled-lang/en.json
@@ -563,12 +563,6 @@
"value": "Number of months. Empty values are ignored."
}
],
- "5ZI59Y": [
- {
- "type": 0,
- "value": "Main"
- }
- ],
"5dp5j+": [
{
"type": 1,
@@ -847,6 +841,12 @@
"value": "(missing label)"
}
],
+ "8/Nzyy": [
+ {
+ "type": 0,
+ "value": "Changing the Objects API group will remove the existing variables mapping. Are you sure you want to continue?"
+ }
+ ],
"833GAg": [
{
"type": 0,
@@ -2455,12 +2455,6 @@
"value": " must be a valid email."
}
],
- "Q7oBP/": [
- {
- "type": 0,
- "value": "Authorised person"
- }
- ],
"Q8WgtE": [
{
"type": 0,
@@ -2527,6 +2521,12 @@
"value": "Confidentiality"
}
],
+ "R7XVbR": [
+ {
+ "type": 0,
+ "value": "Main/representee"
+ }
+ ],
"R8/zGm": [
{
"type": 0,
@@ -2813,6 +2813,12 @@
"value": "All Submissions Removal Limit"
}
],
+ "UjvOBe": [
+ {
+ "type": 0,
+ "value": "Changing the objecttype will remove the existing variables mapping. Are you sure you want to continue?"
+ }
+ ],
"UlVtQd": [
{
"type": 0,
@@ -5405,6 +5411,12 @@
"value": "Maximum length"
}
],
+ "yIPUtA": [
+ {
+ "type": 0,
+ "value": "Authorizee"
+ }
+ ],
"yL9Ql7": [
{
"type": 0,
diff --git a/src/openforms/js/compiled-lang/nl.json b/src/openforms/js/compiled-lang/nl.json
index b2de9c5be2..ee9a50960d 100644
--- a/src/openforms/js/compiled-lang/nl.json
+++ b/src/openforms/js/compiled-lang/nl.json
@@ -563,12 +563,6 @@
"value": "Aantal maanden. Lege waarden worden genegeerd."
}
],
- "5ZI59Y": [
- {
- "type": 0,
- "value": "Main/machtiger"
- }
- ],
"5dp5j+": [
{
"type": 1,
@@ -851,6 +845,12 @@
"value": "(label ontbreekt)"
}
],
+ "8/Nzyy": [
+ {
+ "type": 0,
+ "value": "Changing the Objects API group will remove the existing variables mapping. Are you sure you want to continue?"
+ }
+ ],
"833GAg": [
{
"type": 0,
@@ -2455,12 +2455,6 @@
"value": "Ongeldig e-mailadres."
}
],
- "Q7oBP/": [
- {
- "type": 0,
- "value": "Gemachtigde"
- }
- ],
"Q8WgtE": [
{
"type": 0,
@@ -2527,6 +2521,12 @@
"value": "Vertrouwelijkheidaanduiding"
}
],
+ "R7XVbR": [
+ {
+ "type": 0,
+ "value": "Main/representee"
+ }
+ ],
"R8/zGm": [
{
"type": 0,
@@ -2813,6 +2813,12 @@
"value": "Bewaartermijn van inzendingen"
}
],
+ "UjvOBe": [
+ {
+ "type": 0,
+ "value": "Changing the objecttype will remove the existing variables mapping. Are you sure you want to continue?"
+ }
+ ],
"UlVtQd": [
{
"type": 0,
@@ -5410,6 +5416,12 @@
"value": "Maximale lengte"
}
],
+ "yIPUtA": [
+ {
+ "type": 0,
+ "value": "Authorizee"
+ }
+ ],
"yL9Ql7": [
{
"type": 0,
diff --git a/src/openforms/js/lang/en.json b/src/openforms/js/lang/en.json
index 6b016e7f97..a56567791e 100644
--- a/src/openforms/js/lang/en.json
+++ b/src/openforms/js/lang/en.json
@@ -344,6 +344,11 @@
"description": "Variable table registration title",
"originalDefault": "Registration"
},
+ "8/Nzyy": {
+ "defaultMessage": "Changing the Objects API group will remove the existing variables mapping. Are you sure you want to continue?",
+ "description": "Changing Objects API group warning message",
+ "originalDefault": "Changing the Objects API group will remove the existing variables mapping. Are you sure you want to continue?"
+ },
"833GAg": {
"defaultMessage": "Input mapping",
"description": "Input mapping title",
@@ -1344,6 +1349,11 @@
"description": "All Submissions Removal Limit field label",
"originalDefault": "All Submissions Removal Limit"
},
+ "UjvOBe": {
+ "defaultMessage": "Changing the objecttype will remove the existing variables mapping. Are you sure you want to continue?",
+ "description": "Changing objecttype warning message",
+ "originalDefault": "Changing the objecttype will remove the existing variables mapping. Are you sure you want to continue?"
+ },
"V21YkS": {
"defaultMessage": "Confirm",
"description": "Camunda process variables confirm button",
diff --git a/src/openforms/js/lang/nl.json b/src/openforms/js/lang/nl.json
index 92c16e030b..dbce77dcad 100644
--- a/src/openforms/js/lang/nl.json
+++ b/src/openforms/js/lang/nl.json
@@ -347,6 +347,11 @@
"description": "Variable table registration title",
"originalDefault": "Registration"
},
+ "8/Nzyy": {
+ "defaultMessage": "Changing the Objects API group will remove the existing variables mapping. Are you sure you want to continue?",
+ "description": "Changing Objects API group warning message",
+ "originalDefault": "Changing the Objects API group will remove the existing variables mapping. Are you sure you want to continue?"
+ },
"833GAg": {
"defaultMessage": "Invoerparameters",
"description": "Input mapping title",
@@ -1354,6 +1359,11 @@
"description": "All Submissions Removal Limit field label",
"originalDefault": "All Submissions Removal Limit"
},
+ "UjvOBe": {
+ "defaultMessage": "Changing the objecttype will remove the existing variables mapping. Are you sure you want to continue?",
+ "description": "Changing objecttype warning message",
+ "originalDefault": "Changing the objecttype will remove the existing variables mapping. Are you sure you want to continue?"
+ },
"V21YkS": {
"defaultMessage": "Bevestigen",
"description": "Camunda process variables confirm button",