From ebf2205b35bbec27d6f28af3848d9c0178a26483 Mon Sep 17 00:00:00 2001 From: Waymond Chen Date: Tue, 22 Nov 2022 16:36:50 +0000 Subject: [PATCH 1/6] Import jQuery in separate file to avoid hoisted variables --- src/rails_admin/base.js | 3 +-- src/rails_admin/jquery.js | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 src/rails_admin/jquery.js diff --git a/src/rails_admin/base.js b/src/rails_admin/base.js index 49020f81cc..ff7bba76cc 100644 --- a/src/rails_admin/base.js +++ b/src/rails_admin/base.js @@ -1,6 +1,6 @@ import Rails from "@rails/ujs"; import "@hotwired/turbo-rails"; -import jQuery from "jquery"; +import "./jquery"; import "./vendor/jquery_nested_form"; import "bootstrap"; @@ -27,4 +27,3 @@ import "./ui"; import "./widgets"; Rails.start(); -window.$ = window.jQuery = jQuery; diff --git a/src/rails_admin/jquery.js b/src/rails_admin/jquery.js new file mode 100644 index 0000000000..49c666fc80 --- /dev/null +++ b/src/rails_admin/jquery.js @@ -0,0 +1,2 @@ +import jQuery from "jquery"; +window.$ = window.jQuery = jQuery; From cabc8a5bef42af20752f141373356b92856d7f96 Mon Sep 17 00:00:00 2001 From: Waymond Chen Date: Thu, 24 Nov 2022 21:23:23 +0000 Subject: [PATCH 2/6] Add blank line for consistency --- src/rails_admin/jquery.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rails_admin/jquery.js b/src/rails_admin/jquery.js index 49c666fc80..40a3ce4f74 100644 --- a/src/rails_admin/jquery.js +++ b/src/rails_admin/jquery.js @@ -1,2 +1,3 @@ import jQuery from "jquery"; + window.$ = window.jQuery = jQuery; From 1a86248bc1bde4b1deed02fa2d86cad3eaa2adf3 Mon Sep 17 00:00:00 2001 From: Waymond Chen Date: Fri, 25 Nov 2022 14:53:12 +0000 Subject: [PATCH 3/6] Split lines for assignment --- src/rails_admin/jquery.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/rails_admin/jquery.js b/src/rails_admin/jquery.js index 40a3ce4f74..8188f4b0a0 100644 --- a/src/rails_admin/jquery.js +++ b/src/rails_admin/jquery.js @@ -1,3 +1,4 @@ import jQuery from "jquery"; -window.$ = window.jQuery = jQuery; +window.$ = jQuery; +window.jQuery = jQuery; From d0f963a385f545404bf4a54976485460bcedc42e Mon Sep 17 00:00:00 2001 From: Waymond Chen Date: Fri, 25 Nov 2022 16:01:35 +0000 Subject: [PATCH 4/6] Make option_name mutable to overcome frozen_string_literal --- lib/rails_admin/config/configurable.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rails_admin/config/configurable.rb b/lib/rails_admin/config/configurable.rb index 382677f2ee..e42cba8cdf 100644 --- a/lib/rails_admin/config/configurable.rb +++ b/lib/rails_admin/config/configurable.rb @@ -57,7 +57,7 @@ def register_instance_option(option_name, scope = self, &default) # If it's a boolean create an alias for it and remove question mark if option_name.end_with?('?') - scope.send(:define_method, "#{option_name.chop!}?") do + scope.send(:define_method, "#{(+option_name).chop!}?") do send(option_name) end end From 604543f1ea7de24825679097403022befbedb94a Mon Sep 17 00:00:00 2001 From: Waymond Chen Date: Fri, 25 Nov 2022 16:03:30 +0000 Subject: [PATCH 5/6] Return to one-liner init --- src/rails_admin/jquery.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/rails_admin/jquery.js b/src/rails_admin/jquery.js index 8188f4b0a0..40a3ce4f74 100644 --- a/src/rails_admin/jquery.js +++ b/src/rails_admin/jquery.js @@ -1,4 +1,3 @@ import jQuery from "jquery"; -window.$ = jQuery; -window.jQuery = jQuery; +window.$ = window.jQuery = jQuery; From de2b36116b1a7c5087cecd70a430d0ae17dc4e0c Mon Sep 17 00:00:00 2001 From: Waymond Chen Date: Fri, 25 Nov 2022 16:22:41 +0000 Subject: [PATCH 6/6] Remove unary operator --- lib/rails_admin/config/configurable.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rails_admin/config/configurable.rb b/lib/rails_admin/config/configurable.rb index e42cba8cdf..382677f2ee 100644 --- a/lib/rails_admin/config/configurable.rb +++ b/lib/rails_admin/config/configurable.rb @@ -57,7 +57,7 @@ def register_instance_option(option_name, scope = self, &default) # If it's a boolean create an alias for it and remove question mark if option_name.end_with?('?') - scope.send(:define_method, "#{(+option_name).chop!}?") do + scope.send(:define_method, "#{option_name.chop!}?") do send(option_name) end end