activeadmin 2.5.0 → 2.8.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of activeadmin might be problematic. Click here for more details.

Files changed (149) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +120 -6
  3. data/CONTRIBUTING.md +11 -57
  4. data/README.md +2 -2
  5. data/app/assets/javascripts/active_admin/base.js +26 -18
  6. data/app/assets/stylesheets/active_admin/_header.scss +37 -3
  7. data/app/assets/stylesheets/active_admin/components/_comments.scss +2 -2
  8. data/app/assets/stylesheets/active_admin/mixins/_variables.scss +3 -0
  9. data/app/javascript/active_admin/base.js +9 -0
  10. data/app/javascript/active_admin/initializers/per-page.js +1 -1
  11. data/app/javascript/active_admin/lib/checkbox-toggler.js +3 -3
  12. data/app/javascript/active_admin/lib/dropdown-menu.js +1 -1
  13. data/app/javascript/active_admin/lib/modal-dialog.js +7 -7
  14. data/app/javascript/active_admin/lib/per-page.js +1 -1
  15. data/app/javascript/active_admin/lib/table-checkbox-toggler.js +1 -1
  16. data/app/views/layouts/active_admin_logged_out.html.erb +15 -5
  17. data/config/locales/ar.yml +6 -6
  18. data/config/locales/en-CA.yml +3 -3
  19. data/config/locales/en-GB.yml +3 -3
  20. data/config/locales/en.yml +3 -3
  21. data/config/locales/es-MX.yml +2 -1
  22. data/config/locales/es.yml +5 -5
  23. data/config/locales/fr.yml +4 -4
  24. data/config/locales/it.yml +18 -0
  25. data/config/locales/ja.yml +3 -3
  26. data/config/locales/lv.yml +2 -2
  27. data/config/locales/vi.yml +6 -5
  28. data/docs/0-installation.md +26 -2
  29. data/docs/11-decorators.md +16 -5
  30. data/docs/2-resource-customization.md +10 -1
  31. data/docs/3-index-pages.md +1 -1
  32. data/docs/9-batch-actions.md +2 -2
  33. data/docs/Gemfile +2 -2
  34. data/docs/Gemfile.lock +93 -84
  35. data/docs/_includes/top-menu.html +1 -1
  36. data/docs/documentation.md +1 -1
  37. data/docs/index.html +6 -6
  38. data/lib/active_admin.rb +60 -60
  39. data/lib/active_admin/application.rb +13 -13
  40. data/lib/active_admin/application_settings.rb +3 -3
  41. data/lib/active_admin/authorization_adapter.rb +3 -3
  42. data/lib/active_admin/base_controller.rb +4 -4
  43. data/lib/active_admin/base_controller/authorization.rb +13 -12
  44. data/lib/active_admin/batch_actions/controller.rb +3 -3
  45. data/lib/active_admin/batch_actions/resource_extension.rb +9 -8
  46. data/lib/active_admin/batch_actions/views/batch_action_form.rb +3 -3
  47. data/lib/active_admin/batch_actions/views/batch_action_selector.rb +6 -6
  48. data/lib/active_admin/batch_actions/views/selection_cells.rb +3 -3
  49. data/lib/active_admin/cancan_adapter.rb +1 -1
  50. data/lib/active_admin/collection_decorator.rb +31 -0
  51. data/lib/active_admin/csv_builder.rb +11 -7
  52. data/lib/active_admin/dependency.rb +11 -11
  53. data/lib/active_admin/devise.rb +5 -5
  54. data/lib/active_admin/dsl.rb +1 -1
  55. data/lib/active_admin/dynamic_settings_node.rb +2 -2
  56. data/lib/active_admin/engine.rb +3 -3
  57. data/lib/active_admin/filters.rb +7 -7
  58. data/lib/active_admin/filters/active.rb +1 -1
  59. data/lib/active_admin/filters/active_filter.rb +5 -4
  60. data/lib/active_admin/filters/active_sidebar.rb +5 -5
  61. data/lib/active_admin/filters/forms.rb +6 -6
  62. data/lib/active_admin/filters/formtastic_addons.rb +1 -6
  63. data/lib/active_admin/filters/resource_extension.rb +1 -1
  64. data/lib/active_admin/form_builder.rb +21 -19
  65. data/lib/active_admin/generators/boilerplate.rb +1 -1
  66. data/lib/active_admin/helpers/optional_display.rb +2 -2
  67. data/lib/active_admin/inputs/datepicker_input.rb +1 -1
  68. data/lib/active_admin/inputs/filters/base.rb +1 -1
  69. data/lib/active_admin/inputs/filters/base/search_method_select.rb +4 -4
  70. data/lib/active_admin/inputs/filters/boolean_input.rb +1 -1
  71. data/lib/active_admin/inputs/filters/check_boxes_input.rb +1 -1
  72. data/lib/active_admin/inputs/filters/date_range_input.rb +12 -9
  73. data/lib/active_admin/inputs/filters/select_input.rb +2 -2
  74. data/lib/active_admin/localizers.rb +1 -1
  75. data/lib/active_admin/localizers/resource_localizer.rb +3 -3
  76. data/lib/active_admin/menu.rb +6 -3
  77. data/lib/active_admin/menu_item.rb +7 -7
  78. data/lib/active_admin/namespace.rb +12 -12
  79. data/lib/active_admin/namespace_settings.rb +8 -5
  80. data/lib/active_admin/order_clause.rb +1 -1
  81. data/lib/active_admin/orm/active_record.rb +1 -1
  82. data/lib/active_admin/orm/active_record/comments.rb +19 -19
  83. data/lib/active_admin/orm/active_record/comments/comment.rb +3 -3
  84. data/lib/active_admin/orm/active_record/comments/views.rb +2 -2
  85. data/lib/active_admin/orm/active_record/comments/views/active_admin_comments.rb +19 -19
  86. data/lib/active_admin/page.rb +1 -1
  87. data/lib/active_admin/pundit_adapter.rb +5 -5
  88. data/lib/active_admin/resource.rb +17 -17
  89. data/lib/active_admin/resource/action_items.rb +5 -5
  90. data/lib/active_admin/resource/attributes.rb +1 -1
  91. data/lib/active_admin/resource/belongs_to.rb +2 -2
  92. data/lib/active_admin/resource/controllers.rb +1 -1
  93. data/lib/active_admin/resource/menu.rb +4 -4
  94. data/lib/active_admin/resource/naming.rb +5 -5
  95. data/lib/active_admin/resource/routes.rb +5 -5
  96. data/lib/active_admin/resource/scope_to.rb +7 -7
  97. data/lib/active_admin/resource/sidebars.rb +1 -1
  98. data/lib/active_admin/resource_controller.rb +12 -11
  99. data/lib/active_admin/resource_controller/data_access.rb +1 -1
  100. data/lib/active_admin/resource_controller/decorators.rb +6 -26
  101. data/lib/active_admin/resource_controller/streaming.rb +7 -6
  102. data/lib/active_admin/resource_dsl.rb +5 -5
  103. data/lib/active_admin/scope.rb +6 -6
  104. data/lib/active_admin/version.rb +1 -1
  105. data/lib/active_admin/view_factory.rb +17 -17
  106. data/lib/active_admin/view_helpers.rb +1 -1
  107. data/lib/active_admin/view_helpers/breadcrumb_helper.rb +3 -3
  108. data/lib/active_admin/view_helpers/display_helper.rb +5 -5
  109. data/lib/active_admin/view_helpers/download_format_links_helper.rb +1 -1
  110. data/lib/active_admin/view_helpers/fields_for.rb +2 -2
  111. data/lib/active_admin/views.rb +1 -1
  112. data/lib/active_admin/views/components/active_admin_form.rb +5 -5
  113. data/lib/active_admin/views/components/attributes_table.rb +5 -5
  114. data/lib/active_admin/views/components/blank_slate.rb +1 -1
  115. data/lib/active_admin/views/components/dropdown_menu.rb +8 -8
  116. data/lib/active_admin/views/components/index_list.rb +3 -3
  117. data/lib/active_admin/views/components/menu.rb +1 -1
  118. data/lib/active_admin/views/components/menu_item.rb +4 -4
  119. data/lib/active_admin/views/components/paginated_collection.rb +18 -18
  120. data/lib/active_admin/views/components/panel.rb +1 -1
  121. data/lib/active_admin/views/components/scopes.rb +7 -5
  122. data/lib/active_admin/views/components/site_title.rb +1 -1
  123. data/lib/active_admin/views/components/status_tag.rb +11 -11
  124. data/lib/active_admin/views/components/table_for.rb +17 -17
  125. data/lib/active_admin/views/components/tabs.rb +3 -3
  126. data/lib/active_admin/views/footer.rb +2 -1
  127. data/lib/active_admin/views/header.rb +2 -2
  128. data/lib/active_admin/views/index_as_blog.rb +1 -1
  129. data/lib/active_admin/views/index_as_grid.rb +1 -1
  130. data/lib/active_admin/views/index_as_table.rb +16 -16
  131. data/lib/active_admin/views/pages/base.rb +14 -10
  132. data/lib/active_admin/views/pages/index.rb +14 -13
  133. data/lib/active_admin/views/tabbed_navigation.rb +2 -2
  134. data/lib/active_admin/views/title_bar.rb +1 -1
  135. data/lib/activeadmin.rb +1 -1
  136. data/lib/generators/active_admin/assets/assets_generator.rb +2 -2
  137. data/lib/generators/active_admin/assets/templates/active_admin.scss +2 -2
  138. data/lib/generators/active_admin/devise/devise_generator.rb +5 -5
  139. data/lib/generators/active_admin/install/install_generator.rb +14 -8
  140. data/lib/generators/active_admin/install/templates/active_admin.rb.erb +9 -2
  141. data/lib/generators/active_admin/page/page_generator.rb +1 -1
  142. data/lib/generators/active_admin/resource/resource_generator.rb +3 -3
  143. data/lib/generators/active_admin/webpacker/plugins/jquery.js +7 -0
  144. data/lib/generators/active_admin/webpacker/templates/active_admin.js +5 -0
  145. data/lib/generators/active_admin/webpacker/templates/active_admin.scss +17 -0
  146. data/lib/generators/active_admin/webpacker/templates/print.scss +2 -0
  147. data/lib/generators/active_admin/webpacker/webpacker_generator.rb +26 -0
  148. data/lib/ransack_ext.rb +8 -8
  149. metadata +20 -8
@@ -14,7 +14,7 @@ module ActiveAdmin
14
14
  end
15
15
 
16
16
  def permit_params
17
- assignable_attributes.map { |a| a.to_sym.inspect }.join(', ')
17
+ assignable_attributes.map { |a| a.to_sym.inspect }.join(", ")
18
18
  end
19
19
 
20
20
  def rows
@@ -15,7 +15,7 @@ module ActiveAdmin
15
15
 
16
16
  module OptionalDisplay
17
17
  def display_on?(action, render_context = self)
18
- return false if @options[:only] && !@options[:only].include?(action.to_sym)
18
+ return false if @options[:only] && !@options[:only].include?(action.to_sym)
19
19
  return false if @options[:except] && @options[:except].include?(action.to_sym)
20
20
 
21
21
  case condition = @options[:if]
@@ -31,7 +31,7 @@ module ActiveAdmin
31
31
  private
32
32
 
33
33
  def normalize_display_options!
34
- @options[:only] = Array(@options[:only]) if @options[:only]
34
+ @options[:only] = Array(@options[:only]) if @options[:only]
35
35
  @options[:except] = Array(@options[:except]) if @options[:except]
36
36
  end
37
37
  end
@@ -3,7 +3,7 @@ module ActiveAdmin
3
3
  class DatepickerInput < ::Formtastic::Inputs::StringInput
4
4
  def input_html_options
5
5
  super.tap do |options|
6
- options[:class] = [options[:class], "datepicker"].compact.join(' ')
6
+ options[:class] = [options[:class], "datepicker"].compact.join(" ")
7
7
  options[:data] ||= {}
8
8
  options[:data].merge! datepicker_options
9
9
  end
@@ -25,7 +25,7 @@ module ActiveAdmin
25
25
 
26
26
  def wrapper_html_options
27
27
  opts = super
28
- (opts[:class] ||= '') << " filter_form_field filter_#{as}"
28
+ (opts[:class] ||= "") << " filter_form_field filter_#{as}"
29
29
  opts
30
30
  end
31
31
 
@@ -31,15 +31,15 @@ module ActiveAdmin
31
31
 
32
32
  def wrapper_html_options
33
33
  opts = super
34
- (opts[:class] ||= '') << ' select_and_search' unless seems_searchable?
34
+ (opts[:class] ||= "") << " select_and_search" unless seems_searchable?
35
35
  opts
36
36
  end
37
37
 
38
38
  def to_html
39
39
  input_wrapping do
40
- label_html << # your label
40
+ label_html << # your label
41
41
  select_html << # the dropdown that holds the available search methods
42
- input_html # your input field
42
+ input_html # your input field
43
43
  end
44
44
  end
45
45
 
@@ -48,7 +48,7 @@ module ActiveAdmin
48
48
  end
49
49
 
50
50
  def select_html
51
- template.select_tag '', template.options_for_select(filter_options, current_filter)
51
+ template.select_tag "", template.options_for_select(filter_options, current_filter)
52
52
  end
53
53
 
54
54
  def filters
@@ -16,7 +16,7 @@ module ActiveAdmin
16
16
 
17
17
  # Provide the AA translation to the blank input field.
18
18
  def include_blank
19
- I18n.t 'active_admin.any' if super
19
+ I18n.t "active_admin.any" if super
20
20
  end
21
21
  end
22
22
  end
@@ -22,7 +22,7 @@ module ActiveAdmin
22
22
 
23
23
  # Add whitespace before label
24
24
  def choice_label(choice)
25
- ' ' + super
25
+ " " + super
26
26
  end
27
27
 
28
28
  # Don't wrap in UL tag
@@ -22,17 +22,20 @@ module ActiveAdmin
22
22
  column && column.type == :date ? "#{method}_lteq" : "#{method}_lteq_datetime"
23
23
  end
24
24
 
25
- def input_html_options_for(input_name = gt_input_name, placeholder = gt_input_placeholder)
26
- current_value = begin
27
- #cast value to date object before rendering input
28
- @object.public_send(input_name).to_s.to_date
29
- rescue
30
- nil
31
- end
25
+ def input_html_options
32
26
  { size: 12,
33
27
  class: "datepicker",
34
- maxlength: 10,
35
- placeholder: placeholder,
28
+ maxlength: 10 }.merge(options[:input_html] || {})
29
+ end
30
+
31
+ def input_html_options_for(input_name, placeholder)
32
+ current_value = begin
33
+ #cast value to date object before rendering input
34
+ @object.public_send(input_name).to_s.to_date
35
+ rescue
36
+ nil
37
+ end
38
+ { placeholder: placeholder,
36
39
  value: current_value ? current_value.strftime("%Y-%m-%d") : "" }.merge(input_html_options)
37
40
  end
38
41
 
@@ -7,7 +7,7 @@ module ActiveAdmin
7
7
  def input_name
8
8
  return method if seems_searchable?
9
9
 
10
- searchable_method_name + (multiple? ? '_in' : '_eq')
10
+ searchable_method_name + (multiple? ? "_in" : "_eq")
11
11
  end
12
12
 
13
13
  def searchable_method_name
@@ -22,7 +22,7 @@ module ActiveAdmin
22
22
 
23
23
  # Provide the AA translation to the blank input field.
24
24
  def include_blank
25
- I18n.t 'active_admin.any' if super
25
+ I18n.t "active_admin.any" if super
26
26
  end
27
27
 
28
28
  def input_html_options_name
@@ -1,4 +1,4 @@
1
- require 'active_admin/localizers/resource_localizer'
1
+ require "active_admin/localizers/resource_localizer"
2
2
 
3
3
  module ActiveAdmin
4
4
  module Localizers
@@ -19,16 +19,16 @@ module ActiveAdmin
19
19
 
20
20
  def translate(key, options = {})
21
21
  scope = options.delete(:scope)
22
- specific_key = array_to_key('resources', @model_name, scope, key)
22
+ specific_key = array_to_key("resources", @model_name, scope, key)
23
23
  defaults = [array_to_key(scope, key), key.to_s.titleize]
24
- ::I18n.t specific_key, options.reverse_merge(model: @model, default: defaults, scope: 'active_admin')
24
+ ::I18n.t specific_key, **options.reverse_merge(model: @model, default: defaults, scope: "active_admin")
25
25
  end
26
26
  alias_method :t, :translate
27
27
 
28
28
  protected
29
29
 
30
30
  def array_to_key(*arr)
31
- arr.flatten.compact.join('.').to_sym
31
+ arr.flatten.compact.join(".").to_sym
32
32
  end
33
33
  end
34
34
  end
@@ -47,7 +47,10 @@ module ActiveAdmin
47
47
  # menu.add parent: 'Dashboard', label: 'My Child Dashboard'
48
48
  #
49
49
  def add(options)
50
- item = if parent = options.delete(:parent)
50
+ parent_chain = Array.wrap(options.delete(:parent))
51
+
52
+ item = if parent = parent_chain.shift
53
+ options[:parent] = parent_chain if parent_chain.any?
51
54
  (self[parent] || add(label: parent)).add options
52
55
  else
53
56
  _add options.merge parent: self
@@ -60,7 +63,7 @@ module ActiveAdmin
60
63
 
61
64
  # Whether any children match the given item.
62
65
  def include?(item)
63
- @children.values.include? item
66
+ @children.values.include?(item) || @children.values.any? { |child| child.include?(item) }
64
67
  end
65
68
 
66
69
  # Used in the UI to visually distinguish which menu item is selected.
@@ -87,7 +90,7 @@ module ActiveAdmin
87
90
  def normalize_id(id)
88
91
  case id
89
92
  when String, Symbol, ActiveModel::Name
90
- id.to_s.downcase.tr ' ', '_'
93
+ id.to_s.downcase.tr " ", "_"
91
94
  when ActiveAdmin::Resource::Name
92
95
  id.param_key
93
96
  else
@@ -45,13 +45,13 @@ module ActiveAdmin
45
45
  #
46
46
  def initialize(options = {})
47
47
  super() # MenuNode
48
- @label = options[:label]
49
- @dirty_id = options[:id] || options[:label]
50
- @url = options[:url] || '#'
51
- @priority = options[:priority] || 10
52
- @html_options = options[:html_options] || {}
53
- @should_display = options[:if] || proc { true }
54
- @parent = options[:parent]
48
+ @label = options[:label]
49
+ @dirty_id = options[:id] || options[:label]
50
+ @url = options[:url] || "#"
51
+ @priority = options[:priority] || 10
52
+ @html_options = options[:html_options] || {}
53
+ @should_display = options[:if] || proc { true }
54
+ @parent = options[:parent]
55
55
 
56
56
  yield(self) if block_given? # Builder style syntax
57
57
  end
@@ -1,4 +1,4 @@
1
- require 'active_admin/resource_collection'
1
+ require "active_admin/resource_collection"
2
2
 
3
3
  module ActiveAdmin
4
4
 
@@ -31,7 +31,7 @@ module ActiveAdmin
31
31
  end
32
32
  end
33
33
 
34
- RegisterEvent = 'active_admin.namespace.register'.freeze
34
+ RegisterEvent = "active_admin.namespace.register".freeze
35
35
 
36
36
  attr_reader :application, :resources, :menus
37
37
 
@@ -149,10 +149,10 @@ module ActiveAdmin
149
149
  def add_logout_button_to_menu(menu, priority = 20, html_options = {})
150
150
  if logout_link_path
151
151
  html_options = html_options.reverse_merge(method: logout_link_method || :get)
152
- menu.add id: 'logout', priority: priority, html_options: html_options,
153
- label: -> { I18n.t 'active_admin.logout' },
154
- url: -> { render_or_call_method_or_proc_on self, active_admin_namespace.logout_link_path },
155
- if: :current_active_admin_user?
152
+ menu.add id: "logout", priority: priority, html_options: html_options,
153
+ label: -> { I18n.t "active_admin.logout" },
154
+ url: -> { render_or_call_method_or_proc_on self, active_admin_namespace.logout_link_path },
155
+ if: :current_active_admin_user?
156
156
  end
157
157
  end
158
158
 
@@ -164,10 +164,10 @@ module ActiveAdmin
164
164
  #
165
165
  def add_current_user_to_menu(menu, priority = 10, html_options = {})
166
166
  if current_user_method
167
- menu.add id: 'current_user', priority: priority, html_options: html_options,
168
- label: -> { display_name current_active_admin_user },
169
- url: -> { auto_url_for(current_active_admin_user) },
170
- if: :current_active_admin_user?
167
+ menu.add id: "current_user", priority: priority, html_options: html_options,
168
+ label: -> { display_name current_active_admin_user },
169
+ url: -> { auto_url_for(current_active_admin_user) },
170
+ if: :current_active_admin_user?
171
171
  end
172
172
  end
173
173
 
@@ -211,8 +211,8 @@ module ActiveAdmin
211
211
 
212
212
  def unload_resources!
213
213
  resources.each do |resource|
214
- parent = (module_name || 'Object').constantize
215
- name = resource.controller_name.split('::').last
214
+ parent = (module_name || "Object").constantize
215
+ name = resource.controller_name.split("::").last
216
216
  parent.send(:remove_const, name) if parent.const_defined?(name, false)
217
217
 
218
218
  # Remove circular references
@@ -1,4 +1,4 @@
1
- require 'active_admin/dynamic_settings_node'
1
+ require "active_admin/dynamic_settings_node"
2
2
 
3
3
  module ActiveAdmin
4
4
  class NamespaceSettings < DynamicSettingsNode
@@ -57,7 +57,7 @@ module ActiveAdmin
57
57
  register :filters, true
58
58
 
59
59
  # The namespace root
60
- register :root_to, 'dashboard#index'
60
+ register :root_to, "dashboard#index"
61
61
 
62
62
  # Options that are passed to root_to
63
63
  register :root_to_options, {}
@@ -73,7 +73,7 @@ module ActiveAdmin
73
73
  register :create_another, false
74
74
 
75
75
  # Default CSV options
76
- register :csv_options, { col_sep: ',', byte_order_mark: "\xEF\xBB\xBF" }
76
+ register :csv_options, { col_sep: ",", byte_order_mark: "\xEF\xBB\xBF" }
77
77
 
78
78
  # Default Download Links options
79
79
  register :download_links, true
@@ -102,7 +102,7 @@ module ActiveAdmin
102
102
  ]
103
103
 
104
104
  # Set flash message keys that shouldn't show in ActiveAdmin
105
- register :flash_keys_to_except, ['timedout']
105
+ register :flash_keys_to_except, ["timedout"]
106
106
 
107
107
  # Include association filters by default
108
108
  register :include_default_association_filters, true
@@ -118,6 +118,9 @@ module ActiveAdmin
118
118
  :title,
119
119
  :email,
120
120
  ]
121
- register :filter_method_for_large_association, '_starts_with'
121
+ register :filter_method_for_large_association, "_starts_with"
122
+
123
+ # Switch between asset pipeline and webpacker assets
124
+ register :use_webpacker, false
122
125
  end
123
126
  end
@@ -20,7 +20,7 @@ module ActiveAdmin
20
20
  end
21
21
 
22
22
  def to_sql
23
- [table_column, @op, ' ', @order].compact.join
23
+ [table_column, @op, " ", @order].compact.join
24
24
  end
25
25
 
26
26
  def table
@@ -2,4 +2,4 @@
2
2
 
3
3
  ActiveAdmin::DatabaseHitDuringLoad.database_error_classes << ActiveRecord::StatementInvalid
4
4
 
5
- require 'active_admin/orm/active_record/comments'
5
+ require "active_admin/orm/active_record/comments"
@@ -1,21 +1,21 @@
1
- require 'active_admin/orm/active_record/comments/views'
2
- require 'active_admin/orm/active_record/comments/show_page_helper'
3
- require 'active_admin/orm/active_record/comments/namespace_helper'
4
- require 'active_admin/orm/active_record/comments/resource_helper'
1
+ require "active_admin/orm/active_record/comments/views"
2
+ require "active_admin/orm/active_record/comments/show_page_helper"
3
+ require "active_admin/orm/active_record/comments/namespace_helper"
4
+ require "active_admin/orm/active_record/comments/resource_helper"
5
5
 
6
6
  # Add the comments configuration
7
- ActiveAdmin::Application.inheritable_setting :comments, true
8
- ActiveAdmin::Application.inheritable_setting :comments_registration_name, 'Comment'
9
- ActiveAdmin::Application.inheritable_setting :comments_order, "created_at ASC"
10
- ActiveAdmin::Application.inheritable_setting :comments_menu, {}
7
+ ActiveAdmin::Application.inheritable_setting :comments, true
8
+ ActiveAdmin::Application.inheritable_setting :comments_registration_name, "Comment"
9
+ ActiveAdmin::Application.inheritable_setting :comments_order, "created_at ASC"
10
+ ActiveAdmin::Application.inheritable_setting :comments_menu, {}
11
11
 
12
12
  # Insert helper modules
13
13
  ActiveAdmin::Namespace.send :include, ActiveAdmin::Comments::NamespaceHelper
