diff --git a/package-lock.json b/package-lock.json index 7fd4836bc8..a994304c0e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "dependencies": { "@fortawesome/fontawesome-free": "^6.1.1", "@open-formulieren/design-tokens": "^0.53.0", - "@open-formulieren/formio-builder": "^0.31.0", + "@open-formulieren/formio-builder": "^0.32.0", "@open-formulieren/leaflet-tools": "^1.0.0", "@open-formulieren/monaco-json-editor": "^0.2.0", "@rjsf/core": "^4.2.1", @@ -4429,9 +4429,9 @@ "integrity": "sha512-3Pv32ULCuFOJZ2GaqcpvB45u6xScr0lmW5ETB9P1Ox9TG5nvMcVSwuwYe/GwxbzmvtZgiMQRMKRFT9lNYLeREQ==" }, "node_modules/@open-formulieren/formio-builder": { - "version": "0.31.0", - "resolved": "https://registry.npmjs.org/@open-formulieren/formio-builder/-/formio-builder-0.31.0.tgz", - "integrity": "sha512-gMM3EYU+04fIE0XjiNLTmNfAUl9yNzCcBERwH9hsWVPgduFTYFC0v+kB/SCkg/Zab2bKtv3IugJIksgm1sX36Q==", + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/@open-formulieren/formio-builder/-/formio-builder-0.32.0.tgz", + "integrity": "sha512-XwrAbXeoqQvijS9OfFxk1KyxzzW2xZmaWtBgy+rqAcziaPHk5zaG52YPSHou0T57y3QtKDXp4Lk8q+RBQFqFpA==", "dependencies": { "@ckeditor/ckeditor5-react": "^6.2.0", "@floating-ui/react": "^0.26.4", @@ -23567,9 +23567,9 @@ "integrity": "sha512-3Pv32ULCuFOJZ2GaqcpvB45u6xScr0lmW5ETB9P1Ox9TG5nvMcVSwuwYe/GwxbzmvtZgiMQRMKRFT9lNYLeREQ==" }, "@open-formulieren/formio-builder": { - "version": "0.31.0", - "resolved": "https://registry.npmjs.org/@open-formulieren/formio-builder/-/formio-builder-0.31.0.tgz", - "integrity": "sha512-gMM3EYU+04fIE0XjiNLTmNfAUl9yNzCcBERwH9hsWVPgduFTYFC0v+kB/SCkg/Zab2bKtv3IugJIksgm1sX36Q==", + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/@open-formulieren/formio-builder/-/formio-builder-0.32.0.tgz", + "integrity": "sha512-XwrAbXeoqQvijS9OfFxk1KyxzzW2xZmaWtBgy+rqAcziaPHk5zaG52YPSHou0T57y3QtKDXp4Lk8q+RBQFqFpA==", "requires": { "@ckeditor/ckeditor5-react": "^6.2.0", "@floating-ui/react": "^0.26.4", diff --git a/package.json b/package.json index a1ae7eaa44..36ba0365c9 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "dependencies": { "@fortawesome/fontawesome-free": "^6.1.1", "@open-formulieren/design-tokens": "^0.53.0", - "@open-formulieren/formio-builder": "^0.31.0", + "@open-formulieren/formio-builder": "^0.32.0", "@open-formulieren/leaflet-tools": "^1.0.0", "@open-formulieren/monaco-json-editor": "^0.2.0", "@rjsf/core": "^4.2.1", diff --git a/src/openforms/formio/migration_converters.py b/src/openforms/formio/migration_converters.py index f4e46b3250..536fa8fcfa 100644 --- a/src/openforms/formio/migration_converters.py +++ b/src/openforms/formio/migration_converters.py @@ -208,6 +208,14 @@ def fix_multiple_empty_default_value(component: Component) -> bool: return False +def set_datatype_string(component: Component): + # https://github.com/open-formulieren/open-forms/issues/4772 + if component.get("dataType") != "string": + component["dataType"] = "string" + return True + return False + + def convert_simple_conditionals(configuration: JSONObject) -> bool: config_modified = False @@ -350,6 +358,7 @@ def fix_empty_default_value(component: Component) -> bool: "select": { "set_openforms_datasrc": set_openforms_datasrc, "fix_multiple_empty_default_value": fix_multiple_empty_default_value, + "set_datatype_string": set_datatype_string, }, "selectboxes": {"set_openforms_datasrc": set_openforms_datasrc}, "currency": { diff --git a/src/openforms/formio/tests/test_set_datatype_string.py b/src/openforms/formio/tests/test_set_datatype_string.py new file mode 100644 index 0000000000..3a6a0fb76f --- /dev/null +++ b/src/openforms/formio/tests/test_set_datatype_string.py @@ -0,0 +1,62 @@ +from django.test import SimpleTestCase, tag + +from openforms.formio.typing import SelectComponent + +from ..migration_converters import set_datatype_string + + +class SetDatatypeStringTests(SimpleTestCase): + @tag("gh-4772") + def test_set_datatype_string(self): + configuration: SelectComponent = { + "type": "select", + "key": "select", + "label": "Select", + "data": { + "values": [ + {"label": "Option 1", "value": "1"}, + {"label": "Option 2", "value": "2"}, + ] + }, + } + + set_datatype_string(configuration) + + assert "dataType" in configuration + self.assertEqual(configuration["dataType"], "string") + + configuration: SelectComponent = { + "type": "select", + "key": "select", + "label": "Select", + "dataType": "integer", + "data": { + "values": [ + {"label": "Option 1", "value": "1"}, + {"label": "Option 2", "value": "2"}, + ] + }, + } + + set_datatype_string(configuration) + + assert "dataType" in configuration + self.assertEqual(configuration["dataType"], "string") + + configuration: SelectComponent = { + "type": "select", + "key": "select", + "label": "Select", + "dataType": "string", + "data": { + "values": [ + {"label": "Option 1", "value": "1"}, + {"label": "Option 2", "value": "2"}, + ] + }, + } + + set_datatype_string(configuration) + + assert "dataType" in configuration + self.assertEqual(configuration["dataType"], "string") diff --git a/src/openforms/formio/typing/base.py b/src/openforms/formio/typing/base.py index c1d0be18f1..327c28a148 100644 --- a/src/openforms/formio/typing/base.py +++ b/src/openforms/formio/typing/base.py @@ -89,6 +89,7 @@ class Component(TypedDict): prefill: NotRequired[PrefillConfiguration] openForms: NotRequired[OpenFormsConfig] autocomplete: NotRequired[str] + dataType: NotRequired[Literal["string"]] class FormioConfiguration(TypedDict): diff --git a/src/openforms/forms/migrations/0104_select_datatype_string.py b/src/openforms/forms/migrations/0104_select_datatype_string.py new file mode 100644 index 0000000000..01be2858ba --- /dev/null +++ b/src/openforms/forms/migrations/0104_select_datatype_string.py @@ -0,0 +1,16 @@ +# Generated by Django 4.2.16 on 2024-11-11 12:00 + +from django.db import migrations + +from openforms.forms.migration_operations import ConvertComponentsOperation + + +class Migration(migrations.Migration): + + dependencies = [ + ("forms", "0103_remove_formvariable_prefill_config_empty_or_complete_and_more"), + ] + + operations = [ + ConvertComponentsOperation("select", "set_datatype_string"), + ]