Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#3964] Backport to 2.5.x #4195

Merged
merged 5 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/configuration/registration/zgw.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ZGW API's
The `ZGW (Zaakgericht Werken) API's`_ are a suite of REST based Zaak services.
Open Forms can be configured to access these API's to register form submissions.

.. _`ZGW (Zaakgericht Werken) API's`: https://vng.nl/projecten/zaakgericht-werken-api
.. _`ZGW (Zaakgericht Werken) API's`: https://vng-realisatie.github.io/gemma-zaken/standaard/

.. note::

Expand Down
7 changes: 7 additions & 0 deletions src/openforms/formio/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
import logging
from dataclasses import dataclass
from typing import Any, Dict, Iterator, List, Optional, Tuple, TypeAlias, TypeGuard
Expand Down Expand Up @@ -343,6 +344,12 @@ def is_visible_in_frontend(component: Component, data: DataMapping) -> bool:
if isinstance(trigger_component_value, bool):
compare_value = {"true": True, "false": False}.get(compare_value, False)

# Issue #3964 - The values of number/currency components are numbers, but in Formio frontend logic they are strings.
if isinstance(trigger_component_value, (int, float)) and isinstance(
compare_value, str
):
compare_value = json.loads(compare_value)

return (
conditional_show
if trigger_component_value == compare_value
Expand Down
2 changes: 1 addition & 1 deletion src/openforms/logging/logevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ def registration_skipped_not_yet_paid(submission: "Submission"):


def confirmation_email_scheduled(
submission: Submission, scheduling_options: dict
submission: "Submission", scheduling_options: dict
) -> None:
_create_log(
submission, "confirmation_email_scheduled", extra_data=scheduling_options
Expand Down
5 changes: 5 additions & 0 deletions src/openforms/submissions/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
SubmissionValueVariable,
TemporaryFileUpload,
)
from ..public_references import get_random_reference


class SubmissionFactory(factory.django.DjangoModelFactory):
Expand Down Expand Up @@ -127,6 +128,10 @@ class Params:
status=PaymentStatus.registered,
),
)
with_public_registration_reference = factory.Trait(
completed=True,
public_registration_reference=factory.LazyFunction(get_random_reference),
)

@factory.post_generation
def prefill_data(obj, create, extracted, **kwargs):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,75 @@ def test_checkbox_frontend_logic(self):

self.assertEqual(submission_step.data["textField"], "Test value")

@tag("gh-3964")
def test_number_frontend_logic(self):
form = FormFactory.create()
step = FormStepFactory.create(
form=form,
form_definition__configuration={
"components": [
{
"key": "number",
"type": "number",
},
{
"key": "currency",
"type": "currency",
},
{
"key": "anotherNumber",
"type": "number",
},
{
"key": "textField1",
"type": "textfield",
"clearOnHide": True,
"conditional": {"eq": "1", "show": True, "when": "number"},
},
{
"key": "textField2",
"type": "textfield",
"clearOnHide": True,
"conditional": {"eq": "1", "show": True, "when": "currency"},
},
{
"key": "textField3",
"type": "textfield",
"clearOnHide": True,
"conditional": {
"eq": "1.5",
"show": True,
"when": "anotherNumber",
},
},
]
},
)

submission = SubmissionFactory.create(form=form)
submission_step = SubmissionStepFactory.create(
submission=submission,
form_step=step,
data={
"number": 1,
"currency": 1,
"anotherNumber": 1.5,
"textField1": "Test value",
"textField2": "Test value",
"textField3": "Test value",
},
)

self.assertEqual(submission_step.data["textField1"], "Test value")
self.assertEqual(submission_step.data["textField2"], "Test value")
self.assertEqual(submission_step.data["textField3"], "Test value")

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

self.assertEqual(submission_step.data["textField1"], "Test value")
self.assertEqual(submission_step.data["textField2"], "Test value")
self.assertEqual(submission_step.data["textField3"], "Test value")

@tag("gh-3744")
def test_postcode_component_made_optional(self):
form = FormFactory.create()
Expand Down
Loading