From 15343b98b40a148d00168342c07742e98a1e1898 Mon Sep 17 00:00:00 2001 From: Pablo Brasero Date: Fri, 17 Nov 2023 13:14:48 +0000 Subject: [PATCH] Got this to work on the groceries app --- app/assets/javascripts/administrate/application.js | 6 +++--- bin/importmap | 4 ---- config/importmap.rb | 4 +++- lib/administrate/engine.rb | 2 +- 4 files changed, 7 insertions(+), 9 deletions(-) delete mode 100755 bin/importmap diff --git a/app/assets/javascripts/administrate/application.js b/app/assets/javascripts/administrate/application.js index 9262515981..d7e5eaf930 100644 --- a/app/assets/javascripts/administrate/application.js +++ b/app/assets/javascripts/administrate/application.js @@ -4,8 +4,8 @@ import jQuery from "jquery" import Rails from "jquery-ujs" import "selectize" -import "./components/associative" -import "./components/select" -import "./components/table" +import "administrate/components/associative.js" +import "administrate/components/select.js" +import "administrate/components/table.js" Rails(jQuery) diff --git a/bin/importmap b/bin/importmap deleted file mode 100755 index 1ade1564c0..0000000000 --- a/bin/importmap +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env ruby - -require_relative "../spec/example_app/config/application" -require "importmap/commands" diff --git a/config/importmap.rb b/config/importmap.rb index 3727bf6cfe..b69035f9cf 100644 --- a/config/importmap.rb +++ b/config/importmap.rb @@ -1,6 +1,8 @@ # Pin npm packages by running ./bin/importmap -pin_all_from "app/javascript/administrate/components", under: "components" +pin "administrate/components/table.js", to: "administrate/components/table.js" +pin "administrate/components/associative.js", to: "administrate/components/associative.js" +pin "administrate/components/select.js", to: "administrate/components/select.js" pin "administrate/application", preload: true diff --git a/lib/administrate/engine.rb b/lib/administrate/engine.rb index 9694a05254..b406080676 100644 --- a/lib/administrate/engine.rb +++ b/lib/administrate/engine.rb @@ -23,7 +23,7 @@ class Engine < ::Rails::Engine @@stylesheets = [] initializer "administrate.importmap", before: "importmap" do |app| - app.config.importmap.paths root.join("config/importmap.rb") + app.config.importmap.paths << root.join("config/importmap.rb") end initializer "administrate.assets.precompile" do |app|