Split the rendering of JavaScript action models and views.
Review Request #14665 — Created Oct. 31, 2025 and updated
We now have enough support for multiple views for the same action. It's
time to separate out the registration of the models and the views so
there's no longer a one-to-one association.The new
BaseAction.render_model_js()is responsible for writing the
JavaScript to render an action model. Every registered action in Python
will be registered in JavaScript.The existing
BaseAction.render_js()(old name currently kept for
compatibility reasons) will render the view. This is now only called
when the attachment points used on the page, rather than all attachment
points. That's handled in the{% actions_html %}template tag.The template tag renders the HTML for the attachment point where the
template tag is placed, and then sets up a page injection containing the
JavaScript views. Then, when rendering the JavaScript models, the
injected JavaScript views content will be included.Some of the design of this change is here to facilitate the upcoming
improvements to attachment points.
Unit tests pass.
Tested that all the actions on the page displayed and worked correctly.
| Summary | ID |
|---|---|
| 64080b45a209b91ad223a0767d2bc35bd728c884 |
| Description | From | Last Updated |
|---|---|---|
|
Might as well specify "action's Javascript model" here. |
|
|
|
We should be more specific here and say "... for action model". |
|
|
|
The part about setting up the model should be removed from the sentence now. |
|
|
|
It's a little bit confusing that we assign actions twice and iterate over for action in actions twice. Can we … |
|
|
|
Expected a string and instead saw %. Column: 2 Error code: W095 |
|
|
|
Expected ':' and instead saw 'load'. Column: 4 Error code: E021 |
|
|
|
Expected a JSON value. Column: 9 Error code: E003 |
|
|
|
Expected '}' and instead saw 'actions'. Column: 9 Error code: E021 |
|
|
|
Unrecoverable syntax error. (11% scanned). Column: 9 Error code: E041 |
|
|
|
Same comment as the one on /r/14663, should we |escapejs this? |
|
|
|
Expected a string and instead saw %. Column: 2 Error code: W095 |
|
|
|
Expected ':' and instead saw 'load'. Column: 4 Error code: E021 |
|
|
|
Expected '}' and instead saw 'actions'. Column: 9 Error code: E021 |
|
|
|
Unrecoverable syntax error. (12% scanned). Column: 9 Error code: E041 |
|
|
|
Expected a JSON value. Column: 9 Error code: E003 |
|
|
|
Expected a string and instead saw %. Column: 2 Error code: W095 |
|
|
|
Expected ':' and instead saw 'load'. Column: 4 Error code: E021 |
|
|
|
Expected a JSON value. Column: 9 Error code: E003 |
|
|
|
Expected '}' and instead saw 'actions'. Column: 9 Error code: E021 |
|
|
|
Unrecoverable syntax error. (12% scanned). Column: 9 Error code: E041 |
|
- Change Summary:
-
- Moved
attachmentPointIDfor the JS view intojs_view_dataso it's serialized like all other options. - Clarified some docs.
- Updated class attributes to use
ClassVar. - Updated the
actions_htmltemplate tag to better document the two different rendering passes, and to avoid theactionsvariable.
- Moved
- Commits:
-
Summary ID ac05257d3e82428a725f410c1bcd8cc5f9766b95 7e8c747c4b614b28203a4125e5d54bea5aaa4236 - Diff:
-
Revision 2 (+384 -300)
Checks run (1 failed, 1 succeeded)
JSHint
- Change Summary:
-
Fixed up incorrect naming in my templatetag update. We're rendering HTML, not action models.
- Commits:
-
Summary ID 7e8c747c4b614b28203a4125e5d54bea5aaa4236 64080b45a209b91ad223a0767d2bc35bd728c884 - Diff:
-
Revision 3 (+386 -302)