14
- ActiveAdmin::Resource.send :include, ActiveAdmin::Comments::ResourceHelper
14
+ ActiveAdmin::Resource.send :include, ActiveAdmin::Comments::ResourceHelper
15
15
  ActiveAdmin.application.view_factory.show_page.send :include, ActiveAdmin::Comments::ShowPageHelper
16
16
 
17
17
  # Load the model as soon as it's referenced. By that point, Rails & Kaminari will be ready
18
- ActiveAdmin.autoload :Comment, 'active_admin/orm/active_record/comments/comment'
18
+ ActiveAdmin.autoload :Comment, "active_admin/orm/active_record/comments/comment"
19
19
 
20
20
  # Hint i18n-tasks about model and attribute translations used by default install
21
21
  # i18n-tasks-use t('activerecord.models.comment')
@@ -36,7 +36,7 @@ ActiveAdmin.after_load do |app|
36
36
 
37
37
  menu namespace.comments ? namespace.comments_menu : false
38
38
 
39
- config.comments = false # Don't allow comments on comments
39
+ config.comments = false # Don't allow comments on comments
40
40
  config.batch_actions = false # The default destroy batch action isn't showing up anyway...
41
41
 
42
42
  scope :all, show_count: false
@@ -51,7 +51,7 @@ ActiveAdmin.after_load do |app|
51
51
  # Store the author and namespace
52
52
  before_save do |comment|
53
53
  comment.namespace = active_admin_config.namespace.name
54
- comment.author = current_active_admin_user
54
+ comment.author = current_active_admin_user
55
55
  end
56
56
 
57
57
  controller do
@@ -67,7 +67,7 @@ ActiveAdmin.after_load do |app|
67
67
  redirect_back fallback_location: active_admin_root
68
68
  end
69
69
  failure.html do
70
- flash[:error] = I18n.t 'active_admin.comments.errors.empty_text'
70
+ flash[:error] = I18n.t "active_admin.comments.errors.empty_text"
71
71
  redirect_back fallback_location: active_admin_root
72
72
  end
73
73
  end
@@ -88,12 +88,12 @@ ActiveAdmin.after_load do |app|
88
88
  permit_params :body, :namespace, :resource_id, :resource_type
89
89
 
90
90
  index do
91
- column I18n.t('active_admin.comments.resource_type'), :resource_type
92
- column I18n.t('active_admin.comments.author_type'), :author_type
93
- column I18n.t('active_admin.comments.resource'), :resource
94
- column I18n.t('active_admin.comments.author'), :author
95
- column I18n.t('active_admin.comments.body'), :body
96
- column I18n.t('active_admin.comments.created_at'), :created_at
91
+ column I18n.t("active_admin.comments.resource_type"), :resource_type
92
+ column I18n.t("active_admin.comments.author_type"), :author_type
93
+ column I18n.t("active_admin.comments.resource"), :resource
94
+ column I18n.t("active_admin.comments.author"), :author
95
+ column I18n.t("active_admin.comments.body"), :body
96
+ column I18n.t("active_admin.comments.created_at"), :created_at
97
97
  actions
98
98
  end
99
99
  end
@@ -4,7 +4,7 @@ module ActiveAdmin
4
4
  self.table_name = "#{table_name_prefix}active_admin_comments#{table_name_suffix}"
5
5
 
6
6
  belongs_to :resource, polymorphic: true, optional: true
7
- belongs_to :author, polymorphic: true
7
+ belongs_to :author, polymorphic: true
8
8
 
9
9
  validates_presence_of :body, :namespace, :resource
10
10
 
@@ -18,8 +18,8 @@ module ActiveAdmin
18
18
  def self.find_for_resource_in_namespace(resource, namespace)
19
19
  where(
20
20
  resource_type: resource_type(resource),
21
- resource_id: resource.id,
22
- namespace: namespace.to_s
21
+ resource_id: resource.id,
22
+ namespace: namespace.to_s
23
23
  ).order(ActiveAdmin.application.namespaces[namespace.to_sym].comments_order)
24
24
  end
25
25
 
@@ -1,2 +1,2 @@
1
- require 'active_admin/views'
2
- require 'active_admin/orm/active_record/comments/views/active_admin_comments'
1
+ require "active_admin/views"
2
+ require "active_admin/orm/active_record/comments/views/active_admin_comments"
@@ -1,5 +1,5 @@
1
- require 'active_admin/views'
2
- require 'active_admin/views/components/panel'
1
+ require "active_admin/views"
2
+ require "active_admin/views/components/panel"
3
3
 
