-
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
spike(action_lists)!: evaluation standalone #2753
base: master
Are you sure you want to change the base?
Conversation
@jfmcquade |
Thanks @chrismclarke. I've only had a chance for a quick look through, but the changes definitely make sense from a high level, it seems right that actions should evaluate only at the point of being triggered. I should get a chance to look in a bit more detail tomorrow. In terms of timelines, because of the potential for knock-ons with action handling and the critical status of two deployments currently being worked on ( |
NB, this should resolve #2622 |
PR Checklist
Breaking Changes
action_list evaluates using newer templated data system
This may lead to some unexpected behaviour if any action_lists include complex statements that mix variable references, e.g.
click | set_field : some_field : @local.some_value + 1
. I think these types of patterns had always been discouraged/not worked anyways (with preference of setting intermediate local variables instead), but just to be aware of some small potential for knock-on. Unfortunately we don't have many tests for action_list edge cases so might be good to check against existing debug sheets.action_list values references now auto-update
Previous workaround to specify
this.value
in action_lists to handle receiving updated value for triggered actions are no longer required. The syntax is still supported and not marked as deprecated (no plans to remove), but any documentation that refers to this could likely be updated.Description
Action lists are currently evaluated as part of main template container processing, meaning that all row action params and args are evaluated prior to the row that triggers them from rendering. There are 2 main drawbacks to this:
Actions need to be parsed even if they are never actually triggered. This isn't too expensive an operation, just lacking a bit in optimisation.
Actions can become stale if data changes between render and trigger. This typically happens if an is triggered by a component change (parsed action will have value before change), or if multiple actions are triggered in series where the first action manipulates data required for the second action.
This PR aims to detach action_list processing from the main templating system and instead only evaluate at the time of being triggered. This should address both issues above
Additionally it evaluates actions using the new app data templating system, which has better support for complex expressions such as inline JS evaluation
TODO
interceptTemplateContainerAction
from layout nav-group and refactor interceptor as requiredAuthor Notes
(TODO)
Review Notes
(TODO - identify which sheets best to check/debug functionality, create new sheets as required)
Dev Notes
The main changes here are to omit
action_list
fields from the template-row service evaluator, and add a new interceptor to the template container that sets values of any dynamic variables at the point of being triggered.There was a choice between trying to use the existing row processing system to just delay evaluation of actions until the point of being triggered, or migrate to the new app data templating system that was implemented to evaluate dynamic variables within data-items. I opted for the latter as long term I want to fully remove the legacy system as it focuses too much on individual string replacement and not evaluating expressions.
This means in the short term additional methods added to the template-variables to allow specific prefix evaluation (e.g. global, field, local) for either source of data - legacy
TemplateRowDynamicEvaluator
types (includes partial lookup/matches of things likefulExpression
andmatchedExpression
), as well as the newerITemplatedDataContextList
type which is essentially a dummy-table containing a list of all variables used so that they can be evaluated within a JS context (instead of string replacement). It also means refactoring some methods so that the can be exposed publically for use within the interceptor that evaluates action_list variables standaloneAdditionally, because the system of interceptors recently introduced only supports 1 interceptor per scope, where a scope is typically the nested name of a component that wants to intercept child actions (e.g. so a data_items container can intercept all item children actions), a small workaround has been added to allow a single non-scoped interceptor that applies to all actions within a container (each container creates it's own template-action service so can still have multiple across containers).
Follow-up
Beyond scope of this PR, but could be considered for future follow-up
fields: {some_field: true}
to object that can store metadata (if useful), e.g.@field
,@global
)this.
workarounds (or maybe add@this
/@self
namespace?)_triggeredBy
with actions (template container should be able to manage)template-variables.service
so that they do not need to be explicitly included in places liketemplate-process.service
orapp.component.ts
Git Issues
Closes #
Screenshots/Videos
If useful, provide screenshot or capture to highlight main changes