-
-
Notifications
You must be signed in to change notification settings - Fork 271
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: register stimulus controllers from plugins
- Loading branch information
1 parent
e30fc28
commit fc85b7d
Showing
7 changed files
with
41 additions
and
2 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
app/components/avo/asset_manager/javascript_component.html.erb
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
<% javascripts.each do |path| %> | ||
<%= javascript_include_tag path, "data-turbo-track": "reload", defer: true %> | ||
<% end %> | ||
|
||
<%# Collect all the custom StimulusJS controllers from plugins. %> | ||
<%= javascript_tag nonce: true do %> | ||
Avo.configuration.stimulus_controllers = <%== Avo.asset_manager.stimulus_controllers.to_a.to_json %> | ||
<% end %> | ||
|
||
<%# This is the last script to run so it can register custom StimulusJS controllers from plugins. %> | ||
<%= javascript_include_tag 'late-registration', "data-turbo-track": "reload", defer: true %> |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const application = window.Stimulus | ||
|
||
// This is going run last so it can regiser custom StimulusJS controllers from plugins. | ||
if (window.Avo.configuration.stimulus_controllers) { | ||
window.Avo.configuration.stimulus_controllers.forEach(([name, controller]) => { | ||
application.register(name, window[controller]) | ||
}) | ||
} |
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
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