-
Notifications
You must be signed in to change notification settings - Fork 27
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
Replace DataContainer
with FormioData
in evaluate_form_logic
#5139
Comments
It's a quick test to see what happens if we were to remove the DataContainer from iter_evaluate_rules, and replace it with a FormioData instance. Also added support for FormioData in recursive_apply to fix several failing tests. test_two_actions_on_the_same_variable illustrates what happens when two actions are performed on the same variable.
Investigation of
No it cannot (see changes in e5db653.). Test failures, for example in Initializing a data_for_logic = FormioData(data_container.data_without_to_python) is replaced by data_for_logic = FormioData(data_container.data) However, it will not work for date/datetime fields that are changed in multiple logic actions (see added test We could add a routine that converts the updated values to python objects before adding them to the Moving the conversion to python objects out of Investigation of
This will be tricky in the case when multiple actions change one variable. For example, one action sets a value for a field, and another action changes it back to its original value (not necessarily likely to happen, but also not impossible). This means it was changed twice during logic evaluation and will therefore show up in the mutations, but overall the value hasn't changed. Therefore, we would have to compare it to the original values anyway. Investigation of
Some good news, time/date-related config modifications do work with strings (see Investigation of
The check whether a component is visible in the frontend seems to work better without the python objects actually. Take for example a simple conditional of show component B when date field A has the value '2025-01-01'. Currently, the value entered in the date field is converted to a date object, and used by EDIT: they seem to be used for showing/hiding fields within edit grids (and possibly field sets). Currently, there is no access to fields within edit grids or field sets from the simple logic rules. Not sure if it is possible to access them in a advanced logic rule Investigation of
This injects the variable values into the formio configration to perform template rendering of component properties. It requires python objects for all variables, so it has to use |
Discussion with Sergei on 10-03-2025:
Something to think about: what should happen when iterating over a |
It's a quick test to see what happens if we were to remove the DataContainer from iter_evaluate_rules, and replace it with a FormioData instance. Also added support for FormioData in recursive_apply to fix several failing tests. test_two_actions_on_the_same_variable illustrates what happens when two actions are performed on the same variable.
This simplifies the data structures. Things to investigate/consider:
DataContainer.data
returns the python objects of the variables. Caniter_evaluate_rules
work without these objects?Can we track all of the variable changes based on the returned mutations of all evaluated actions? (Some context:
AcitonOperation.eval
returns a data mapping of the applied changes.)Do we want to refactor the following functions to rely on
SubmissionValueVariablesState
orFormioData
? It depends on whether they can work without the python objects of the variables (that is whatDataContainer.data
currently returns):get_dynamic_configuration
(TODO in code "refactor this to rely onSubmissionValueVariablesState
")FormioConfigurationWrapper.is_visible_in_frontend
inject_variables
The text was updated successfully, but these errors were encountered: