FIO-8091: added selectData calculation for url/resource select components #5564
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Link to Jira Ticket
https://formio.atlassian.net/browse/FIO-8091
Description
The issue: possible select component configuration: URL/Resource data source, lazy loading, value property and item template (using different properties from request object), default value. With this configuration in the form definition, we can see only value property for default value. So select component will be not aware of other object properties unless click on the select component to load items.
The solution: add selectData property for select component definition so select component can use required data for template without loading items.
The first iteration: I tried to use just conditional and calculated value for the selectData field but faced a problem when we change the template and click on default value to load items, as a result, calculate will not be triggered because the default value will not be changed.
Second iteration: when we click on the default value field, we're loading all items, and the onSetItem method will be called so we can use it to update the selectData property and do the same when we select other default values using the onChange method. Set selectData with all additional fields that the select component needs using a template and loaded data.
How has this PR been tested?
Unit tests
Checklist: