Skip to content

Commit

Permalink
Use NodeTree as ES module
Browse files Browse the repository at this point in the history
We only use it on the nodes page and do not need to make globally
available thanks to script type module \o/
  • Loading branch information
tvdeyen committed Jun 28, 2023
1 parent 1b8086d commit 38e5308
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions app/assets/config/alchemy_manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
//= link_tree ../../../vendor/assets/fonts/
//= link_tree ../../../vendor/assets/images/
//= link alchemy_admin.js
//= link alchemy_admin/node_tree.js
2 changes: 0 additions & 2 deletions app/javascript/alchemy_admin.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import translate from "./alchemy_admin/i18n"
import translationData from "./alchemy_admin/translations"
import NodeTree from "./alchemy_admin/node_tree"
import fileEditors from "./alchemy_admin/file_editors"
import IngredientAnchorLink from "./alchemy_admin/ingredient_anchor_link"
import pictureEditors from "./alchemy_admin/picture_editors"
Expand All @@ -21,7 +20,6 @@ Object.assign(Alchemy, {
// Global utility method for translating a given string
t: translate,
translations: Object.assign(Alchemy.translations || {}, translationData),
NodeTree,
fileEditors,
pictureEditors,
ImageLoader: ImageLoader.init,
Expand Down
6 changes: 4 additions & 2 deletions app/views/alchemy/admin/nodes/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
<% end %>
</div>

<script>
Alchemy.NodeTree()
<script type="module">
import NodeTree from "alchemy_admin/node_tree"

NodeTree()
</script>
1 change: 1 addition & 0 deletions config/importmap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
pin "sortablejs", to: "https://ga.jspm.io/npm:sortablejs@1.15.0/modular/sortable.esm.js", preload: true

pin "alchemy_admin", to: "alchemy_admin.js", preload: true
pin "alchemy_admin/node_tree", to: "alchemy_admin/node_tree.js", preload: true

0 comments on commit 38e5308

Please sign in to comment.