activeadmin 4.0.0.beta2 → 4.0.0.beta22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +18 -2
  3. data/CONTRIBUTING.md +13 -13
  4. data/README.md +4 -4
  5. data/UPGRADING.md +274 -0
  6. data/app/controllers/active_admin/base_controller/authorization.rb +1 -1
  7. data/app/controllers/active_admin/base_controller/menu.rb +2 -2
  8. data/app/controllers/active_admin/resource_controller/data_access.rb +9 -4
  9. data/app/controllers/active_admin/resource_controller/decorators.rb +1 -1
  10. data/app/controllers/active_admin/resource_controller/streaming.rb +3 -3
  11. data/app/controllers/active_admin/resource_controller.rb +1 -1
  12. data/app/helpers/active_admin/display_helper.rb +3 -3
  13. data/app/helpers/active_admin/form_helper.rb +1 -1
  14. data/app/helpers/active_admin/layout_helper.rb +2 -2
  15. data/app/javascript/active_admin/features/batch_actions.js +10 -4
  16. data/app/javascript/active_admin/features/main_menu.js +3 -2
  17. data/app/views/active_admin/_flash_messages.html.erb +4 -4
  18. data/app/views/active_admin/_main_navigation.html.erb +28 -11
  19. data/app/views/active_admin/_page_header.html.erb +2 -2
  20. data/app/views/active_admin/_site_footer.html.erb +1 -1
  21. data/app/views/active_admin/_site_header.html.erb +7 -7
  22. data/app/views/active_admin/devise/confirmations/new.html.erb +1 -1
  23. data/app/views/active_admin/devise/passwords/edit.html.erb +1 -1
  24. data/app/views/active_admin/devise/passwords/new.html.erb +1 -1
  25. data/app/views/active_admin/devise/registrations/new.html.erb +1 -1
  26. data/app/views/active_admin/devise/sessions/new.html.erb +1 -1
  27. data/app/views/active_admin/devise/unlocks/new.html.erb +1 -1
  28. data/app/views/active_admin/kaminari/_gap.html.erb +1 -1
  29. data/app/views/active_admin/kaminari/_next_page.html.erb +1 -1
  30. data/app/views/active_admin/kaminari/_prev_page.html.erb +1 -1
  31. data/app/views/active_admin/page/index.html.arb +1 -2
  32. data/app/views/active_admin/resource/_form.html.arb +0 -1
  33. data/app/views/active_admin/resource/_form_default.html.arb +0 -1
  34. data/app/views/active_admin/resource/_index_as_table_default.html.arb +0 -1
  35. data/app/views/active_admin/resource/_show_default.html.arb +0 -1
  36. data/app/views/active_admin/resource/edit.html.arb +0 -1
  37. data/app/views/active_admin/resource/index.html.arb +1 -2
  38. data/app/views/active_admin/resource/new.html.arb +0 -1
  39. data/app/views/active_admin/resource/show.html.arb +0 -1
  40. data/app/views/active_admin/shared/_resource_comments.html.erb +7 -7
  41. data/app/views/active_admin/shared/_sidebar_section.html.arb +0 -1
  42. data/app/views/layouts/active_admin.html.erb +1 -1
  43. data/config/importmap.rb +5 -0
  44. data/config/locales/ar.yml +136 -100
  45. data/config/locales/az.yml +103 -102
  46. data/config/locales/bg.yml +91 -90
  47. data/config/locales/bs.yml +95 -94
  48. data/config/locales/ca.yml +131 -77
  49. data/config/locales/cs.yml +82 -81
  50. data/config/locales/da.yml +102 -101
  51. data/config/locales/de.yml +130 -125
  52. data/config/locales/el.yml +94 -93
  53. data/config/locales/en-CA.yml +104 -103
  54. data/config/locales/en-GB.yml +104 -103
  55. data/config/locales/en.yml +134 -130
  56. data/config/locales/eo.yml +107 -106
  57. data/config/locales/es-MX.yml +70 -69
  58. data/config/locales/es.yml +129 -122
  59. data/config/locales/fa.yml +91 -90
  60. data/config/locales/fi.yml +84 -83
  61. data/config/locales/fr.yml +135 -126
  62. data/config/locales/he.yml +103 -102
  63. data/config/locales/hr.yml +95 -94
  64. data/config/locales/hu.yml +76 -75
  65. data/config/locales/id.yml +97 -96
  66. data/config/locales/it.yml +134 -124
  67. data/config/locales/ja.yml +109 -104
  68. data/config/locales/ko.yml +136 -92
  69. data/config/locales/lt.yml +106 -105
  70. data/config/locales/lv.yml +70 -69
  71. data/config/locales/mk.yml +100 -99
  72. data/config/locales/nb.yml +98 -97
  73. data/config/locales/nl.yml +113 -114
  74. data/config/locales/pl.yml +137 -130
  75. data/config/locales/pt-BR.yml +134 -105
  76. data/config/locales/pt-PT.yml +71 -70
  77. data/config/locales/ro.yml +74 -73
  78. data/config/locales/ru.yml +142 -106
  79. data/config/locales/sk.yml +131 -130
  80. data/config/locales/sv-SE.yml +126 -125
  81. data/config/locales/tr.yml +105 -104
  82. data/config/locales/uk.yml +140 -103
  83. data/config/locales/vi.yml +125 -124
  84. data/config/locales/zh-CN.yml +135 -125
  85. data/config/locales/zh-TW.yml +136 -100
  86. data/lib/active_admin/application.rb +5 -5
  87. data/lib/active_admin/application_settings.rb +1 -1
  88. data/lib/active_admin/async_count.rb +21 -0
  89. data/lib/active_admin/batch_actions/resource_extension.rb +2 -2
  90. data/lib/active_admin/batch_actions/views/batch_action_form.rb +1 -1
  91. data/lib/active_admin/batch_actions/views/selection_cells.rb +1 -1
  92. data/lib/active_admin/batch_actions.rb +4 -4
  93. data/lib/active_admin/collection_decorator.rb +1 -1
  94. data/lib/active_admin/csv_builder.rb +1 -1
  95. data/lib/active_admin/dependency.rb +1 -1
  96. data/lib/active_admin/dsl.rb +2 -2
  97. data/lib/active_admin/dynamic_settings_node.rb +2 -2
  98. data/lib/active_admin/engine.rb +5 -2
  99. data/lib/active_admin/filters/active.rb +2 -2
  100. data/lib/active_admin/filters/active_filter.rb +1 -7
  101. data/lib/active_admin/filters/forms.rb +0 -3
  102. data/lib/active_admin/filters/resource_extension.rb +2 -2
  103. data/lib/active_admin/filters.rb +5 -5
  104. data/lib/active_admin/form_builder.rb +4 -9
  105. data/lib/active_admin/helpers/optional_display.rb +1 -1
  106. data/lib/active_admin/inputs/filters/base/search_method_select.rb +2 -2
  107. data/lib/active_admin/inputs/filters/select_input.rb +1 -3
  108. data/lib/active_admin/localizers.rb +1 -1
  109. data/lib/active_admin/menu.rb +2 -2
  110. data/lib/active_admin/menu_item.rb +1 -1
  111. data/lib/active_admin/namespace.rb +1 -1
  112. data/lib/active_admin/namespace_settings.rb +1 -1
  113. data/lib/active_admin/orm/active_record/comments/views/active_admin_comments.rb +1 -1
  114. data/lib/active_admin/orm/active_record/comments/views.rb +2 -2
  115. data/lib/active_admin/orm/active_record/comments.rb +7 -7
  116. data/lib/active_admin/orm/active_record.rb +1 -1
  117. data/lib/active_admin/pundit_adapter.rb +4 -4
  118. data/lib/active_admin/resource/action_items.rb +3 -3
  119. data/lib/active_admin/resource/attributes.rb +8 -1
  120. data/lib/active_admin/resource/belongs_to.rb +0 -1
  121. data/lib/active_admin/resource/naming.rb +1 -1
  122. data/lib/active_admin/resource/page_presenters.rb +2 -2
  123. data/lib/active_admin/resource/sidebars.rb +1 -1
  124. data/lib/active_admin/resource.rb +21 -19
  125. data/lib/active_admin/resource_collection.rb +1 -1
  126. data/lib/active_admin/resource_dsl.rb +2 -2
  127. data/lib/active_admin/router.rb +5 -5
  128. data/lib/active_admin/scope.rb +10 -0
  129. data/lib/active_admin/version.rb +1 -1
  130. data/lib/active_admin/view_helpers/method_or_proc_helper.rb +1 -1
  131. data/lib/active_admin/views/components/active_admin_form.rb +2 -2
  132. data/lib/active_admin/views/components/attributes_table.rb +10 -4
  133. data/lib/active_admin/views/components/paginated_collection.rb +4 -1
  134. data/lib/active_admin/views/components/panel.rb +1 -1
  135. data/lib/active_admin/views/components/scopes.rb +26 -4
  136. data/lib/active_admin/views/components/table_for.rb +7 -2
  137. data/lib/active_admin/views/index_as_table.rb +22 -6
  138. data/lib/active_admin.rb +11 -6
  139. data/lib/activeadmin.rb +1 -1
  140. data/lib/generators/active_admin/assets/templates/active_admin.css +3 -3
  141. data/lib/generators/active_admin/assets/templates/tailwind.config.js +9 -5
  142. data/lib/generators/active_admin/devise/devise_generator.rb +2 -2
  143. data/lib/generators/active_admin/install/templates/active_admin.rb.erb +1 -1
  144. data/lib/generators/active_admin/resource/resource_generator.rb +6 -2
  145. data/lib/generators/active_admin/resource/templates/resource.rb.erb +2 -2
  146. data/plugin.js +424 -0
  147. data/vendor/javascript/flowbite.js +1 -2
  148. data/vendor/javascript/rails_ujs_esm.js +1 -0
  149. metadata +35 -20
  150. data/config/locales/de-CH.yml +0 -84
  151. data/lib/active_admin/views/components/tabs.rb +0 -40
@@ -1,112 +1,148 @@
1
- "zh-TW":
1
+ ---
2
+ zh-TW:
2
3
  active_admin:
3
- dashboard: 儀表板
4
- view: "檢視"
5
- edit: "編輯"
6
- delete: "刪除"
7
- delete_confirmation: "你確定要刪除嗎?"
8
- new_model: "新增 %{model}"
9
- edit_model: "編輯 %{model}"
10
- delete_model: "刪除 %{model}"
11
- details: "%{model} 明細"
12
- cancel: "取消"
13
- empty: "空的"
14
- previous: "前一個"
15
- next: "下一個"
16
- download: "下載:"
17
- has_many_new: "增加新的 %{model}"
18
- has_many_delete: "刪除"
19
- has_many_remove: "清除"
20
- filters:
21
- buttons:
22
- filter: "篩選"
23
- clear: "清除篩選條件"
24
- search_status:
25
- no_current_filters: "無"
26
- status_tag:
27
- "yes": "是"
28
- "no": "否"
29
- "unset": "否"
30
- logout: "登出"
31
- powered_by: "Powered by %{active_admin} %{version}"
32
- sidebars:
33
- filters: "篩選條件"
34
- search_status: "搜尋條件"
35
- pagination:
36
- empty: "找不到 %{model} "
37
- one: "顯示 <b>1</b> %{model}"
38
- one_page: "顯示 <b>全部 %{n}</b> %{model}"
39
- multiple: "總計 <b>%{total}</b> 顯示 %{model} 中<b>%{from}&nbsp;-&nbsp;%{to}</b> 筆"
40
- multiple_without_total: "顯示 %{model} 中<b>%{from}&nbsp;-&nbsp;%{to}</b> 筆"
41
- entry:
42
- one: "筆"
43
- other: "筆"
44
- any: "任何"
45
- blank_slate:
46
- content: "尚無 %{resource_name}"
47
- link: "建立一筆"
4
+ access_denied:
5
+ message: 你沒有權限執行此項操作
6
+ any: 任何
48
7
  batch_actions:
49
- button_label: "批次作業"
50
- default_confirmation: "你確定你要這樣做?"
51
- delete_confirmation: "你確定要刪除這些 %{plural_model} 嗎?"
52
- succesfully_destroyed:
53
- one: "成功刪除 1 %{model}"
54
- other: "成功刪除 %{count} %{plural_model}"
55
- selection_toggle_explanation: "(切換選取)"
56
8
  action_label: "%{title} 已選取"
9
+ button_label: 批次操作
10
+ default_confirmation: 你確定要這樣做嗎?
11
+ delete_confirmation: 你確定要刪除這些 %{plural_model} 嗎?
57
12
  labels:
58
- destroy: "刪除"
13
+ destroy: 刪除
14
+ selection_toggle_explanation: "(切換選取)"
15
+ successfully_destroyed:
16
+ one: 成功刪除 1 %{model}
17
+ other: 成功刪除 %{count} %{plural_model}
18
+ blank_slate:
19
+ content: 尚無 %{resource_name}。
20
+ link: 建立一筆
21
+ cancel: 取消
59
22
  comments:
60
- created_at: "建立"
61
- resource_type: "資源種類"
62
- author_type: "作者身份"
63
- body: "內文"
64
- author: "作者"
65
- add: "新增評論"
66
- delete: "刪除評論"
67
- delete_confirmation: "你確定要刪除這些評論嗎?"
68
- resource: "資源"
69
- no_comments_yet: "尚無評論"
70
- author_missing: "匿名"
71
- title_content: "(%{count}) 則評論"
23
+ add: 新增評論
24
+ author: 作者
25
+ author_missing: 匿名
26
+ author_type: 作者身份
27
+ body: 內文
28
+ created_at: 建立時間
29
+ delete: 刪除評論
30
+ delete_confirmation: 你確定要刪除這個評論嗎?
72
31
  errors:
73
- empty_text: "評論儲存失敗,不允許空白的內容。"
32
+ empty_text: 評論儲存失敗,不允許空白的內容。
33
+ no_comments_yet: 尚無評論
34
+ resource: 資源
35
+ resource_type: 資源類型
36
+ title_content: "%{count} 則評論"
37
+ create_another: 新增另一個 %{model}
38
+ dashboard: 儀表板
39
+ delete: 刪除
40
+ delete_confirmation: 你確定要刪除嗎?
41
+ delete_model: 刪除 %{model}
42
+ details: "%{model} 明細"
74
43
  devise:
75
- username:
76
- title: "帳號"
44
+ change_password:
45
+ submit: 更改我的密碼
46
+ title: 更改你的密碼
77
47
  email:
78
- title: "電子郵件信箱"
79
- subdomain:
80
- title: "子網域"
81
- password:
82
- title: "密碼"
83
- sign_up:
84
- title: "註冊"
85
- submit: "註冊"
48
+ title: 電子郵件信箱
49
+ links:
50
+ forgot_your_password: 忘記密碼?
51
+ resend_confirmation_instructions: 重新發送確認信
52
+ resend_unlock_instructions: 重新發送解鎖指示
53
+ sign_in: 登入
54
+ sign_in_with_omniauth_provider: 使用 %{provider} 登入
55
+ sign_up: 註冊
86
56
  login:
87
- title: "登入"
88
- remember_me: "記住我"
89
- submit: "登入"
57
+ remember_me: 記住我
58
+ submit: 登入
59
+ title: 登入
60
+ password:
61
+ title: 密碼
62
+ password_confirmation:
63
+ title: 確認密碼
64
+ resend_confirmation_instructions:
65
+ submit: 重新發送確認信
66
+ title: 重新發送確認信
90
67
  reset_password:
91
- title: "忘記密碼?"
92
- submit: "重置密碼"
93
- change_password:
94
- title: "更改你的密碼"
95
- submit: "更改我的密碼"
68
+ submit: 重設密碼
69
+ title: 忘記密碼?
70
+ sign_up:
71
+ submit: 註冊
72
+ title: 註冊
73
+ subdomain:
74
+ title: 子網域
96
75
  unlock:
97
- title: "重新發送解鎖指示"
98
- submit: "重新發送解鎖指示"
99
- resend_confirmation_instructions:
100
- title: '重新發送確認信'
101
- submit: '重新發送確認信'
102
- links:
103
- sign_up: "註冊"
104
- sign_in: "登入"
105
- forgot_your_password: "忘記密碼?"
106
- sign_in_with_omniauth_provider: "使用 %{provider} 登入"
107
- resend_unlock_instructions: "重新發送解鎖指示"
108
- resend_confirmation_instructions: "重新發送確認信"
109
- access_denied:
110
- message: "您沒有權限執行此項操作"
76
+ submit: 重新發送解鎖指示
77
+ title: 重新發送解鎖指示
78
+ username:
79
+ title: 帳號
80
+ download: 下載:
81
+ edit: 編輯
82
+ edit_model: 編輯 %{model}
83
+ empty: 空的
84
+ filters:
85
+ buttons:
86
+ clear: 清除篩選條件
87
+ filter: 篩選
88
+ predicates:
89
+ from:
90
+ to: 到
91
+ has_many_delete: 刪除
92
+ has_many_new: 增加新的 %{model}
93
+ has_many_remove: 移除
111
94
  index_list:
112
- table: "表格"
95
+ table: 表格
96
+ logout: 登出
97
+ move: 移動
98
+ new_model: 新增 %{model}
99
+ next: 下一個
100
+ pagination:
101
+ empty: 找不到 %{model}
102
+ entry:
103
+ one: 筆
104
+ other: 筆
105
+ multiple: 總計 <b>%{total}</b> 顯示 %{model} 中<b>%{from}&nbsp;-&nbsp;%{to}</b> 筆
106
+ multiple_without_total: 顯示 %{model} 中<b>%{from}&nbsp;-&nbsp;%{to}</b> 筆
107
+ next: 下一個
108
+ one: 顯示 <b>1</b> %{model}
109
+ one_page: 顯示 <b>全部 %{n}</b> %{model}
110
+ per_page: '每頁 '
111
+ previous: 前一個
112
+ truncate: "&hellip;"
113
+ powered_by: 由 %{active_admin} %{version} 提供
114
+ previous: 前一個
115
+ scopes:
116
+ all: 全部
117
+ search_status:
118
+ no_current_filters: 未套用篩選條件
119
+ title: 進行中的搜尋
120
+ title_with_scope: 正在搜尋 %{name}
121
+ sidebars:
122
+ filters: 篩選條件
123
+ search_status: 搜尋狀態
124
+ status_tag:
125
+ 'no': 否
126
+ unset: 未知
127
+ 'yes': 是
128
+ toggle_dark_mode: 切換暗黑模式
129
+ toggle_main_navigation_menu: 切換主要導覽
130
+ toggle_section: 切換區塊
131
+ toggle_user_menu: 切換使用者選單
132
+ view: 檢視
133
+ activerecord:
134
+ attributes:
135
+ active_admin/comment:
136
+ author_type: 作者類型
137
+ body: 內容
138
+ created_at: 建立時間
139
+ namespace: 命名空間
140
+ resource_type: 資源類型
141
+ updated_at: 更新時間
142
+ models:
143
+ active_admin/comment:
144
+ one: 評論
145
+ other: 評論
146
+ comment:
147
+ one: 評論
148
+ other: 評論
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
- require "active_admin/router"
3
- require "active_admin/application_settings"
4
- require "active_admin/namespace_settings"
2
+ require_relative "router"
3
+ require_relative "application_settings"
4
+ require_relative "namespace_settings"
5
5
 
6
6
  module ActiveAdmin
7
7
  class Application
@@ -101,7 +101,7 @@ module ActiveAdmin
101
101
  # Removes all defined controllers from memory. Useful in
102
102
  # development, where they are reloaded on each request.
103
103
  def unload!
104
- namespaces.each &:unload!
104
+ namespaces.each(&:unload!)
105
105
  @@loaded = false
106
106
  end
107
107
 
@@ -155,7 +155,7 @@ module ActiveAdmin
155
155
 
156
156
  def controllers_for_filters
157
157
  controllers = [BaseController]
158
- controllers.push *Devise.controllers_for_filters if Dependency.devise?
158
+ controllers.push(*Devise.controllers_for_filters) if Dependency.devise?
159
159
  controllers
160
160
  end
161
161
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require "active_admin/settings_node"
2
+ require_relative "settings_node"
3
3
 
4
4
  module ActiveAdmin
5
5
  class ApplicationSettings < SettingsNode
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+ module ActiveAdmin
3
+ class AsyncCount
4
+ class NotSupportedError < RuntimeError; end
5
+
6
+ def initialize(collection)
7
+ raise NotSupportedError, "#{collection.inspect} does not support :async_count" unless collection.respond_to?(:async_count)
8
+
9
+ @collection = collection.except(:select, :order)
10
+ @promise = @collection.async_count
11
+ end
12
+
13
+ def count
14
+ @promise.value
15
+ end
16
+
17
+ alias size count
18
+
19
+ delegate :except, :group_values, :length, :limit_value, to: :@collection
20
+ end
21
+ end
@@ -69,7 +69,7 @@ module ActiveAdmin
69
69
 
70
70
  redirect_to active_admin_config.route_collection_path(params),
71
71
  notice: I18n.t(
72
- "active_admin.batch_actions.succesfully_destroyed",
72
+ "active_admin.batch_actions.successfully_destroyed",
73
73
  count: selected_ids.count,
74
74
  model: active_admin_config.resource_label.downcase,
75
75
  plural_model: active_admin_config.plural_resource_label(count: selected_ids.count).downcase)
@@ -95,7 +95,7 @@ module ActiveAdmin
95
95
  # => Will create an action that appears in the action list popover
96
96
  #
97
97
  # BatchAction.new(:flag) { |selection| redirect_to collection_path, notice: "#{selection.length} users flagged" }
98
- # => Will create an action that uses a block to process the request (which receives one paramater of the selected objects)
98
+ # => Will create an action that uses a block to process the request (which receives one parameter of the selected objects)
99
99
  #
100
100
  # BatchAction.new("Perform Long Operation on") { |selection| }
101
101
  # => You can create batch actions with a title instead of a Symbol
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require "active_admin/component"
2
+ require_relative "../../component"
3
3
 
4
4
  module ActiveAdmin
5
5
  module BatchActions
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require "active_admin/component"
2
+ require_relative "../../component"
3
3
 
4
4
  module ActiveAdmin
5
5
  module BatchActions
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
  ActiveAdmin.before_load do |app|
3
- require "active_admin/batch_actions/resource_extension"
4
- require "active_admin/batch_actions/controller"
3
+ require_relative "batch_actions/resource_extension"
4
+ require_relative "batch_actions/controller"
5
5
 
6
6
  # Add our Extensions
7
7
  ActiveAdmin::Resource.send :include, ActiveAdmin::BatchActions::ResourceExtension
8
8
  ActiveAdmin::ResourceController.send :include, ActiveAdmin::BatchActions::Controller
9
9
 
10
- require "active_admin/batch_actions/views/batch_action_form"
11
- require "active_admin/batch_actions/views/selection_cells"
10
+ require_relative "batch_actions/views/batch_action_form"
11
+ require_relative "batch_actions/views/selection_cells"
12
12
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
  module ActiveAdmin
3
3
  # This class decorates a collection of objects delegating
4
- # mehods to behave like an Array. It's used to decouple ActiveAdmin
4
+ # methods to behave like an Array. It's used to decouple ActiveAdmin
5
5
  # from Draper and thus being able to use PORO decorators as well.
6
6
  #
7
7
  # It's implementation is heavily based on the Draper::CollectionDecorator
@@ -64,7 +64,7 @@ module ActiveAdmin
64
64
  def exec_columns(view_context = nil)
65
65
  @view_context = view_context
66
66
  @columns = [] # we want to re-render these every instance
67
- instance_exec &@block if @block.present?
67
+ instance_exec(&@block) if @block.present?
68
68
  columns
69
69
  end
70
70
 
@@ -2,7 +2,7 @@
2
2
  module ActiveAdmin
3
3
  module Dependency
4
4
  module Requirements
5
- DEVISE = ">= 4.0", "< 5"
5
+ DEVISE = ">= 4.0", "< 6"
6
6
  end
7
7
 
8
8
  # Provides a clean interface to check for gem dependencies at runtime.
@@ -13,7 +13,7 @@ module ActiveAdmin
13
13
 
14
14
  # Runs the registration block inside this object
15
15
  def run_registration_block(&block)
16
- instance_exec &block if block
16
+ instance_exec(&block) if block
17
17
  end
18
18
 
19
19
  # The instance of ActiveAdmin::Resource that's being registered
@@ -30,7 +30,7 @@ module ActiveAdmin
30
30
  @config
31
31
  end
32
32
 
33
- # Include a module with this resource. The modules's `included` method
33
+ # Include a module with this resource. The modules' `included` method
34
34
  # is called with the instance of the `ActiveAdmin::DSL` passed into it.
35
35
  #
36
36
  # eg:
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
- require "active_admin/dynamic_setting"
3
- require "active_admin/settings_node"
2
+ require_relative "dynamic_setting"
3
+ require_relative "settings_node"
4
4
 
5
5
  module ActiveAdmin
6
6
 
@@ -15,7 +15,10 @@ module ActiveAdmin
15
15
  end
16
16
  end
17
17
 
18
- initializer "active_admin.importmap", before: "importmap" do |app|
18
+ initializer "active_admin.importmap", after: "importmap" do |app|
19
+ # Skip if importmap-rails is not installed
20
+ next unless app.config.respond_to?(:importmap)
21
+
19
22
  ActiveAdmin.importmap.draw(Engine.root.join("config", "importmap.rb"))
20
23
  package_path = Engine.root.join("app/javascript")
21
24
  if app.config.respond_to?(:assets)
@@ -32,7 +35,7 @@ module ActiveAdmin
32
35
  end
33
36
 
34
37
  initializer "active_admin.routes" do
35
- require "active_admin/helpers/routes/url_helpers"
38
+ require_relative "helpers/routes/url_helpers"
36
39
  end
37
40
 
38
41
  initializer "active_admin.deprecator" do |app|
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require "active_admin/filters/active_filter"
2
+ require_relative "active_filter"
3
3
 
4
4
  module ActiveAdmin
5
5
  module Filters
@@ -11,7 +11,7 @@ module ActiveAdmin
11
11
  # @param resource [ActiveAdmin::Resource] current resource
12
12
  # @param search [Ransack::Search] search object
13
13
  #
14
- # @see ActiveAdmin::ResourceController::DataAcces#apply_filtering
14
+ # @see ActiveAdmin::ResourceController::DataAccess#apply_filtering
15
15
  def initialize(resource, search)
16
16
  @resource = resource
17
17
  @filters = build_filters(search.conditions)
@@ -38,9 +38,7 @@ module ActiveAdmin
38
38
  end
39
39
 
40
40
  def predicate_name
41
- I18n.t(
42
- "ransack.predicates.#{condition.predicate.name}",
43
- default: ransack_predicate_name)
41
+ Ransack::Translate.predicate(condition.predicate.name)
44
42
  end
45
43
 
46
44
  def html_options
@@ -78,10 +76,6 @@ module ActiveAdmin
78
76
  condition_attribute.attr_name
79
77
  end
80
78
 
81
- def ransack_predicate_name
82
- Ransack::Translate.predicate(condition.predicate.name)
83
- end
84
-
85
79
  def find_class?
86
80
  ["eq", "in"].include? condition.predicate.arel_predicate
87
81
  end
@@ -7,9 +7,6 @@ module ActiveAdmin
7
7
  include ::ActiveAdmin::Filters::FormtasticAddons
8
8
  self.input_namespaces = [::Object, ::ActiveAdmin::Inputs::Filters, ::ActiveAdmin::Inputs, ::Formtastic::Inputs]
9
9
 
10
- # TODO: remove input class finders after formtastic 4 (where it will be default)
11
- self.input_class_finder = ::Formtastic::InputClassFinder
12
-
13
10
  def filter(method, options = {})
14
11
  if method.present? && options[:as] ||= default_input_type(method)
15
12
  template.concat input(method, options)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require "active_admin/filters/active"
2
+ require_relative "active"
3
3
 
4
4
  module ActiveAdmin
5
5
  module Filters
@@ -146,7 +146,7 @@ module ActiveAdmin
146
146
  filters = poly.map(&:foreign_type) + low_arity.map(&:name) + high_arity
147
147
  end
148
148
 
149
- filters.map &:to_sym
149
+ filters.map(&:to_sym)
150
150
  else
151
151
  []
152
152
  end
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
- require "active_admin/filters/dsl"
3
- require "active_admin/filters/resource_extension"
4
- require "active_admin/filters/formtastic_addons"
5
- require "active_admin/filters/forms"
6
- require "active_admin/helpers/optional_display"
2
+ require_relative "filters/dsl"
3
+ require_relative "filters/resource_extension"
4
+ require_relative "filters/formtastic_addons"
5
+ require_relative "filters/forms"
6
+ require_relative "helpers/optional_display"
7
7
 
8
8
  # Add our Extensions
9
9
  ActiveAdmin::ResourceDSL.send :include, ActiveAdmin::Filters::DSL
@@ -17,10 +17,6 @@ module ActiveAdmin
17
17
 
18
18
  self.input_namespaces = [::Object, ::ActiveAdmin::Inputs, ::Formtastic::Inputs]
19
19
 
20
- # TODO: remove both class finders after formtastic 4 (where it will be default)
21
- self.input_class_finder = ::Formtastic::InputClassFinder
22
- self.action_class_finder = ::Formtastic::ActionClassFinder
23
-
24
20
  def cancel_link(url = { action: "index" }, html_options = {}, li_attrs = {})