4
4
  module ActiveAdmin
5
5
  module Comments
@@ -22,13 +22,13 @@ module ActiveAdmin
22
22
  protected
23
23
 
24
24
  def title
25
- I18n.t 'active_admin.comments.title_content', count: @comments.total_count
25
+ I18n.t "active_admin.comments.title_content", count: @comments.total_count
26
26
  end
27
27
 
28
28
  def build_comments
29
29
  if @comments.any?
30
30
  @comments.each(&method(:build_comment))
31
- div page_entries_info(@comments).html_safe, class: 'pagination_information'
31
+ div page_entries_info(@comments).html_safe, class: "pagination_information"
32
32
  else
33
33
  build_empty_message
34
34
  end
@@ -42,56 +42,56 @@ module ActiveAdmin
42
42
 
43
43
  def build_comment(comment)
44
44
  div for: comment do
45
- div class: 'active_admin_comment_meta' do
46
- h4 class: 'active_admin_comment_author' do
47
- comment.author ? auto_link(comment.author) : I18n.t('active_admin.comments.author_missing')
45
+ div class: "active_admin_comment_meta" do
46
+ h4 class: "active_admin_comment_author" do
47
+ comment.author ? auto_link(comment.author) : I18n.t("active_admin.comments.author_missing")
48
48
  end
49
49
  span pretty_format comment.created_at
50
50
  if authorized?(ActiveAdmin::Auth::DESTROY, comment)
51
- text_node link_to I18n.t('active_admin.comments.delete'), comments_url(comment.id), method: :delete, data: { confirm: I18n.t('active_admin.comments.delete_confirmation') }
51
+ text_node link_to I18n.t("active_admin.comments.delete"), comments_url(comment.id), method: :delete, data: { confirm: I18n.t("active_admin.comments.delete_confirmation") }
52
52
  end
53
53
  end
54
- div class: 'active_admin_comment_body' do
54
+ div class: "active_admin_comment_body" do
55
55
  simple_format comment.body
56
56
  end
57
57
  end
58
58
  end
59
59
 
60
60
  def build_empty_message
61
- span I18n.t('active_admin.comments.no_comments_yet'), class: 'empty'
61
+ span I18n.t("active_admin.comments.no_comments_yet"), class: "empty"
62
62
  end
63
63
 
64
64
  def comments_url(*args)
65
65
  parts = []
66
66
  parts << active_admin_namespace.name unless active_admin_namespace.root?
67
67
  parts << active_admin_namespace.comments_registration_name.underscore
68
- parts << 'path'
69
- send parts.join('_'), *args
68
+ parts << "path"
69
+ send parts.join("_"), *args
70
70
  end
71
71
 
72
72
  def comment_form_url
73
73
  parts = []
74
74
  parts << active_admin_namespace.name unless active_admin_namespace.root?
75
75
  parts << active_admin_namespace.comments_registration_name.underscore.pluralize
76
- parts << 'path'
77
- send parts.join '_'
76
+ parts << "path"
77
+ send parts.join "_"
78
78
  end
79
79
 
80
80
  def build_comment_form
81
81
  active_admin_form_for(ActiveAdmin::Comment.new, url: comment_form_url) do |f|
82
82
  f.inputs do
83
- f.input :resource_type, as: :hidden, input_html: { value: ActiveAdmin::Comment.resource_type(parent.resource) }
84
- f.input :resource_id, as: :hidden, input_html: { value: parent.resource.id }
85
- f.input :body, label: false, input_html: { size: '80x8' }
83
+ f.input :resource_type, as: :hidden, input_html: { value: ActiveAdmin::Comment.resource_type(parent.resource) }
84
+ f.input :resource_id, as: :hidden, input_html: { value: parent.resource.id }
85
+ f.input :body, label: false, input_html: { size: "80x8" }
86
86
  end
87
87
  f.actions do
88
- f.action :submit, label: I18n.t('active_admin.comments.add')
88
+ f.action :submit, label: I18n.t("active_admin.comments.add")
89
89
  end
90
90
  end
91
91
  end
92
92
 
93
93
  def default_id_for_prefix
94
- 'active_admin_comments_for'
94
+ "active_admin_comments_for"
95
95
  end
96
96
  end
97
97