activeadmin 4.0.0.beta3 → 4.0.0.beta9

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 (45) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +18 -2
  3. data/CONTRIBUTING.md +8 -12
  4. data/README.md +2 -2
  5. data/UPGRADING.md +6 -4
  6. data/app/controllers/active_admin/base_controller/authorization.rb +1 -1
  7. data/app/controllers/active_admin/resource_controller.rb +1 -1
  8. data/app/javascript/active_admin/features/batch_actions.js +10 -4
  9. data/app/views/active_admin/_main_navigation.html.erb +2 -2
  10. data/app/views/active_admin/_site_header.html.erb +3 -3
  11. data/app/views/active_admin/kaminari/_next_page.html.erb +1 -1
  12. data/app/views/active_admin/kaminari/_prev_page.html.erb +1 -1
  13. data/app/views/active_admin/resource/index.html.arb +1 -1
  14. data/config/importmap.rb +1 -1
  15. data/config/locales/ca.yml +85 -32
  16. data/config/locales/de.yml +16 -12
  17. data/config/locales/en.yml +6 -4
  18. data/config/locales/fr.yml +2 -4
  19. data/config/locales/it.yml +15 -7
  20. data/config/locales/nl.yml +2 -4
  21. data/config/locales/zh-CN.yml +4 -0
  22. data/config/locales/zh-TW.yml +49 -19
  23. data/lib/active_admin/batch_actions/resource_extension.rb +1 -1
  24. data/lib/active_admin/collection_decorator.rb +1 -1
  25. data/lib/active_admin/dsl.rb +1 -1
  26. data/lib/active_admin/engine.rb +4 -1
  27. data/lib/active_admin/pundit_adapter.rb +2 -2
  28. data/lib/active_admin/resource/attributes.rb +8 -1
  29. data/lib/active_admin/resource/page_presenters.rb +2 -2
  30. data/lib/active_admin/version.rb +1 -1
  31. data/lib/active_admin/views/components/active_admin_form.rb +1 -1
  32. data/lib/active_admin/views/components/panel.rb +1 -1
  33. data/lib/active_admin/views/components/scopes.rb +1 -1
  34. data/lib/active_admin/views/components/tabs.rb +2 -2
  35. data/lib/active_admin.rb +6 -1
  36. data/lib/generators/active_admin/assets/templates/tailwind.config.js +1 -1
  37. data/lib/generators/active_admin/install/templates/active_admin.rb.erb +1 -1
  38. data/lib/generators/active_admin/resource/resource_generator.rb +6 -2
  39. data/lib/generators/active_admin/resource/templates/resource.rb.erb +2 -2
  40. data/plugin.js +4 -5
  41. data/vendor/javascript/flowbite.js +1 -2
  42. data/vendor/javascript/rails_ujs_esm.js +1 -0
  43. metadata +21 -8
  44. data/config/i18n-tasks.yml +0 -37
  45. data/config/locales/de-CH.yml +0 -84
@@ -1,10 +1,27 @@
1
1
  "zh-TW":
2
+ activerecord:
3
+ models:
4
+ comment:
5
+ one: "評論"
6
+ other: "評論"
7
+ active_admin/comment:
8
+ one: "評論"
9
+ other: "評論"
10
+ attributes:
11
+ active_admin/comment:
12
+ author_type: "作者類型"
13
+ body: "內容"
14
+ created_at: "建立時間"
15
+ namespace: "命名空間"
16
+ resource_type: "資源類型"
17
+ updated_at: "更新時間"
2
18
  active_admin:
3
- dashboard: 儀表板
19
+ dashboard: "儀表板"
4
20
  view: "檢視"
5
21
  edit: "編輯"
6
22
  delete: "刪除"
7
23
  delete_confirmation: "你確定要刪除嗎?"
24
+ create_another: "新增另一個 %{model}"
8
25
  new_model: "新增 %{model}"
9
26
  edit_model: "編輯 %{model}"
10
27
  delete_model: "刪除 %{model}"
@@ -13,41 +30,52 @@
13
30
  empty: "空的"
14
31
  previous: "前一個"
15
32
  next: "下一個"
16
- download: "下載:"
33
+ download: "下載:"
17
34
  has_many_new: "增加新的 %{model}"
18
35
  has_many_delete: "刪除"
19
- has_many_remove: "清除"
36
+ has_many_remove: "移除"
37
+ move: "移動"
20
38
  filters:
21
39
  buttons:
22
40
  filter: "篩選"
23
41
  clear: "清除篩選條件"
42
+ predicates:
43
+ from: "從"
44
+ to: "到"
45
+ scopes:
46
+ all: "全部"
24
47
  search_status:
25
- no_current_filters: ""
48
+ title: "進行中的搜尋"
49
+ title_with_scope: "正在搜尋 %{name}"
50
+ no_current_filters: "未套用篩選條件"
26
51
  status_tag:
27
52
  "yes": "是"
28
53
  "no": "否"
29
- "unset": ""
54
+ "unset": "未知"
30
55
  logout: "登出"
31
- powered_by: "Powered by %{active_admin} %{version}"
56
+ powered_by: " %{active_admin} %{version} 提供"
32
57
  sidebars:
33
58
  filters: "篩選條件"
34
- search_status: "搜尋條件"
59
+ search_status: "搜尋狀態"
35
60
  pagination:
36
- empty: "找不到 %{model} "
61
+ empty: "找不到 %{model}"
37
62
  one: "顯示 <b>1</b> %{model}"
38
63
  one_page: "顯示 <b>全部 %{n}</b> %{model}"
39
64
  multiple: "總計 <b>%{total}</b> 顯示 %{model} 中<b>%{from}&nbsp;-&nbsp;%{to}</b> 筆"
40
65
  multiple_without_total: "顯示 %{model} 中<b>%{from}&nbsp;-&nbsp;%{to}</b> 筆"
66
+ per_page: "每頁 "
67
+ previous: "前一個"
68
+ next: "下一個"
41
69
  entry:
42
70
  one: "筆"
43
71
  other: "筆"
44
72
  any: "任何"
45
73
  blank_slate:
46
- content: "尚無 %{resource_name}"
74
+ content: "尚無 %{resource_name}"
47
75
  link: "建立一筆"
48
76
  batch_actions:
49
- button_label: "批次作業"
50
- default_confirmation: "你確定你要這樣做?"
77
+ button_label: "批次操作"
78
+ default_confirmation: "你確定要這樣做嗎?"
51
79
  delete_confirmation: "你確定要刪除這些 %{plural_model} 嗎?"
52
80
  succesfully_destroyed:
53
81
  one: "成功刪除 1 %{model}"
@@ -57,18 +85,18 @@
57
85
  labels:
58
86
  destroy: "刪除"
59
87
  comments:
60
- created_at: "建立"
61
- resource_type: "資源種類"
88
+ created_at: "建立時間"
89
+ resource_type: "資源類型"
62
90
  author_type: "作者身份"
63
91
  body: "內文"
64
92
  author: "作者"
65
93
  add: "新增評論"
66
94
  delete: "刪除評論"
67
- delete_confirmation: "你確定要刪除這些評論嗎?"
95
+ delete_confirmation: "你確定要刪除這個評論嗎?"
68
96
  resource: "資源"
69
97
  no_comments_yet: "尚無評論"
70
98
  author_missing: "匿名"
71
- title_content: "(%{count}) 則評論"
99
+ title_content: "%{count} 則評論"
72
100
  errors:
73
101
  empty_text: "評論儲存失敗,不允許空白的內容。"
74
102
  devise:
@@ -80,6 +108,8 @@
80
108
  title: "子網域"
81
109
  password:
82
110
  title: "密碼"
111
+ password_confirmation:
112
+ title: "確認密碼"
83
113
  sign_up:
84
114
  title: "註冊"
85
115
  submit: "註冊"
@@ -89,7 +119,7 @@
89
119
  submit: "登入"
90
120
  reset_password:
91
121
  title: "忘記密碼?"
92
- submit: "重置密碼"
122
+ submit: "重設密碼"
93
123
  change_password:
94
124
  title: "更改你的密碼"
95
125
  submit: "更改我的密碼"
@@ -97,8 +127,8 @@
97
127
  title: "重新發送解鎖指示"
98
128
  submit: "重新發送解鎖指示"
99
129
  resend_confirmation_instructions:
100
- title: '重新發送確認信'
101
- submit: '重新發送確認信'
130
+ title: "重新發送確認信"
131
+ submit: "重新發送確認信"
102
132
  links:
103
133
  sign_up: "註冊"
104
134
  sign_in: "登入"
@@ -107,6 +137,6 @@
107
137
  resend_unlock_instructions: "重新發送解鎖指示"
108
138
  resend_confirmation_instructions: "重新發送確認信"
109
139
  access_denied:
110
- message: "您沒有權限執行此項操作"
140
+ message: "你沒有權限執行此項操作"
111
141
  index_list:
112
142
  table: "表格"
@@ -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,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
@@ -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:
@@ -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)
@@ -19,7 +19,7 @@ module ActiveAdmin
19
19
  end
20
20
 
21
21
  def scope_collection(collection, action = Auth::READ)
22
- # scoping is appliable only to read/index action
22
+ # scoping is applicable only to read/index action
23
23
  # which means there is no way how to scope other actions
24
24
  Pundit.policy_scope!(user, namespace(collection))
25
25
  rescue Pundit::NotDefinedError => e
@@ -42,7 +42,7 @@ module ActiveAdmin
42
42
  end
43
43
 
44
44
  def format_action(action, subject)
45
- # https://github.com/varvet/pundit/blob/master/lib/generators/pundit/install/templates/application_policy.rb
45
+ # https://github.com/varvet/pundit/blob/main/lib/generators/pundit/install/templates/application_policy.rb
46
46
  case action
47
47
  when Auth::READ then subject.is_a?(Class) ? :index? : :show?
48
48
  when Auth::DESTROY then subject.is_a?(Class) ? :destroy_all? : :destroy?
@@ -37,7 +37,14 @@ module ActiveAdmin
37
37
  end
38
38
 
39
39
  def counter_cache_col?(c)
40
- c.name.end_with?("_count")
40
+ # This helper is called inside a loop. Let's memoize the result.
41
+ @counter_cache_columns ||= begin
42
+ resource_class.reflect_on_all_associations(:has_many)
43
+ .select(&:has_cached_counter?)
44
+ .map(&:counter_cache_column)
45
+ end
46
+
47
+ @counter_cache_columns.include?(c.name)
41
48
  end
42
49
 
43
50
  def filtered_col?(c)
@@ -51,7 +51,7 @@ module ActiveAdmin
51
51
  # Stores a config for all index actions supplied
52
52
  #
53
53
  # @param [Symbol] index_as The index type to store in the configuration
54
- # @param [PagePresenter] page_presenter The intance of PagePresenter to store
54
+ # @param [PagePresenter] page_presenter The instance of PagePresenter to store
55
55
  def set_index_presenter(index_as, page_presenter)
56
56
  page_presenters[:index] ||= {}
57
57
 
@@ -64,7 +64,7 @@ module ActiveAdmin
64
64
  page_presenters[:index][index_as] = page_presenter
65
65
  end
66
66
 
67
- # Returns the actual class for renderering the main content on the index
67
+ # Returns the actual class for rendering the main content on the index
68
68
  # page. To set this, use the :as option in the page_presenter block.
69
69
  #
70
70
  # @param [Symbol, Class] symbol_or_class The component symbol or class
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module ActiveAdmin
3
- VERSION = "4.0.0.beta3"
3
+ VERSION = "4.0.0.beta9"
4
4
  end
@@ -131,7 +131,7 @@ module ActiveAdmin
131
131
  html_options[:class] ||= "inputs"
132
132
  legend = args.shift if args.first.is_a?(::String)
133
133
  legend = html_options.delete(:name) if html_options.key?(:name)
134
- legend_tag = legend ? "<legend class=\"fieldset-title\">#{legend}</legend>" : ""
134
+ legend_tag = legend ? "<legend class=\"fieldset-title\">#{ERB::Util.html_escape(legend)}</legend>" : ""
135
135
  fieldset_attrs = html_options.map { |k, v| %Q{#{k}="#{v}"} }.join(" ")
136
136
  @opening_tag = "<fieldset #{fieldset_attrs}>#{legend_tag}<ol>"
137
137
  @closing_tag = "</ol></fieldset>"
@@ -22,7 +22,7 @@ module ActiveAdmin
22
22
 
23
23
  # Override children? to only report children when the panel's
24
24
  # contents have been added to. This ensures that the panel
25
- # correcly appends string values, etc.
25
+ # correctly appends string values, etc.
26
26
  def children?
27
27
  @contents.children?
28
28
  end
@@ -4,7 +4,7 @@ require "active_admin/view_helpers/method_or_proc_helper"
4
4
  module ActiveAdmin
5
5
  module Views
6
6
  # Renders a collection of ActiveAdmin::Scope objects as a
7
- # simple list with a seperator
7
+ # simple list with a separator
8
8
  class Scopes < ActiveAdmin::Component
9
9
  include ActiveAdmin::ScopeChain
10
10
 
@@ -19,8 +19,8 @@ module ActiveAdmin
19
19
 
20
20
  def build_menu_item(title, options, &block)
21
21
  fragment = options.fetch(:id, fragmentize(title))
22
- html_options = options.fetch(:html_options, {}).merge("data-tabs-target": "##{fragment}", role: "tab", "aria-controls": fragment)
23
- button html_options do
22
+ html_options = options.fetch(:html_options, {}).merge("data-tabs-target": "##{fragment}", role: "tab", "aria-controls": fragment, href: "#")
23
+ a html_options do
24
24
  title
25
25
  end
26
26
  end
data/lib/active_admin.rb CHANGED
@@ -9,6 +9,12 @@ require "formtastic_i18n"
9
9
  require "inherited_resources"
10
10
  require "arbre"
11
11
 
12
+ begin
13
+ require "importmap-rails"
14
+ rescue LoadError
15
+ # importmap-rails is optional
16
+ end
17
+
12
18
  module ActiveAdmin
13
19
 
14
20
  autoload :VERSION, "active_admin/version"
@@ -57,7 +63,6 @@ module ActiveAdmin
57
63
  end
58
64
 
59
65
  def importmap
60
- require "importmap-rails"
61
66
  @importmap ||= Importmap::Map.new
62
67
  end
63
68
 
@@ -11,7 +11,7 @@ module.exports = {
11
11
  './app/views/admin/**/*.{arb,erb,html,rb}',
12
12
  './app/javascript/**/*.js'
13
13
  ],
14
- darkMode: "class",
14
+ darkMode: "selector",
15
15
  plugins: [
16
16
  require(`@activeadmin/activeadmin/plugin`)
17
17
  ]
@@ -203,7 +203,7 @@ ActiveAdmin.setup do |config|
203
203
  #
204
204
  # config.namespace :admin do |admin|
205
205
  # admin.build_menu :default do |menu|
206
- # menu.add label: "My Great Website", url: "https://mygreatwebsite.example.com", html_options: { target: :blank }
206
+ # menu.add label: "My Great Website", url: "https://mygreatwebsite.example.com", html_options: { target: "_blank" }
207
207
  # end
208
208
  # end
209
209
 
@@ -16,8 +16,12 @@ module ActiveAdmin
16
16
  @attributes ||= class_name.constantize.new.attributes.keys
17
17
  end
18
18
 
19
+ def primary_key
20
+ @primary_key ||= [class_name.constantize.primary_key].flatten
21
+ end
22
+
19
23
  def assignable_attributes
20
- @assignable_attributes ||= attributes - %w(id created_at updated_at)
24
+ @assignable_attributes ||= attributes - primary_key - %w(created_at updated_at)
21
25
  end
22
26
 
23
27
  def permit_params
@@ -33,7 +37,7 @@ module ActiveAdmin
33
37
  end
34
38
 
35
39
  def columns
36
- attributes.map { |a| column(a) }.join("\n ")
40
+ (attributes - primary_key).map { |a| column(a) }.join("\n ")
37
41
  end
38
42
 
39
43
  def column(name)
@@ -16,7 +16,7 @@ ActiveAdmin.register <%= class_name %> do
16
16
  # Add or remove filters to toggle their visibility
17
17
  <%= filters %>
18
18
 
19
- # Add or remove columns to toggle their visiblity in the index action
19
+ # Add or remove columns to toggle their visibility in the index action
20
20
  index do
21
21
  selectable_column
22
22
  id_column
@@ -24,7 +24,7 @@ ActiveAdmin.register <%= class_name %> do
24
24
  actions
25
25
  end
26
26
 
27
- # Add or remove rows to toggle their visiblity in the show action
27
+ # Add or remove rows to toggle their visibility in the show action
28
28
  show do
29
29
  attributes_table_for(resource) do
30
30
  <%= rows %>
data/plugin.js CHANGED
@@ -44,7 +44,6 @@ module.exports = plugin(
44
44
  "[type='tel']",
45
45
  "[type='time']",
46
46
  "[type='week']",
47
- '[multiple]',
48
47
  'textarea',
49
48
  'select',
50
49
  ]]: {
@@ -475,8 +474,8 @@ module.exports = plugin(
475
474
  '.tabs-nav': {
476
475
  '@apply flex flex-wrap mb-2 text-sm font-medium text-center border-b border-gray-200 dark:border-gray-700': {}
477
476
  },
478
- '.tabs-nav > :where(button)': {
479
- '@apply inline-block p-4 border-b-2 border-transparent rounded-t-lg hover:text-gray-600 hover:border-gray-300 dark:hover:text-gray-300': {}
477
+ '.tabs-nav > :where(a)': {
478
+ '@apply block p-4 border-b-2 border-transparent rounded-t-md hover:text-gray-600 dark:hover:text-gray-300 no-underline': {}
480
479
  },
481
480
  '.tabs-content': {
482
481
  '@apply p-4 mb-6': {}
@@ -513,10 +512,10 @@ module.exports = plugin(
513
512
  '@apply text-gray-500 mt-2': {}
514
513
  },
515
514
  '.formtastic :where(.errors)': {
516
- '@apply p-4 mb-2 rounded-lg bg-red-50 text-red-800 dark:bg-red-800 dark:text-red-300': {}
515
+ '@apply p-4 mb-6 rounded-md space-y-2 bg-red-50 text-red-800 dark:bg-red-800 dark:text-red-300': {}
517
516
  },
518
517
  '.formtastic :where(.errors > li)': {
519
- '@apply list-disc ms-4 mb-1': {}
518
+ '@apply list-disc ms-4': {}
520
519
  },
521
520
  '.formtastic :where(.inline-errors)': {
522
521
  '@apply font-bold mt-2 text-red-600 dark:text-red-300': {}