activeadmin 1.0.0.pre5 → 1.0.0
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/.rubocop.yml +27 -0
- data/.travis.yml +21 -23
- data/Appraisals +12 -74
- data/CHANGELOG.md +21 -5
- data/CONTRIBUTING.md +2 -2
- data/Gemfile +8 -9
- data/README.md +19 -56
- data/Rakefile +1 -1
- data/activeadmin.gemspec +4 -4
- data/app/assets/stylesheets/active_admin/_forms.scss +10 -0
- data/config/locales/ca.yml +1 -1
- data/config/locales/da.yml +44 -12
- data/config/locales/el.yml +1 -1
- data/config/locales/en.yml +2 -0
- data/config/locales/fr.yml +16 -2
- data/config/locales/ja.yml +1 -0
- data/config/locales/zh-CN.yml +4 -0
- data/docs/12-arbre-components.md +23 -0
- data/docs/14-gotchas.md +1 -1
- data/docs/2-resource-customization.md +2 -5
- data/docs/5-forms.md +19 -0
- data/docs/6-show-pages.md +0 -28
- data/docs/9-batch-actions.md +0 -1
- data/docs/CNAME +1 -1
- data/docs/_includes/head.html +4 -4
- data/docs/_includes/toc.html +2 -1
- data/docs/documentation.md +2 -2
- data/docs/index.html +1 -6
- data/docs/stylesheets/main.css +172 -219
- data/features/belongs_to.feature +5 -5
- data/features/comments/commenting.feature +0 -13
- data/features/create_another.feature +55 -0
- data/features/development_reloading.feature +2 -4
- data/features/edit_page.feature +6 -7
- data/features/favicon.feature +2 -2
- data/features/i18n.feature +1 -0
- data/features/index/filters.feature +18 -0
- data/features/index/format_as_csv.feature +3 -3
- data/features/index/formats.feature +22 -0
- data/features/index/index_as_table.feature +6 -6
- data/features/index/page_title.feature +1 -2
- data/features/menu.feature +20 -1
- data/features/new_page.feature +6 -8
- data/features/registering_assets.feature +4 -4
- data/features/registering_pages.feature +18 -0
- data/features/renamed_resource.feature +2 -4
- data/features/show/page_title.feature +1 -2
- data/features/step_definitions/attribute_steps.rb +1 -1
- data/features/step_definitions/configuration_steps.rb +2 -2
- data/features/step_definitions/format_steps.rb +4 -0
- data/features/step_definitions/index_scope_steps.rb +1 -1
- data/features/step_definitions/menu_steps.rb +2 -2
- data/features/step_definitions/user_steps.rb +1 -1
- data/features/step_definitions/web_steps.rb +6 -5
- data/features/sti_resource.feature +2 -2
- data/features/strong_parameters.feature +0 -4
- data/features/support/env.rb +5 -19
- data/features/support/paths.rb +6 -9
- data/gemfiles/rails_42.gemfile +15 -23
- data/gemfiles/rails_50.gemfile +15 -16
- data/gemfiles/rails_51.gemfile +45 -0
- data/lib/active_admin/application.rb +4 -0
- data/lib/active_admin/base_controller.rb +2 -7
- data/lib/active_admin/base_controller/menu.rb +1 -5
- data/lib/active_admin/csv_builder.rb +2 -2
- data/lib/active_admin/dependency.rb +4 -8
- data/lib/active_admin/devise.rb +1 -1
- data/lib/active_admin/error.rb +1 -1
- data/lib/active_admin/filters/active.rb +2 -10
- data/lib/active_admin/filters/resource_extension.rb +1 -10
- data/lib/active_admin/inputs/filters/date_range_input.rb +1 -1
- data/lib/active_admin/inputs/filters/select_input.rb +1 -2
- data/lib/active_admin/inputs/filters/text_input.rb +2 -2
- data/lib/active_admin/menu.rb +1 -1
- data/lib/active_admin/namespace.rb +14 -7
- data/lib/active_admin/orm/active_record/comments.rb +2 -7
- data/lib/active_admin/orm/active_record/comments/comment.rb +2 -12
- data/lib/active_admin/page.rb +5 -0
- data/lib/active_admin/page_controller.rb +1 -5
- data/lib/active_admin/resource.rb +28 -5
- data/lib/active_admin/resource/attributes.rb +44 -0
- data/lib/active_admin/resource/menu.rb +4 -1
- data/lib/active_admin/resource/routes.rb +2 -3
- data/lib/active_admin/resource_controller.rb +13 -0
- data/lib/active_admin/resource_controller/data_access.rb +18 -9
- data/lib/active_admin/resource_dsl.rb +21 -18
- data/lib/active_admin/version.rb +1 -1
- data/lib/active_admin/view_helpers/breadcrumb_helper.rb +1 -1
- data/lib/active_admin/view_helpers/display_helper.rb +10 -12
- data/lib/active_admin/view_helpers/download_format_links_helper.rb +12 -0
- data/lib/active_admin/view_helpers/fields_for.rb +1 -2
- data/lib/active_admin/view_helpers/form_helper.rb +1 -1
- data/lib/active_admin/views/components/active_admin_form.rb +28 -2
- data/lib/active_admin/views/components/paginated_collection.rb +3 -8
- data/lib/active_admin/views/components/table_for.rb +1 -1
- data/lib/active_admin/views/index_as_table.rb +2 -2
- data/lib/active_admin/views/pages/layout.rb +1 -1
- data/lib/active_admin/views/pages/show.rb +1 -1
- data/lib/bug_report_templates/rails_5_master.rb +1 -3
- data/lib/generators/active_admin/devise/devise_generator.rb +1 -1
- data/lib/generators/active_admin/install/templates/active_admin.rb.erb +7 -0
- data/lib/generators/active_admin/install/templates/admin_user.rb.erb +0 -2
- data/lib/generators/active_admin/install/templates/migrations/create_active_admin_comments.rb.erb +5 -7
- data/lib/generators/active_admin/resource/resource_generator.rb +1 -1
- data/lib/generators/active_admin/resource/templates/{admin.rb → admin.rb.erb} +0 -2
- data/lib/ransack_ext.rb +2 -2
- data/spec/rails_helper.rb +1 -19
- data/spec/requests/default_namespace_spec.rb +40 -8
- data/spec/support/active_admin_integration_spec_helper.rb +9 -2
- data/spec/support/rails_template.rb +17 -20
- data/spec/support/rails_template_with_data.rb +3 -9
- data/spec/support/templates/admin/stores.rb +1 -3
- data/spec/unit/application_spec.rb +19 -8
- data/spec/unit/belongs_to_spec.rb +6 -2
- data/spec/unit/comments_spec.rb +0 -19
- data/spec/unit/controller_filters_spec.rb +5 -5
- data/spec/unit/csv_builder_spec.rb +7 -4
- data/spec/unit/filters/active_spec.rb +1 -8
- data/spec/unit/filters/filter_form_builder_spec.rb +2 -3
- data/spec/unit/filters/resource_spec.rb +3 -4
- data/spec/unit/form_builder_spec.rb +39 -11
- data/spec/unit/namespace/register_page_spec.rb +1 -1
- data/spec/unit/pretty_format_spec.rb +39 -35
- data/spec/unit/resource/attributes_spec.rb +50 -0
- data/spec/unit/resource/includes_spec.rb +1 -1
- data/spec/unit/resource/ordering_spec.rb +1 -1
- data/spec/unit/resource/routes_spec.rb +2 -2
- data/spec/unit/resource_controller/data_access_spec.rb +51 -10
- data/spec/unit/resource_controller/decorators_spec.rb +2 -2
- data/spec/unit/resource_controller/sidebars_spec.rb +3 -3
- data/spec/unit/resource_controller_spec.rb +16 -5
- data/spec/unit/resource_spec.rb +12 -38
- data/spec/unit/routing_spec.rb +2 -2
- data/spec/unit/view_helpers/breadcrumbs_spec.rb +36 -1
- data/spec/unit/view_helpers/display_helper_spec.rb +17 -2
- data/spec/unit/view_helpers/fields_for_spec.rb +1 -1
- data/spec/unit/view_helpers/form_helper_spec.rb +3 -3
- data/spec/unit/view_helpers/method_or_proc_helper_spec.rb +2 -2
- data/spec/unit/views/components/attributes_table_spec.rb +2 -2
- data/spec/unit/views/components/index_list_spec.rb +1 -1
- data/spec/unit/views/components/paginated_collection_spec.rb +4 -4
- data/spec/unit/views/components/table_for_spec.rb +1 -1
- data/spec/unit/views/components/unsupported_browser_spec.rb +1 -1
- data/spec/unit/views/pages/form_spec.rb +4 -1
- data/spec/unit/views/pages/index_spec.rb +1 -1
- data/spec/unit/views/pages/show_spec.rb +2 -3
- data/tasks/lint.rake +8 -0
- metadata +22 -29
- data/features/step_definitions/symbol_leak_steps.rb +0 -3
- data/features/symbol_leak.feature +0 -35
- data/gemfiles/rails_32.gemfile +0 -54
- data/gemfiles/rails_40.gemfile +0 -53
- data/gemfiles/rails_41.gemfile +0 -53
- data/spec/support/deferred_garbage_collection.rb +0 -19
@@ -98,10 +98,6 @@ module ActiveAdmin
|
|
98
98
|
# Does the actual work of finding a resource in the database. This
|
99
99
|
# method uses the finder method as defined in InheritedResources.
|
100
100
|
#
|
101
|
-
# Note that public_send can't be used here because Rails 3.2's
|
102
|
-
# ActiveRecord::Associations::CollectionProxy (belongs_to associations)
|
103
|
-
# mysteriously returns an Enumerator object.
|
104
|
-
#
|
105
101
|
# @return [ActiveRecord::Base] An active record object.
|
106
102
|
def find_resource
|
107
103
|
scoped_collection.send method_for_find, params[:id]
|
@@ -120,7 +116,6 @@ module ActiveAdmin
|
|
120
116
|
get_resource_ivar || begin
|
121
117
|
resource = build_new_resource
|
122
118
|
resource = apply_decorations(resource)
|
123
|
-
resource = assign_attributes(resource, resource_params)
|
124
119
|
run_build_callbacks resource
|
125
120
|
authorize_resource! resource
|
126
121
|
|
@@ -131,12 +126,9 @@ module ActiveAdmin
|
|
131
126
|
# Builds a new resource. This method uses the method_for_build provided
|
132
127
|
# by Inherited Resources.
|
133
128
|
#
|
134
|
-
# Note that public_send can't be used here w/ Rails 3.2 & a belongs_to
|
135
|
-
# config, or you'll get undefined method `build' for []:Array.
|
136
|
-
#
|
137
129
|
# @return [ActiveRecord::Base] An un-saved active record base object
|
138
130
|
def build_new_resource
|
139
|
-
scoped_collection.send method_for_build
|
131
|
+
scoped_collection.send method_for_build, *resource_params
|
140
132
|
end
|
141
133
|
|
142
134
|
# Calls all the appropriate callbacks and then creates the new resource.
|
@@ -305,6 +297,23 @@ module ActiveAdmin
|
|
305
297
|
def apply_decorations(resource)
|
306
298
|
apply_decorator(resource)
|
307
299
|
end
|
300
|
+
|
301
|
+
# @return [String]
|
302
|
+
def smart_resource_url
|
303
|
+
if create_another?
|
304
|
+
new_resource_url(create_another: params[:create_another])
|
305
|
+
else
|
306
|
+
super
|
307
|
+
end
|
308
|
+
end
|
309
|
+
|
310
|
+
private
|
311
|
+
|
312
|
+
# @return [Boolean] true if user requested to create one more
|
313
|
+
# resource after creating this one.
|
314
|
+
def create_another?
|
315
|
+
params[:create_another].present?
|
316
|
+
end
|
308
317
|
end
|
309
318
|
end
|
310
319
|
end
|
@@ -1,10 +1,6 @@
|
|
1
1
|
module ActiveAdmin
|
2
2
|
# This is the class where all the register blocks are evaluated.
|
3
3
|
class ResourceDSL < DSL
|
4
|
-
def initialize(config, resource_class)
|
5
|
-
@resource = resource_class
|
6
|
-
super(config)
|
7
|
-
end
|
8
4
|
|
9
5
|
private
|
10
6
|
|
@@ -47,7 +43,7 @@ module ActiveAdmin
|
|
47
43
|
end
|
48
44
|
|
49
45
|
#
|
50
|
-
#
|
46
|
+
# Keys included in the `permitted_params` setting are automatically whitelisted.
|
51
47
|
#
|
52
48
|
# Either
|
53
49
|
#
|
@@ -64,16 +60,19 @@ module ActiveAdmin
|
|
64
60
|
# end
|
65
61
|
# end
|
66
62
|
#
|
67
|
-
# Keys included in the `permitted_params` setting are automatically whitelisted.
|
68
|
-
#
|
69
63
|
def permit_params(*args, &block)
|
70
64
|
param_key = config.param_key.to_sym
|
71
65
|
belongs_to_param = config.belongs_to_param
|
66
|
+
create_another_param = :create_another if config.create_another
|
72
67
|
|
73
68
|
controller do
|
74
69
|
define_method :permitted_params do
|
75
|
-
|
76
|
-
|
70
|
+
permitted_params =
|
71
|
+
active_admin_namespace.permitted_params +
|
72
|
+
Array.wrap(belongs_to_param) +
|
73
|
+
Array.wrap(create_another_param)
|
74
|
+
|
75
|
+
params.permit(*permitted_params, param_key => block ? instance_exec(&block) : args)
|
77
76
|
end
|
78
77
|
end
|
79
78
|
end
|
@@ -107,7 +106,7 @@ module ActiveAdmin
|
|
107
106
|
# end
|
108
107
|
#
|
109
108
|
def csv(options={}, &block)
|
110
|
-
options[:resource] =
|
109
|
+
options[:resource] = config
|
111
110
|
|
112
111
|
config.csv_builder = CSVBuilder.new(options, &block)
|
113
112
|
end
|
@@ -136,8 +135,7 @@ module ActiveAdmin
|
|
136
135
|
title = options.delete(:title)
|
137
136
|
|
138
137
|
controller do
|
139
|
-
|
140
|
-
send(callback, only: [name]) { @page_title = title } if title
|
138
|
+
before_action(only: [name]) { @page_title = title } if title
|
141
139
|
define_method(name, &block || Proc.new{})
|
142
140
|
end
|
143
141
|
end
|
@@ -187,17 +185,22 @@ module ActiveAdmin
|
|
187
185
|
delegate :before_save, :after_save, to: :controller
|
188
186
|
delegate :before_destroy, :after_destroy, to: :controller
|
189
187
|
|
190
|
-
# This code defines both *_filter and *_action for Rails
|
191
|
-
|
188
|
+
# This code defines both *_filter and *_action for Rails 4.0 to Rails 5 and *_action for Rails >= 5.1
|
189
|
+
phases = [
|
192
190
|
:before, :skip_before,
|
193
191
|
:after, :skip_after,
|
194
192
|
:around, :skip
|
195
193
|
]
|
196
|
-
|
197
|
-
|
198
|
-
|
194
|
+
keywords = if Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR >= 1
|
195
|
+
[:action]
|
196
|
+
else
|
197
|
+
[:action, :filter]
|
198
|
+
end
|
199
|
+
|
200
|
+
keywords.each do |name|
|
201
|
+
phases.each do |action|
|
199
202
|
define_method "#{action}_#{name}" do |*args, &block|
|
200
|
-
controller.public_send "#{action}
|
203
|
+
controller.public_send "#{action}_action", *args, &block
|
201
204
|
end
|
202
205
|
end
|
203
206
|
end
|
data/lib/active_admin/version.rb
CHANGED
@@ -12,7 +12,7 @@ module ActiveAdmin
|
|
12
12
|
# 1. try using `display_name` if we can locate a DB object
|
13
13
|
# 2. try using the model name translation
|
14
14
|
# 3. default to calling `titlecase` on the URL fragment
|
15
|
-
if part =~ /\A(\d+|[a-f0-9]{24})\z/ && parts[index-1]
|
15
|
+
if part =~ /\A(\d+|[a-f0-9]{24}|(?:[a-f0-9]{8}-(?:[a-f0-9]{4}-){3}[a-f0-9]{12}))\z/ && parts[index-1]
|
16
16
|
parent = active_admin_config.belongs_to_config.try :target
|
17
17
|
config = parent && parent.resource_name.route_key == parts[index-1] ? parent : active_admin_config
|
18
18
|
name = display_name config.find_resource part
|
@@ -45,7 +45,7 @@ module ActiveAdmin
|
|
45
45
|
|
46
46
|
if value.is_a?(Arbre::Element)
|
47
47
|
value
|
48
|
-
elsif boolean_attr?(resource, attr)
|
48
|
+
elsif boolean_attr?(resource, attr, value)
|
49
49
|
Arbre::Context.new { status_tag value }
|
50
50
|
else
|
51
51
|
pretty_format value
|
@@ -55,8 +55,6 @@ module ActiveAdmin
|
|
55
55
|
def find_value(resource, attr)
|
56
56
|
if attr.is_a? Proc
|
57
57
|
attr.call resource
|
58
|
-
elsif attr =~ /\A(.+)_id\z/ && reflection_for(resource, $1.to_sym)
|
59
|
-
resource.public_send $1
|
60
58
|
elsif resource.respond_to? attr
|
61
59
|
resource.public_send attr
|
62
60
|
elsif resource.respond_to? :[]
|
@@ -70,7 +68,7 @@ module ActiveAdmin
|
|
70
68
|
when String, Numeric, Symbol, Arbre::Element
|
71
69
|
object.to_s
|
72
70
|
when Date, Time
|
73
|
-
localize object, format: active_admin_application.localize_format
|
71
|
+
I18n.localize object, format: active_admin_application.localize_format
|
74
72
|
else
|
75
73
|
if defined?(::ActiveRecord) && object.is_a?(ActiveRecord::Base) ||
|
76
74
|
defined?(::Mongoid) && object.class.include?(Mongoid::Document)
|
@@ -81,14 +79,14 @@ module ActiveAdmin
|
|
81
79
|
end
|
82
80
|
end
|
83
81
|
|
84
|
-
def
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
82
|
+
def boolean_attr?(resource, attr, value)
|
83
|
+
case value
|
84
|
+
when TrueClass, FalseClass
|
85
|
+
true
|
86
|
+
else
|
87
|
+
if resource.class.respond_to? :columns_hash
|
88
|
+
column = resource.class.columns_hash[attr.to_s] and column.type == :boolean
|
89
|
+
end
|
92
90
|
end
|
93
91
|
end
|
94
92
|
|
@@ -2,6 +2,18 @@ module ActiveAdmin
|
|
2
2
|
module ViewHelpers
|
3
3
|
module DownloadFormatLinksHelper
|
4
4
|
|
5
|
+
def build_download_formats(download_links)
|
6
|
+
download_links = instance_exec(&download_links) if download_links.is_a?(Proc)
|
7
|
+
|
8
|
+
if download_links.is_a?(Array) && !download_links.empty?
|
9
|
+
download_links
|
10
|
+
elsif download_links == false
|
11
|
+
[]
|
12
|
+
else
|
13
|
+
self.class.formats
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
5
17
|
def build_download_format_links(formats = self.class.formats)
|
6
18
|
params = request.query_parameters.except :format, :commit
|
7
19
|
div class: "download_links" do
|
@@ -16,7 +16,6 @@ module ActiveAdmin
|
|
16
16
|
def fields_for_params(params, options = {})
|
17
17
|
namespace = options[:namespace]
|
18
18
|
except = Array.wrap(options[:except]).map &:to_s
|
19
|
-
params = params.respond_to?(:to_unsafe_h) ? params.to_unsafe_h : params
|
20
19
|
|
21
20
|
params.flat_map do |k, v|
|
22
21
|
next if namespace.nil? && %w(controller action commit utf8).include?(k.to_s)
|
@@ -39,7 +38,7 @@ module ActiveAdmin
|
|
39
38
|
end
|
40
39
|
when nil
|
41
40
|
{ k => '' }
|
42
|
-
when TrueClass,FalseClass
|
41
|
+
when TrueClass, FalseClass
|
43
42
|
{ k => v }
|
44
43
|
else
|
45
44
|
raise "I don't know what to do with #{v.class} params: #{v.inspect}"
|
@@ -9,7 +9,7 @@ module ActiveAdmin
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def hidden_field_tags_for(params, options={})
|
12
|
-
fields_for_params(params, options).map do |kv|
|
12
|
+
fields_for_params(params.to_unsafe_hash, options).map do |kv|
|
13
13
|
k, v = kv.first
|
14
14
|
hidden_field_tag k, v, id: sanitize_to_id("hidden_active_admin_#{k}")
|
15
15
|
end.join("\n").html_safe
|
@@ -34,7 +34,7 @@ module ActiveAdmin
|
|
34
34
|
@opening_tag, @closing_tag = split_string_on(form_string, "</form>")
|
35
35
|
instance_eval(&block) if block_given?
|
36
36
|
|
37
|
-
# Rails
|
37
|
+
# Rails sets multipart automatically if a file field is present,
|
38
38
|
# but the form tag has already been rendered before the block eval.
|
39
39
|
if multipart? && @opening_tag !~ /multipart/
|
40
40
|
@opening_tag.sub!(/<form/, '<form enctype="multipart/form-data"')
|
@@ -72,10 +72,17 @@ module ActiveAdmin
|
|
72
72
|
end
|
73
73
|
|
74
74
|
def commit_action_with_cancel_link
|
75
|
+
add_create_another_checkbox
|
75
76
|
action(:submit)
|
76
77
|
cancel_link
|
77
78
|
end
|
78
79
|
|
80
|
+
def add_create_another_checkbox
|
81
|
+
if %w(new create).include?(helpers.action_name) && active_admin_config && active_admin_config.create_another
|
82
|
+
current_arbre_element.add_child(create_another_checkbox)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
79
86
|
def has_many(*args, &block)
|
80
87
|
insert_tag(HasManyProxy, form_builder, *args, &block)
|
81
88
|
end
|
@@ -91,6 +98,25 @@ module ActiveAdmin
|
|
91
98
|
def form_buffers
|
92
99
|
raise "'form_buffers' has been removed from ActiveAdmin::FormBuilder, please read https://github.com/activeadmin/activeadmin/blob/master/docs/5-forms.md for details."
|
93
100
|
end
|
101
|
+
|
102
|
+
private
|
103
|
+
|
104
|
+
def create_another_checkbox
|
105
|
+
create_another = params[:create_another]
|
106
|
+
label = @resource.class.model_name.human
|
107
|
+
Arbre::Context.new do
|
108
|
+
li do
|
109
|
+
input(
|
110
|
+
checked: create_another,
|
111
|
+
id: 'create_another',
|
112
|
+
class: 'create_another',
|
113
|
+
name: 'create_another',
|
114
|
+
type: 'checkbox',
|
115
|
+
)
|
116
|
+
label(I18n.t('active_admin.create_another', model: label), for: 'create_another')
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
94
120
|
end
|
95
121
|
|
96
122
|
class SemanticInputsProxy < FormtasticProxy
|
@@ -100,7 +126,7 @@ module ActiveAdmin
|
|
100
126
|
legend = args.shift if args.first.is_a?(::String)
|
101
127
|
legend = html_options.delete(:name) if html_options.key?(:name)
|
102
128
|
legend_tag = legend ? "<legend><span>#{legend}</span></legend>" : ""
|
103
|
-
fieldset_attrs = html_options.map {|k,v| %Q{#{k}="#{v}"} }.join(" ")
|
129
|
+
fieldset_attrs = html_options.map {|k, v| %Q{#{k}="#{v}"} }.join(" ")
|
104
130
|
@opening_tag = "<fieldset #{fieldset_attrs}>#{legend_tag}<ol>"
|
105
131
|
@closing_tag = "</ol></fieldset>"
|
106
132
|
super(*(args << html_options), &block)
|
@@ -71,19 +71,14 @@ module ActiveAdmin
|
|
71
71
|
build_pagination
|
72
72
|
div(page_entries_info(options).html_safe, class: "pagination_information")
|
73
73
|
|
74
|
-
|
75
|
-
|
76
|
-
if download_links.is_a?(Array) && !download_links.empty?
|
77
|
-
build_download_format_links download_links
|
78
|
-
else
|
79
|
-
build_download_format_links unless download_links == false
|
80
|
-
end
|
74
|
+
formats = build_download_formats @download_links
|
75
|
+
build_download_format_links formats if formats.any?
|
81
76
|
end
|
82
77
|
end
|
83
78
|
|
84
79
|
def build_per_page_select
|
85
80
|
div class: "pagination_per_page" do
|
86
|
-
text_node "
|
81
|
+
text_node I18n.t("active_admin.pagination.per_page")
|
87
82
|
select do
|
88
83
|
@per_page.each do |per_page|
|
89
84
|
option(
|
@@ -233,8 +233,8 @@ module ActiveAdmin
|
|
233
233
|
proc do
|
234
234
|
selectable_column
|
235
235
|
id_column if resource_class.primary_key
|
236
|
-
|
237
|
-
column
|
236
|
+
active_admin_config.resource_columns.each do |attribute|
|
237
|
+
column attribute
|
238
238
|
end
|
239
239
|
actions
|
240
240
|
end
|
@@ -21,8 +21,6 @@ gemfile(true) do
|
|
21
21
|
else
|
22
22
|
gem 'activeadmin', git: 'https://github.com/activeadmin/activeadmin', require: false
|
23
23
|
end
|
24
|
-
|
25
|
-
gem 'inherited_resources', '~> 1.7', require: false
|
26
24
|
end
|
27
25
|
|
28
26
|
# prepare active_record database
|
@@ -41,7 +39,7 @@ ActiveRecord::Schema.define do
|
|
41
39
|
end
|
42
40
|
end
|
43
41
|
|
44
|
-
# prepare
|
42
|
+
# prepare Rails app
|
45
43
|
require 'action_controller/railtie'
|
46
44
|
require 'action_view/railtie'
|
47
45
|
require 'active_admin'
|
@@ -55,7 +55,7 @@ module ActiveAdmin
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def add_default_user_to_seed
|
58
|
-
seeds_paths = Rails.application.paths["db/seeds.rb"]
|
58
|
+
seeds_paths = Rails.application.paths["db/seeds.rb"]
|
59
59
|
seeds_file = seeds_paths.existent.first
|
60
60
|
return if seeds_file.nil? || !options[:default_user]
|
61
61
|
|
@@ -179,6 +179,13 @@ ActiveAdmin.setup do |config|
|
|
179
179
|
#
|
180
180
|
# config.breadcrumb = false
|
181
181
|
|
182
|
+
# == Create Another Checkbox
|
183
|
+
#
|
184
|
+
# Create another checkbox is disabled by default. You can customize it for individual
|
185
|
+
# resources or you can enable them globally from here.
|
186
|
+
#
|
187
|
+
# config.create_another = true
|
188
|
+
|
182
189
|
# == Register Stylesheets & Javascripts
|
183
190
|
#
|
184
191
|
# We recommend using the built in Active Admin layout and loading
|
data/lib/generators/active_admin/install/templates/migrations/create_active_admin_comments.rb.erb
CHANGED
@@ -1,15 +1,13 @@
|
|
1
1
|
<%
|
2
|
-
parent_class = ActiveRecord::Migration
|
3
|
-
parent_class = parent_class[
|
4
|
-
|
5
|
-
|
2
|
+
parent_class = ActiveRecord::Migration
|
3
|
+
parent_class = parent_class[parent_class.current_version] if Rails::VERSION::MAJOR >= 5
|
4
|
+
-%>
|
6
5
|
class CreateActiveAdminComments < <%= parent_class.to_s %>
|
7
6
|
def self.up
|
8
7
|
create_table :active_admin_comments do |t|
|
9
8
|
t.string :namespace
|
10
9
|
t.text :body
|
11
|
-
t.
|
12
|
-
t.string :resource_type, null: false
|
10
|
+
t.references :resource, polymorphic: true
|
13
11
|
t.references :author, polymorphic: true
|
14
12
|
<%- if Rails::VERSION::MAJOR >= 5 -%>
|
15
13
|
t.timestamps
|
@@ -21,9 +19,9 @@ class CreateActiveAdminComments < <%= parent_class.to_s %>
|
|
21
19
|
<%- unless Rails::VERSION::MAJOR >= 5 -%>
|
22
20
|
|
23
21
|
add_index :active_admin_comments, [:author_type, :author_id]
|
22
|
+
add_index :active_admin_comments, [:resource_type, :resource_id]
|
24
23
|
<%- end -%>
|
25
24
|
|
26
|
-
add_index :active_admin_comments, [:resource_type, :resource_id]
|
27
25
|
end
|
28
26
|
|
29
27
|
def self.down
|