25
21
  li_attrs[:class] ||= "action cancel"
26
22
  html_options[:class] ||= "cancel-link"
@@ -95,7 +91,7 @@ module ActiveAdmin
95
91
  contents = without_wrapper { inputs(options, &form_block) }
96
92
  contents ||= "".html_safe
97
93
 
98
- js = new_record ? js_for_has_many(options[:class], &form_block) : ""
94
+ js = new_record ? js_for_has_many(&form_block) : ""
99
95
  contents << js
100
96
  end
101
97
 
@@ -159,14 +155,13 @@ module ActiveAdmin
159
155
  end
160
156
 
161
157
  # Capture the ADD JS
162
- def js_for_has_many(class_string, &form_block)
158
+ def js_for_has_many(&form_block)
163
159
  assoc_name = assoc_klass.model_name
164
160
  placeholder = "NEW_#{assoc_name.to_s.underscore.upcase.tr('/', '_')}_RECORD"
165
- opts = {
161
+ opts = options.merge(
166
162
  for: [assoc, assoc_klass.new],
167
- class: class_string,
168
163
  for_options: { child_index: placeholder }
169
- }
164
+ )
170
165
  html = template.capture { __getobj__.send(:inputs_for_nested_attributes, opts, &form_block) }
171
166
  text = new_record.is_a?(String) ? new_record : I18n.t("active_admin.has_many_new", model: assoc_name.human)
172
167
 
@@ -23,7 +23,7 @@ module ActiveAdmin
23
23
  when Symbol, String
24
24
  render_context.public_send condition
25
25
  when Proc
26
- render_context.instance_exec &condition
26
+ render_context.instance_exec(&condition)
27
27
  else
28
28
  true
29
29
  end
@@ -26,7 +26,7 @@ module ActiveAdmin
26
26
  attr_reader :filters
27
27
 
28
28
  def filter(*filters)
29
- (@filters ||= []).push *filters
29
+ (@filters ||= []).push(*filters)
30
30
  end
31
31
  end
32
32
 
@@ -63,7 +63,7 @@ module ActiveAdmin
63
63
 
64
64
  def filter_options
65
65
  filters.collect do |filter|
66
- [I18n.t("ransack.predicates.#{filter}").capitalize, "#{method}_#{filter}"]
66
+ [Ransack::Translate.predicate(filter).capitalize, "#{method}_#{filter}"]
67
67
  end
68
68
  end
69
69
 
@@ -15,9 +15,7 @@ module ActiveAdmin
15
15
  if searchable_has_many_through?
16
16
  "#{reflection.through_reflection.name}_#{reflection.foreign_key}"
17
17
  else
18
- name = method.to_s
19
- name.concat "_#{reflection.association_primary_key}" if reflection_searchable?
20
- name
18
+ reflection_searchable? ? "#{method}_#{reflection.association_primary_key}" : method.to_s
21
19
  end
22
20
  end
23
21
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require "active_admin/localizers/resource_localizer"
2
+ require_relative "localizers/resource_localizer"
3
3
 
4
4
  module ActiveAdmin
5
5
  module Localizers
@@ -66,8 +66,8 @@ module ActiveAdmin
66
66
  end
67
67
 
68
68
  # Used in the UI to visually distinguish which menu item is selected.
69
- def current?(item)
70
- self == item || include?(item)
69
+ def current?(item, children: true)
70
+ self == item || (children && include?(item))
71
71
  end
72
72
 
73
73
  # Returns sorted array of menu items that should be displayed in this context.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require 'active_admin/view_helpers/method_or_proc_helper'
2
+ require_relative "view_helpers/method_or_proc_helper"
3
3
 
4
4
  module ActiveAdmin
5
5
  class MenuItem
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require "active_admin/resource_collection"
2
+ require_relative "resource_collection"
3
3
 
4
4
  module ActiveAdmin
5
5
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require "active_admin/dynamic_settings_node"
2
+ require_relative "dynamic_settings_node"
3
3
 
4
4
  module ActiveAdmin
5
5
  class NamespaceSettings < DynamicSettingsNode
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require "active_admin/views"
2
+ require_relative "../../../../views"
3
3
 
4
4
  module ActiveAdmin
5
5
  module Comments