-
Notifications
You must be signed in to change notification settings - Fork 25
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
Refactor/set data action #2454
Draft
chrismclarke
wants to merge
65
commits into
master
Choose a base branch
from
refactor/set-data-action
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Refactor/set data action #2454
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ing-app-ui into refactor/set-item-action
6 tasks
…idemsinternational/open-app-builder into refactor/set-data-action
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
PR Checklist
TODO
Update 2024-11-09
Core set_data handling moved to standalone PR #2513 to try unblock and make easier to review
Update 2024-10-30
With further work on this feature it has become apparent that a complete rewrite is required, fully decoupling the
data_items
from bothitems
and template processors.Problem Statement
The fundamental issue is the way in which dynamic data is evaluated in stages, with a first pass at the templating level and then a second pass at the item level. This makes it impossible to evaluate data that combines both local and item contexts (e.g.
@item.number > @local.number
). The item code also contains a number of workarounds for partially parsed data which are hard to extend or work with, and is lacking in testing infrastructure to ensure changes do not have unforseen knock-ons.The existing item implementation is also lacking some functionality, such as the ability to refer to a target item with the correct context, e.g. to toggle the completed state of the next item you may try to use an action like
however both the _index lookup and completed lookup will operate on the current item. Similarly
set_items | completed: [email protected]
will set all item values to the initial item row valueSolution
The proposed solution is to completely rewrite the data_items system to be decoupled from both templating and items. It is intended that the rewrite is fully backwards-compatible with the current
data_items
syntax (no re-authoring required), and that once implemented it could also potentially be a replacement foritems
, unifying the two syntaxes.The solution also provides an alternative pathway to managing content with dynamic variables, which in turn could form the basis of a new templating system (discussed in Templating RFC)
Blocking
The system works when managing
@items
references, however an initial pass on item processing is handled in the main processor which also replaces@item
withthis.item
references. Whilst it is possible to just add ahackUnparseItem
method, this feels messy. Instead it would be better to improve the item handling at the parser level, to avoid replacing outside of the item processor. The challenge here is that the initialitems
template processor is reasonably untested and quite fragile, so changing as part of this PR isn't advisableDue to the closely coupled nature of the parser and items the best solution appears to be to mostly detach the
data_items
parsing from the template parser, and essentially handle it's own parsing from the ground up. Whilst it is still possible to expose and call methods from the current parser (e.g. processDynamicEvaluators), these methods themselves are quite hacky and have a number of issues (particularly regarding the way dynamic variables are replaced as strings one-by-one, making it harder to evaluate compound expressions, e.g.
@row.first_name === 'Ada'
replaces first_name without quotation).However a full solution for this will likely involve creating a new base parser that can convert full expressions to valid js and evaluate. E.g.
Hello @field.{@local.lookup_field}}
->
"Hello+' '+[field[local.lookup_field]]"
or
`Hello ${field[local.lookup_field]}`
Description
Re-implementation of #2388, to use
set_data
action globally and updateset_item
/set_items
actions in data_items list to call the global function.It also includes better test coverage, and support for items with dynamic expressions, such as global `set_da
Author Notes
General Use
Set values on a specific data_list item
Can include
@item
reference that will use existing row contextCan set item by
_index
Can target all items in a list (no current support for filtered subset) by omitting
_id
Dev Notes
Git Issues
Closes #
Screenshots/Videos
If useful, provide screenshot or capture to highlight main changes