Skip to content

Commit

Permalink
🚧 [#5139] Replace DataContainer with FormioData instance in is_visibl…
Browse files Browse the repository at this point in the history
…e_in_frontend
  • Loading branch information
viktorvanwijk committed Mar 10, 2025
1 parent 2917cf3 commit e16ae3f
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/openforms/submissions/form_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ def evaluate_form_logic(
data_diff = FormioData()
for component in config_wrapper:
key = component["key"]
is_visible = config_wrapper.is_visible_in_frontend(key, data_container.data)
# TODO-5139: is_visible_in_frontend must accept a FormioData instance instead
is_visible = config_wrapper.is_visible_in_frontend(key, data_for_evaluation.data)
if is_visible:
continue

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import unittest

from django.test import TestCase, tag

from openforms.forms.constants import LogicActionTypes
Expand Down Expand Up @@ -874,6 +876,43 @@ def test_component_visible_in_frontend(self):
"Some data that must not be cleared!", submission_step.data["textField"]
)

# TODO-5139: this is a bug which currently exists on master as well, and is not
# fixed with the data-structure changes, yet.
@unittest.expectedFailure
def test_component_visible_with_date(self):
form = FormFactory.create()
form_step = FormStepFactory.create(
form=form,
form_definition__configuration={
"components": [
{
"key": "date",
"type": "date",
},
{
"type": "textfield",
"key": "textField",
"hidden": True,
"conditional": {"eq": "2025-01-01", "show": True, "when": "date"},
"clearOnHide": True,
},
]
},
)

submission = SubmissionFactory.create(form=form)
submission_step = SubmissionStepFactory.create(
submission=submission,
form_step=form_step,
data={"date": "2025-01-01", "textField": "Some data that must not be cleared!"},
)

evaluate_form_logic(submission, submission_step, submission.data, dirty=True)

self.assertEqual(
"Some data that must not be cleared!", submission_step.data["textField"]
)

@tag("gh-1183")
def test_component_incomplete_frontend_logic(self):
form = FormFactory.create()
Expand Down

0 comments on commit e16ae3f

Please sign in to comment.