activeadmin 1.0.0.pre2 → 1.0.0.pre3
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.
- checksums.yaml +4 -4
- data/.hound.yml +7 -4
- data/.travis.yml +17 -15
- data/CHANGELOG.md +5 -1
- data/CODE_OF_CONDUCT.md +22 -0
- data/Gemfile +26 -12
- data/README.md +24 -4
- data/activeadmin.gemspec +1 -0
- data/app/assets/javascripts/active_admin/base.js.coffee +1 -1
- data/app/assets/javascripts/active_admin/initializers/batch_actions.js.coffee +7 -0
- data/app/assets/javascripts/active_admin/initializers/datepicker.js.coffee +10 -0
- data/app/assets/javascripts/active_admin/initializers/filters.js.coffee +15 -0
- data/app/assets/javascripts/active_admin/initializers/tabs.js.coffee +3 -0
- data/app/assets/javascripts/active_admin/lib/batch_actions.js.coffee +1 -1
- data/app/assets/javascripts/active_admin/lib/dropdown-menu.js.coffee +1 -1
- data/app/assets/stylesheets/active_admin/_forms.scss +1 -1
- data/config/locales/ar.yml +47 -43
- data/config/locales/de.yml +2 -1
- data/config/locales/en.yml +2 -1
- data/config/locales/es-MX.yml +3 -3
- data/config/locales/es.yml +5 -4
- data/config/locales/fr.yml +2 -1
- data/config/locales/hu.yml +1 -1
- data/config/locales/id.yml +2 -1
- data/config/locales/it.yml +19 -0
- data/config/locales/ja.yml +2 -1
- data/config/locales/ko.yml +2 -1
- data/config/locales/nb.yml +6 -1
- data/config/locales/nl.yml +1 -1
- data/config/locales/pt-BR.yml +5 -1
- data/config/locales/ru.yml +4 -3
- data/config/locales/sv-SE.yml +3 -2
- data/config/locales/tr.yml +83 -44
- data/config/locales/uk.yml +13 -12
- data/config/locales/zh-CN.yml +2 -1
- data/config/locales/zh-TW.yml +10 -1
- data/cucumber.yml +1 -1
- data/docs/0-installation.md +24 -10
- data/docs/1-general-configuration.md +22 -0
- data/docs/12-arbre-components.md +1 -1
- data/docs/13-authorization-adapter.md +1 -1
- data/docs/14-gotchas.md +11 -3
- data/docs/2-resource-customization.md +16 -3
- data/docs/3-index-pages.md +1 -1
- data/docs/3-index-pages/index-as-table.md +13 -1
- data/docs/4-csv-format.md +19 -0
- data/docs/5-forms.md +14 -2
- data/docs/6-show-pages.md +1 -1
- data/features/decorators.feature +2 -0
- data/features/development_reloading.feature +1 -1
- data/features/edit_page.feature +4 -4
- data/features/index/batch_actions.feature +13 -0
- data/features/index/page_title.feature +2 -1
- data/features/new_page.feature +4 -4
- data/features/renamed_resource.feature +1 -1
- data/features/show/default_content.feature +1 -1
- data/features/show/page_title.feature +2 -1
- data/features/step_definitions/attribute_steps.rb +2 -2
- data/features/step_definitions/factory_steps.rb +2 -2
- data/features/step_definitions/filter_steps.rb +2 -2
- data/features/step_definitions/format_steps.rb +1 -1
- data/features/sti_resource.feature +2 -2
- data/features/strong_parameters.feature +3 -3
- data/features/support/env.rb +21 -4
- data/lib/active_admin/application.rb +11 -4
- data/lib/active_admin/authorization_adapter.rb +1 -1
- data/lib/active_admin/base_controller.rb +12 -2
- data/lib/active_admin/base_controller/authorization.rb +4 -7
- data/lib/active_admin/base_controller/menu.rb +5 -1
- data/lib/active_admin/batch_actions/controller.rb +0 -1
- data/lib/active_admin/batch_actions/resource_extension.rb +3 -2
- data/lib/active_admin/batch_actions/views/batch_action_selector.rb +1 -0
- data/lib/active_admin/csv_builder.rb +18 -15
- data/lib/active_admin/dependency.rb +74 -1
- data/lib/active_admin/error.rb +1 -1
- data/lib/active_admin/filters/active.rb +4 -3
- data/lib/active_admin/filters/resource_extension.rb +7 -3
- data/lib/active_admin/generators/boilerplate.rb +8 -0
- data/lib/active_admin/inputs/filters/base.rb +3 -1
- data/lib/active_admin/inputs/filters/base/search_method_select.rb +3 -3
- data/lib/active_admin/inputs/filters/date_range_input.rb +2 -2
- data/lib/active_admin/inputs/filters/select_input.rb +3 -2
- data/lib/active_admin/orm/active_record/comments.rb +13 -8
- data/lib/active_admin/page_controller.rb +5 -1
- data/lib/active_admin/reloader.rb +25 -0
- data/lib/active_admin/resource/menu.rb +1 -1
- data/lib/active_admin/resource_controller/data_access.rb +33 -20
- data/lib/active_admin/resource_controller/decorators.rb +2 -2
- data/lib/active_admin/resource_controller/streaming.rb +7 -1
- data/lib/active_admin/resource_dsl.rb +15 -9
- data/lib/active_admin/router.rb +1 -1
- data/lib/active_admin/scope.rb +2 -3
- data/lib/active_admin/version.rb +1 -1
- data/lib/active_admin/view_helpers/display_helper.rb +31 -0
- data/lib/active_admin/view_helpers/fields_for.rb +3 -2
- data/lib/active_admin/views/components/attributes_table.rb +5 -23
- data/lib/active_admin/views/components/index_list.rb +1 -1
- data/lib/active_admin/views/components/paginated_collection.rb +3 -3
- data/lib/active_admin/views/components/site_title.rb +1 -1
- data/lib/active_admin/views/components/table_for.rb +8 -27
- data/lib/active_admin/views/index_as_grid.rb +2 -2
- data/lib/active_admin/views/index_as_table.rb +24 -2
- data/lib/active_admin/views/pages/base.rb +1 -1
- data/lib/active_admin/views/pages/form.rb +6 -2
- data/lib/active_admin/views/title_bar.rb +1 -1
- data/lib/generators/active_admin/assets/templates/active_admin.scss +1 -1
- data/lib/generators/active_admin/install/install_generator.rb +1 -1
- data/lib/generators/active_admin/install/templates/active_admin.rb.erb +14 -4
- data/lib/generators/active_admin/resource/templates/admin.rb +8 -2
- data/lib/ransack_ext.rb +8 -0
- data/script/local +15 -6
- data/spec/rails_helper.rb +12 -1
- data/spec/requests/javascript_spec.rb +15 -13
- data/spec/requests/stylesheets_spec.rb +1 -1
- data/spec/support/detect_rails_version.rb +1 -1
- data/spec/support/rails_template.rb +117 -104
- data/spec/support/rails_template_with_data.rb +5 -9
- data/spec/support/templates/admin/stores.rb +1 -1
- data/spec/unit/action_builder_spec.rb +58 -56
- data/spec/unit/authorization/authorization_adapter_spec.rb +5 -5
- data/spec/unit/authorization/index_overriding_spec.rb +2 -1
- data/spec/unit/auto_link_spec.rb +1 -1
- data/spec/unit/batch_actions/resource_spec.rb +2 -2
- data/spec/unit/batch_actions/settings_spec.rb +13 -13
- data/spec/unit/comments_spec.rb +5 -5
- data/spec/unit/csv_builder_spec.rb +59 -0
- data/spec/unit/dsl_spec.rb +1 -1
- data/spec/unit/filters/filter_form_builder_spec.rb +5 -4
- data/spec/unit/filters/resource_spec.rb +7 -0
- data/spec/unit/form_builder_spec.rb +4 -1
- data/spec/unit/generators/install_spec.rb +4 -4
- data/spec/unit/helpers/collection_spec.rb +4 -4
- data/spec/unit/menu_collection_spec.rb +3 -3
- data/spec/unit/namespace/register_page_spec.rb +17 -18
- data/spec/unit/namespace/register_resource_spec.rb +20 -21
- data/spec/unit/namespace_spec.rb +4 -4
- data/spec/unit/pundit_adapter_spec.rb +3 -3
- data/spec/unit/resource/action_items_spec.rb +1 -1
- data/spec/unit/resource/naming_spec.rb +1 -1
- data/spec/unit/resource/routes_spec.rb +6 -2
- data/spec/unit/resource/scopes_spec.rb +2 -2
- data/spec/unit/resource_controller/decorators_spec.rb +11 -0
- data/spec/unit/resource_controller/sidebars_spec.rb +17 -24
- data/spec/unit/resource_spec.rb +14 -12
- data/spec/unit/routing_spec.rb +19 -14
- data/spec/unit/scope_spec.rb +28 -33
- data/spec/unit/view_helpers/display_helper_spec.rb +165 -0
- data/spec/unit/view_helpers/download_format_links_helper_spec.rb +9 -9
- data/spec/unit/views/components/attributes_table_spec.rb +1 -1
- data/spec/unit/views/components/blank_slate_spec.rb +3 -3
- data/spec/unit/views/components/index_table_for_spec.rb +82 -1
- data/spec/unit/views/components/paginated_collection_spec.rb +0 -1
- data/spec/unit/views/components/table_for_spec.rb +13 -8
- data/spec/unit/views/components/unsupported_browser_spec.rb +2 -8
- data/spec/unit/views/index_as_blog_spec.rb +76 -0
- data/spec/unit/views/pages/form_spec.rb +9 -0
- data/tasks/test.rake +13 -5
- metadata +27 -10
- data/app/assets/javascripts/active_admin/application.js.coffee +0 -37
- data/spec/support/templates/cucumber.rb +0 -24
- data/spec/support/templates/cucumber_with_reloading.rb +0 -5
- data/spec/unit/view_helpers/display_name_spec.rb +0 -71
@@ -28,7 +28,7 @@ module ActiveAdmin
|
|
28
28
|
|
29
29
|
def decorate?
|
30
30
|
case action_name
|
31
|
-
when 'new', 'edit'
|
31
|
+
when 'new', 'edit', 'create', 'update'
|
32
32
|
form = active_admin_config.get_page_presenter :form
|
33
33
|
form && form.options[:decorate] && decorator_class.present?
|
34
34
|
else
|
@@ -67,7 +67,7 @@ module ActiveAdmin
|
|
67
67
|
def self.wrap!(parent, name)
|
68
68
|
::Class.new parent do
|
69
69
|
delegate :reorder, :page, :current_page, :total_pages, :limit_value,
|
70
|
-
:total_count, :
|
70
|
+
:total_count, :total_pages, :to_key, :group_values, :except,
|
71
71
|
:find_each, :ransack
|
72
72
|
|
73
73
|
define_singleton_method(:name) { name }
|
@@ -20,7 +20,12 @@ module ActiveAdmin
|
|
20
20
|
def stream_resource(&block)
|
21
21
|
headers['X-Accel-Buffering'] = 'no'
|
22
22
|
headers['Cache-Control'] = 'no-cache'
|
23
|
-
|
23
|
+
|
24
|
+
if ActiveAdmin.application.disable_streaming_in.include? Rails.env
|
25
|
+
self.response_body = block['']
|
26
|
+
else
|
27
|
+
self.response_body = Enumerator.new &block
|
28
|
+
end
|
24
29
|
end
|
25
30
|
|
26
31
|
def csv_filename
|
@@ -28,6 +33,7 @@ module ActiveAdmin
|
|
28
33
|
end
|
29
34
|
|
30
35
|
def stream_csv
|
36
|
+
headers['Content-Type'] = 'text/csv; charset=utf-8' # In Rails 5 it's set to HTML??
|
31
37
|
headers['Content-Disposition'] = %{attachment; filename="#{csv_filename}"}
|
32
38
|
stream_resource &active_admin_config.csv_builder.method(:build).to_proc.curry[self]
|
33
39
|
end
|
@@ -116,7 +116,8 @@ module ActiveAdmin
|
|
116
116
|
title = options.delete(:title)
|
117
117
|
|
118
118
|
controller do
|
119
|
-
|
119
|
+
callback = ActiveAdmin::Dependency.rails >= 4 ? :before_action : :before_filter
|
120
|
+
send(callback, only: [name]) { @page_title = title } if title
|
120
121
|
define_method(name, &block || Proc.new{})
|
121
122
|
end
|
122
123
|
end
|
@@ -159,14 +160,19 @@ module ActiveAdmin
|
|
159
160
|
delegate :before_save, :after_save, to: :controller
|
160
161
|
delegate :before_destroy, :after_destroy, to: :controller
|
161
162
|
|
162
|
-
#
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
163
|
+
# This code defines both *_filter and *_action for Rails 3.2 to Rails 5.
|
164
|
+
actions = [
|
165
|
+
:before, :skip_before,
|
166
|
+
:after, :skip_after,
|
167
|
+
:around, :skip
|
168
|
+
]
|
169
|
+
destination = ActiveAdmin::Dependency.rails >= 4 ? :action : :filter
|
170
|
+
[:action, :filter].each do |name|
|
171
|
+
actions.each do |action|
|
172
|
+
define_method "#{action}_#{name}" do |*args, &block|
|
173
|
+
controller.public_send "#{action}_#{destination}", *args, &block
|
174
|
+
end
|
175
|
+
end
|
170
176
|
end
|
171
177
|
|
172
178
|
# Specify which actions to create in the controller
|
data/lib/active_admin/router.rb
CHANGED
@@ -24,7 +24,7 @@ module ActiveAdmin
|
|
24
24
|
root namespace.root_to_options.merge(to: namespace.root_to)
|
25
25
|
else
|
26
26
|
namespace namespace.name do
|
27
|
-
root namespace.root_to_options.merge(to: namespace.root_to)
|
27
|
+
root namespace.root_to_options.merge(to: namespace.root_to, as: :root)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
data/lib/active_admin/scope.rb
CHANGED
@@ -29,10 +29,10 @@ module ActiveAdmin
|
|
29
29
|
|
30
30
|
if name.is_a? Proc
|
31
31
|
raise "A string/symbol is required as the second argument if your label is a proc." unless method
|
32
|
-
@id = method.to_s
|
32
|
+
@id = ActiveAdmin::Dependency.rails.parameterize method.to_s
|
33
33
|
else
|
34
34
|
@scope_method ||= name.to_sym
|
35
|
-
@id = name.to_s
|
35
|
+
@id = ActiveAdmin::Dependency.rails.parameterize name.to_s
|
36
36
|
end
|
37
37
|
|
38
38
|
@scope_method = nil if @scope_method == :all
|
@@ -41,7 +41,6 @@ module ActiveAdmin
|
|
41
41
|
@show_count = options.fetch(:show_count, true)
|
42
42
|
@display_if_block = options[:if] || proc{ true }
|
43
43
|
@default_block = options[:default] || proc{ false }
|
44
|
-
|
45
44
|
end
|
46
45
|
|
47
46
|
def name
|
data/lib/active_admin/version.rb
CHANGED
@@ -40,6 +40,25 @@ module ActiveAdmin
|
|
40
40
|
resource.class.reflect_on_all_associations.map(&:name)
|
41
41
|
end
|
42
42
|
|
43
|
+
def format_attribute(resource, attr)
|
44
|
+
value = find_value resource, attr
|
45
|
+
value = pretty_format value if attr.is_a? Symbol
|
46
|
+
value = Arbre::Context.new{ status_tag value } if boolean_attr? resource, attr
|
47
|
+
value
|
48
|
+
end
|
49
|
+
|
50
|
+
def find_value(resource, attr)
|
51
|
+
if attr.is_a? Proc
|
52
|
+
attr.call resource
|
53
|
+
elsif attr =~ /\A(.+)_id\z/ && reflection_for(resource, $1.to_sym)
|
54
|
+
resource.public_send $1
|
55
|
+
elsif resource.respond_to? attr
|
56
|
+
resource.public_send attr
|
57
|
+
elsif resource.respond_to? :[]
|
58
|
+
resource[attr]
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
43
62
|
# Attempts to create a human-readable string for any object
|
44
63
|
def pretty_format(object)
|
45
64
|
case object
|
@@ -56,6 +75,18 @@ module ActiveAdmin
|
|
56
75
|
end
|
57
76
|
end
|
58
77
|
end
|
78
|
+
|
79
|
+
def reflection_for(resource, method)
|
80
|
+
klass = resource.class
|
81
|
+
klass.reflect_on_association method if klass.respond_to? :reflect_on_association
|
82
|
+
end
|
83
|
+
|
84
|
+
def boolean_attr?(resource, attr)
|
85
|
+
if resource.class.respond_to? :columns_hash
|
86
|
+
column = resource.class.columns_hash[attr.to_s] and column.type == :boolean
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
59
90
|
end
|
60
91
|
end
|
61
92
|
end
|
@@ -15,11 +15,12 @@ module ActiveAdmin
|
|
15
15
|
#
|
16
16
|
def fields_for_params(params, options = {})
|
17
17
|
namespace = options[:namespace]
|
18
|
-
except
|
18
|
+
except = Array.wrap(options[:except]).map &:to_s
|
19
|
+
params = params.respond_to?(:to_unsafe_h) ? params.to_unsafe_h : params
|
19
20
|
|
20
21
|
params.flat_map do |k, v|
|
21
22
|
next if namespace.nil? && %w(controller action commit utf8).include?(k.to_s)
|
22
|
-
next if except.
|
23
|
+
next if except.include?(k.to_s)
|
23
24
|
|
24
25
|
if namespace
|
25
26
|
k = "#{namespace}[#{k}]"
|
@@ -5,7 +5,7 @@ module ActiveAdmin
|
|
5
5
|
builder_method :attributes_table_for
|
6
6
|
|
7
7
|
def build(obj, *attrs)
|
8
|
-
@collection =
|
8
|
+
@collection = Array.wrap(obj)
|
9
9
|
@resource_class = @collection.first.class
|
10
10
|
options = { }
|
11
11
|
options[:for] = @collection.first if single_record?
|
@@ -26,7 +26,7 @@ module ActiveAdmin
|
|
26
26
|
if options[:class]
|
27
27
|
classes << options[:class]
|
28
28
|
elsif title.present?
|
29
|
-
classes << "row-#{
|
29
|
+
classes << "row-#{ActiveAdmin::Dependency.rails.parameterize(title.to_s)}"
|
30
30
|
end
|
31
31
|
options[:class] = classes.join(' ')
|
32
32
|
|
@@ -79,33 +79,15 @@ module ActiveAdmin
|
|
79
79
|
end
|
80
80
|
|
81
81
|
def content_for(record, attr)
|
82
|
-
value =
|
82
|
+
value = format_attribute record, attr
|
83
83
|
value.blank? && current_arbre_element.children.to_s.empty? ? empty_value : value
|
84
|
-
|
85
|
-
|
86
|
-
def find_attr_value(record, attr)
|
87
|
-
if attr.is_a?(Proc)
|
88
|
-
attr.call(record)
|
89
|
-
elsif attr =~ /\A(.+)_id\z/ && reflection_for(record.class, $1.to_sym)
|
90
|
-
record.public_send $1
|
91
|
-
elsif record.respond_to? attr
|
92
|
-
record.public_send attr
|
93
|
-
elsif record.respond_to? :[]
|
94
|
-
record[attr]
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
def reflection_for(klass, method)
|
99
|
-
klass.reflect_on_association method if klass.respond_to? :reflect_on_association
|
84
|
+
# Don't add the same Arbre twice, while still allowing format_attribute to call status_tag
|
85
|
+
current_arbre_element << value unless current_arbre_element.children.include? value
|
100
86
|
end
|
101
87
|
|
102
88
|
def single_record?
|
103
89
|
@single_record ||= @collection.size == 1
|
104
90
|
end
|
105
|
-
|
106
|
-
def is_array?(obj)
|
107
|
-
obj.respond_to?(:each) && obj.respond_to?(:first) && !obj.is_a?(Hash)
|
108
|
-
end
|
109
91
|
end
|
110
92
|
|
111
93
|
end
|
@@ -36,7 +36,7 @@ module ActiveAdmin
|
|
36
36
|
# @param [Class] index_class The class on which to build the link and html classes
|
37
37
|
def build_index_list(index_class)
|
38
38
|
li class: classes_for_index(index_class) do
|
39
|
-
a href: url_for(
|
39
|
+
a href: url_for(as: index_class.index_name.to_sym), class: "table_tools_button" do
|
40
40
|
name = index_class.index_name
|
41
41
|
I18n.t("active_admin.index_list.#{name}", default: name.to_s.titleize)
|
42
42
|
end
|
@@ -44,7 +44,7 @@ module ActiveAdmin
|
|
44
44
|
@display_total = options.delete(:pagination_total) { true }
|
45
45
|
@per_page = options.delete(:per_page)
|
46
46
|
|
47
|
-
unless collection.respond_to?(:
|
47
|
+
unless collection.respond_to?(:total_pages)
|
48
48
|
raise(StandardError, "Collection is not a paginated scope. Set collection.page(params[:page]).per(10) before calling :paginated_collection.")
|
49
49
|
end
|
50
50
|
|
@@ -132,7 +132,7 @@ module ActiveAdmin
|
|
132
132
|
end
|
133
133
|
|
134
134
|
if @display_total
|
135
|
-
if collection.
|
135
|
+
if collection.total_pages < 2
|
136
136
|
case collection_size
|
137
137
|
when 0; I18n.t("active_admin.pagination.empty", model: entries_name)
|
138
138
|
when 1; I18n.t("active_admin.pagination.one", model: entry_name)
|
@@ -149,7 +149,7 @@ module ActiveAdmin
|
|
149
149
|
end
|
150
150
|
else
|
151
151
|
# Do not display total count, in order to prevent a `SELECT count(*)`.
|
152
|
-
# To do so we must not call `collection.
|
152
|
+
# To do so we must not call `collection.total_pages`
|
153
153
|
offset = (collection.current_page - 1) * collection.limit_value
|
154
154
|
I18n.t "active_admin.pagination.multiple_without_total",
|
155
155
|
model: entries_name,
|
@@ -46,7 +46,7 @@ module ActiveAdmin
|
|
46
46
|
|
47
47
|
def title_image
|
48
48
|
path = helpers.render_or_call_method_or_proc_on(self, @namespace.site_title_image)
|
49
|
-
helpers.image_tag(path, id: "site_title_image", alt:
|
49
|
+
helpers.image_tag(path, id: "site_title_image", alt: title_text)
|
50
50
|
end
|
51
51
|
|
52
52
|
end
|
@@ -39,9 +39,9 @@ module ActiveAdmin
|
|
39
39
|
end
|
40
40
|
|
41
41
|
# Add a table cell for each item
|
42
|
-
@collection.each_with_index do |
|
43
|
-
within @tbody.children[
|
44
|
-
build_table_cell col,
|
42
|
+
@collection.each_with_index do |resource, index|
|
43
|
+
within @tbody.children[index] do
|
44
|
+
build_table_cell col, resource
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
@@ -96,30 +96,11 @@ module ActiveAdmin
|
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
99
|
-
def build_table_cell(col,
|
99
|
+
def build_table_cell(col, resource)
|
100
100
|
td class: col.html_class do
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
def render_data(data, item)
|
106
|
-
value = if data.is_a? Proc
|
107
|
-
data.call item
|
108
|
-
elsif item.respond_to? data
|
109
|
-
item.public_send data
|
110
|
-
elsif item.respond_to? :[]
|
111
|
-
item[data]
|
112
|
-
end
|
113
|
-
value = pretty_format(value) if data.is_a?(Symbol)
|
114
|
-
value = status_tag value if is_boolean? data, item
|
115
|
-
value
|
116
|
-
end
|
117
|
-
|
118
|
-
def is_boolean?(data, item)
|
119
|
-
if item.respond_to? :has_attribute?
|
120
|
-
item.has_attribute?(data) &&
|
121
|
-
item.column_for_attribute(data) &&
|
122
|
-
item.column_for_attribute(data).type == :boolean
|
101
|
+
html = format_attribute(resource, col.data)
|
102
|
+
# Don't add the same Arbre twice, while still allowing format_attribute to call status_tag
|
103
|
+
current_arbre_element << html unless current_arbre_element.children.include? html
|
123
104
|
end
|
124
105
|
end
|
125
106
|
|
@@ -166,7 +147,7 @@ module ActiveAdmin
|
|
166
147
|
if @options.has_key?(:class)
|
167
148
|
html_classes << @options.delete(:class)
|
168
149
|
elsif @title.present?
|
169
|
-
html_classes << "col-#{@title.to_s
|
150
|
+
html_classes << "col-#{ActiveAdmin::Dependency.rails.parameterize(@title.to_s)}"
|
170
151
|
end
|
171
152
|
@html_class = html_classes.join(' ')
|
172
153
|
@data = args[1] || args[0]
|
@@ -29,7 +29,7 @@ module ActiveAdmin
|
|
29
29
|
|
30
30
|
def build(page_presenter, collection)
|
31
31
|
@page_presenter = page_presenter
|
32
|
-
@collection = collection
|
32
|
+
@collection = collection.to_a
|
33
33
|
add_class "index"
|
34
34
|
build_table
|
35
35
|
end
|
@@ -47,7 +47,7 @@ module ActiveAdmin
|
|
47
47
|
def build_table
|
48
48
|
resource_selection_toggle_panel if active_admin_config.batch_actions.any?
|
49
49
|
table class: "index_grid" do
|
50
|
-
collection.in_groups_of(number_of_columns).each do |group|
|
50
|
+
@collection.in_groups_of(number_of_columns).each do |group|
|
51
51
|
build_row(group)
|
52
52
|
end
|
53
53
|
end
|
@@ -52,6 +52,8 @@ module ActiveAdmin
|
|
52
52
|
# end
|
53
53
|
# ```
|
54
54
|
#
|
55
|
+
# ## Defining Actions
|
56
|
+
#
|
55
57
|
# To setup links to View, Edit and Delete a resource, use the `actions` method:
|
56
58
|
#
|
57
59
|
# ```ruby
|
@@ -108,6 +110,18 @@ module ActiveAdmin
|
|
108
110
|
# end
|
109
111
|
# ```
|
110
112
|
#
|
113
|
+
# In addition, you can insert the position of the row in the greater collection by using the index_column special command:
|
114
|
+
#
|
115
|
+
# ```ruby
|
116
|
+
# index do
|
117
|
+
# selectable_column
|
118
|
+
# index_column
|
119
|
+
# column :title
|
120
|
+
# end
|
121
|
+
# ```
|
122
|
+
#
|
123
|
+
# index_column take an optional offset parameter to allow a developer to set the starting number for the index (default is 1).
|
124
|
+
#
|
111
125
|
# ## Sorting
|
112
126
|
#
|
113
127
|
# When a column is generated from an Active Record attribute, the table is
|
@@ -218,7 +232,7 @@ module ActiveAdmin
|
|
218
232
|
def default_table
|
219
233
|
proc do
|
220
234
|
selectable_column
|
221
|
-
id_column if resource_class.primary_key
|
235
|
+
id_column if resource_class.primary_key
|
222
236
|
resource_class.content_columns.each do |col|
|
223
237
|
column col.name.to_sym
|
224
238
|
end
|
@@ -244,12 +258,20 @@ module ActiveAdmin
|
|
244
258
|
end
|
245
259
|
end
|
246
260
|
|
261
|
+
def index_column(start_value = 1)
|
262
|
+
column '#', class: 'col-index', sortable: false do |resource|
|
263
|
+
@collection.offset_value + @collection.index(resource) + start_value
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
247
267
|
# Display a column for the id
|
248
268
|
def id_column
|
249
|
-
raise "#{resource_class.name}
|
269
|
+
raise "#{resource_class.name} has no primary_key!" unless resource_class.primary_key
|
250
270
|
column(resource_class.human_attribute_name(resource_class.primary_key), sortable: resource_class.primary_key) do |resource|
|
251
271
|
if controller.action_methods.include?('show')
|
252
272
|
link_to resource.id, resource_path(resource), class: "resource_id_link"
|
273
|
+
elsif controller.action_methods.include?('edit')
|
274
|
+
link_to resource.id, edit_resource_path(resource), class: "resource_id_link"
|
253
275
|
else
|
254
276
|
resource.id
|
255
277
|
end
|
@@ -56,7 +56,7 @@ module ActiveAdmin
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def build_unsupported_browser
|
59
|
-
if active_admin_namespace.unsupported_browser_matcher =~
|
59
|
+
if active_admin_namespace.unsupported_browser_matcher =~ request.user_agent
|
60
60
|
insert_tag view_factory.unsupported_browser
|
61
61
|
end
|
62
62
|
end
|
@@ -5,8 +5,12 @@ module ActiveAdmin
|
|
5
5
|
class Form < Base
|
6
6
|
|
7
7
|
def title
|
8
|
-
|
9
|
-
|
8
|
+
if form_presenter[:title]
|
9
|
+
render_or_call_method_or_proc_on(resource, form_presenter[:title])
|
10
|
+
else
|
11
|
+
assigns[:page_title] || I18n.t("active_admin.#{normalized_action}_model",
|
12
|
+
model: active_admin_config.resource_label)
|
13
|
+
end
|
10
14
|
end
|
11
15
|
|
12
16
|
def form_presenter
|
@@ -1,7 +1,7 @@
|
|
1
1
|
// SASS variable overrides must be declared before loading up Active Admin's styles.
|
2
2
|
//
|
3
3
|
// To view the variables that Active Admin provides, take a look at
|
4
|
-
// `app/assets/stylesheets/active_admin/mixins/_variables.
|
4
|
+
// `app/assets/stylesheets/active_admin/mixins/_variables.scss` in the
|
5
5
|
// Active Admin source.
|
6
6
|
//
|
7
7
|
// For example, to change the sidebar width:
|