activeadmin 1.0.0.pre1 → 1.0.0.pre2
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/.travis.yml +18 -16
- data/CHANGELOG.md +18 -1013
- data/Gemfile +18 -11
- data/LICENSE +0 -5
- data/README.md +0 -2
- data/activeadmin.gemspec +3 -1
- data/app/assets/javascripts/active_admin/application.js.coffee +8 -3
- data/app/assets/javascripts/active_admin/base.js.coffee +1 -6
- data/app/assets/javascripts/active_admin/jquery_ui.js.erb +11 -0
- data/app/assets/javascripts/active_admin/lib/flash.js.coffee +1 -1
- data/app/assets/javascripts/active_admin/lib/modal_dialog.js.coffee +11 -3
- data/app/assets/javascripts/active_admin/lib/per_page.js.coffee +5 -1
- data/app/assets/stylesheets/active_admin/_base.scss +1 -4
- data/app/assets/stylesheets/active_admin/_forms.scss +13 -8
- data/app/assets/stylesheets/active_admin/components/_buttons.scss +0 -5
- data/app/assets/stylesheets/active_admin/mixins/_all.scss +0 -1
- data/app/assets/stylesheets/active_admin/mixins/_sections.scss +0 -1
- data/app/assets/stylesheets/active_admin/mixins/_typography.scss +1 -1
- data/app/assets/stylesheets/active_admin/mixins/_variables.scss +1 -1
- data/app/assets/stylesheets/active_admin/structure/_title_bar.scss +0 -5
- data/app/views/layouts/active_admin_logged_out.html.erb +4 -0
- data/config/locales/ar.yml +14 -2
- data/config/locales/de-CH.yml +2 -0
- data/config/locales/de.yml +15 -0
- data/config/locales/en.yml +10 -2
- data/config/locales/es.yml +26 -4
- data/config/locales/fr.yml +5 -0
- data/config/locales/id.yml +135 -0
- data/config/locales/ja.yml +21 -3
- data/config/locales/ko.yml +66 -36
- data/config/locales/nl.yml +14 -1
- data/config/locales/pt-BR.yml +11 -0
- data/config/locales/ru.yml +15 -1
- data/config/locales/sv-SE.yml +45 -5
- data/config/locales/uk.yml +16 -4
- data/config/locales/zh-CN.yml +5 -0
- data/config/locales/zh-TW.yml +32 -1
- data/docs/0-installation.md +7 -1
- data/docs/1-general-configuration.md +9 -0
- data/docs/10-custom-pages.md +10 -0
- data/docs/12-arbre-components.md +1 -1
- data/docs/14-gotchas.md +2 -2
- data/docs/2-resource-customization.md +5 -3
- data/docs/3-index-pages.md +7 -0
- data/docs/3-index-pages/index-as-table.md +4 -0
- data/docs/6-show-pages.md +1 -1
- data/docs/7-sidebars.md +8 -0
- data/features/index/batch_actions.feature +21 -2
- data/features/index/pagination.feature +16 -12
- data/features/meta_tags.feature +21 -0
- data/features/registering_assets.feature +1 -2
- data/features/show/columns.feature +40 -0
- data/features/show/default_content.feature +2 -1
- data/features/step_definitions/asset_steps.rb +3 -3
- data/features/step_definitions/batch_action_steps.rb +11 -2
- data/features/step_definitions/column_steps.rb +8 -0
- data/features/step_definitions/configuration_steps.rb +2 -2
- data/features/step_definitions/factory_steps.rb +3 -2
- data/features/step_definitions/meta_tag_steps.rb +3 -0
- data/features/step_definitions/pagination_steps.rb +8 -0
- data/features/step_definitions/table_steps.rb +2 -1
- data/lib/active_admin.rb +3 -3
- data/lib/active_admin/application.rb +66 -16
- data/lib/active_admin/batch_actions.rb +0 -1
- data/lib/active_admin/batch_actions/controller.rb +2 -2
- data/lib/active_admin/batch_actions/resource_extension.rb +3 -1
- data/lib/active_admin/callbacks.rb +1 -1
- data/lib/active_admin/csv_builder.rb +2 -2
- data/lib/active_admin/dependency.rb +18 -16
- data/lib/active_admin/devise.rb +1 -1
- data/lib/active_admin/dsl.rb +1 -1
- data/lib/active_admin/event.rb +8 -17
- data/lib/active_admin/filters/active.rb +29 -0
- data/lib/active_admin/filters/forms.rb +6 -1
- data/lib/active_admin/filters/humanized.rb +68 -0
- data/lib/active_admin/filters/resource_extension.rb +48 -1
- data/lib/active_admin/form_builder.rb +4 -4
- data/lib/active_admin/generators/boilerplate.rb +37 -0
- data/lib/active_admin/helpers/routes/url_helpers.rb +1 -1
- data/lib/active_admin/inputs.rb +1 -0
- data/lib/active_admin/inputs/filters/date_picker_input.rb +13 -0
- data/lib/active_admin/inputs/filters/date_range_input.rb +1 -1
- data/lib/active_admin/menu.rb +1 -0
- data/lib/active_admin/menu_item.rb +1 -1
- data/lib/active_admin/namespace.rb +5 -5
- data/lib/active_admin/orm/active_record/comments.rb +10 -1
- data/lib/active_admin/orm/active_record/comments/comment.rb +1 -1
- data/lib/active_admin/orm/active_record/comments/views/active_admin_comments.rb +11 -0
- data/lib/active_admin/resource.rb +9 -3
- data/lib/active_admin/resource/action_items.rb +13 -3
- data/lib/active_admin/resource/belongs_to.rb +6 -2
- data/lib/active_admin/resource/pagination.rb +4 -0
- data/lib/active_admin/resource_collection.rb +3 -1
- data/lib/active_admin/resource_controller/data_access.rb +6 -11
- data/lib/active_admin/resource_controller/decorators.rb +1 -1
- data/lib/active_admin/resource_dsl.rb +8 -2
- data/lib/active_admin/sidebar_section.rb +4 -12
- data/lib/active_admin/version.rb +1 -1
- data/lib/active_admin/view_factory.rb +1 -2
- data/lib/active_admin/view_helpers.rb +0 -1
- data/lib/active_admin/view_helpers/display_helper.rb +3 -4
- data/lib/active_admin/view_helpers/method_or_proc_helper.rb +3 -3
- data/lib/active_admin/views/components/active_admin_form.rb +3 -3
- data/lib/active_admin/views/components/columns.rb +9 -4
- data/lib/active_admin/views/components/dropdown_menu.rb +0 -2
- data/lib/active_admin/views/components/paginated_collection.rb +35 -13
- data/lib/active_admin/views/components/panel.rb +1 -3
- data/lib/active_admin/views/components/sidebar_section.rb +6 -1
- data/lib/active_admin/views/components/status_tag.rb +3 -2
- data/lib/active_admin/views/components/table_for.rb +2 -1
- data/lib/active_admin/views/index_as_table.rb +2 -2
- data/lib/active_admin/views/pages/base.rb +4 -0
- data/lib/active_admin/views/pages/show.rb +1 -1
- data/lib/generators/active_admin/assets/assets_generator.rb +1 -1
- data/lib/generators/active_admin/assets/templates/{active_admin.css.scss → active_admin.scss} +0 -0
- data/lib/generators/active_admin/devise/devise_generator.rb +7 -19
- data/lib/generators/active_admin/install/templates/active_admin.rb.erb +29 -0
- data/lib/generators/active_admin/page/templates/page.rb +1 -1
- data/lib/generators/active_admin/resource/resource_generator.rb +6 -0
- data/lib/generators/active_admin/resource/templates/admin.rb +34 -13
- data/spec/rails_helper.rb +6 -2
- data/spec/requests/memory_spec.rb +1 -3
- data/spec/support/active_admin_request_helpers.rb +27 -0
- data/spec/support/detect_rails_version.rb +1 -1
- data/spec/support/rails_template.rb +7 -0
- data/spec/unit/application_spec.rb +29 -4
- data/spec/unit/batch_actions/resource_spec.rb +5 -0
- data/spec/unit/belongs_to_spec.rb +14 -0
- data/spec/unit/comments_spec.rb +24 -2
- data/spec/unit/controller_filters_spec.rb +25 -28
- data/spec/unit/dsl_spec.rb +1 -1
- data/spec/unit/filters/humanized_spec.rb +56 -0
- data/spec/unit/filters/resource_spec.rb +1 -1
- data/spec/unit/form_builder_spec.rb +71 -11
- data/spec/unit/generators/install_spec.rb +3 -2
- data/spec/unit/pretty_format_spec.rb +15 -1
- data/spec/unit/resource_collection_spec.rb +17 -0
- data/spec/unit/resource_controller_spec.rb +2 -2
- data/spec/unit/resource_registration_spec.rb +3 -3
- data/spec/unit/resource_spec.rb +53 -2
- data/spec/unit/view_factory_spec.rb +0 -2
- data/spec/unit/view_helpers/display_name_spec.rb +6 -4
- data/spec/unit/views/components/{batch_action_popover_spec.rb → batch_action_selector_spec.rb} +9 -13
- data/spec/unit/views/components/columns_spec.rb +17 -0
- data/spec/unit/views/components/paginated_collection_spec.rb +16 -2
- data/spec/unit/views/components/panel_spec.rb +1 -5
- data/spec/unit/views/components/sidebar_section_spec.rb +21 -0
- data/spec/unit/views/components/status_tag_spec.rb +15 -1
- data/spec/unit/views/components/table_for_spec.rb +45 -0
- data/tasks/parallel_tests.rake +1 -1
- data/tasks/test.rake +4 -4
- metadata +29 -30
- data/app/assets/javascripts/active_admin/lib/popover.js.coffee +0 -68
- data/app/assets/stylesheets/active_admin/components/_popovers.scss +0 -122
- data/app/assets/stylesheets/active_admin/mixins/_icons.scss +0 -20
- data/lib/active_admin/batch_actions/views/batch_action_popover.rb +0 -28
- data/lib/active_admin/iconic.rb +0 -53
- data/lib/active_admin/iconic/icons.rb +0 -142
- data/lib/active_admin/view_helpers/icon_helper.rb +0 -12
- data/lib/active_admin/views/components/action_list_popover.rb +0 -29
- data/lib/active_admin/views/components/popover.rb +0 -27
- data/spec/javascripts/coffeescripts/jquery.aa.popover-spec.js.coffee +0 -82
- data/spec/support/integration_example_group.rb +0 -31
- data/spec/unit/event_spec.rb +0 -47
- data/spec/unit/views/components/action_list_popover_spec.rb +0 -40
- data/spec/unit/views/components/popover_spec.rb +0 -33
@@ -42,11 +42,13 @@ module ActiveAdmin
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def inputs(*args, &block)
|
45
|
+
if block_given?
|
46
|
+
form_builder.template.assign(has_many_block: true)
|
47
|
+
end
|
45
48
|
if block_given? && block.arity == 0
|
46
49
|
wrapped_block = proc do
|
47
50
|
wrap_it = form_builder.already_in_an_inputs_block ? true : false
|
48
51
|
form_builder.already_in_an_inputs_block = true
|
49
|
-
form_builder.template.assign('has_many_block'=> true)
|
50
52
|
content = form_builder.template.capture do
|
51
53
|
block.call
|
52
54
|
end
|
@@ -114,8 +116,6 @@ module ActiveAdmin
|
|
114
116
|
|
115
117
|
class HasManyProxy < FormtasticProxy
|
116
118
|
def build(form_builder, *args, &block)
|
117
|
-
assoc = args[0]
|
118
|
-
builder_options = args[1] || {}
|
119
119
|
text_node form_builder.has_many(*args, &block)
|
120
120
|
end
|
121
121
|
end
|
@@ -41,7 +41,7 @@ module ActiveAdmin
|
|
41
41
|
# the first being 2 time bigger than the second.
|
42
42
|
#
|
43
43
|
#
|
44
|
-
# == Max and
|
44
|
+
# == Max and Min Column Sizes
|
45
45
|
#
|
46
46
|
# Active Admin is a fluid width layout, which means that columns are all defined
|
47
47
|
# using percentages. Sometimes this can cause issues if you don't want a column
|
@@ -93,19 +93,24 @@ module ActiveAdmin
|
|
93
93
|
all_margins_width = margin_size * (span_count - 1)
|
94
94
|
column_width = (100.00 - all_margins_width) / span_count
|
95
95
|
|
96
|
-
|
96
|
+
columns.each_with_index do |column, i|
|
97
97
|
is_last_column = i == (columns_count - 1)
|
98
|
-
|
98
|
+
column.set_column_styles(column_width, margin_size, is_last_column)
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
102
102
|
def columns_span_count
|
103
103
|
count = 0
|
104
|
-
|
104
|
+
columns.each do |column|
|
105
|
+
count += column.span_size
|
106
|
+
end
|
105
107
|
|
106
108
|
count
|
107
109
|
end
|
108
110
|
|
111
|
+
def columns
|
112
|
+
children.select { |child| child.is_a?(Column) }
|
113
|
+
end
|
109
114
|
end
|
110
115
|
|
111
116
|
class Column < ActiveAdmin::Component
|
@@ -32,11 +32,13 @@ module ActiveAdmin
|
|
32
32
|
# collection => A paginated collection from kaminari
|
33
33
|
# options => These options will be passed to `page_entries_info`
|
34
34
|
# entry_name => The name to display for this resource collection
|
35
|
+
# params => Extra parameters for pagination (e.g. { anchor: 'details' })
|
35
36
|
# param_name => Parameter name for page number in the links (:page by default)
|
36
37
|
# download_links => Download links override (false or [:csv, :pdf])
|
37
38
|
#
|
38
39
|
def build(collection, options = {})
|
39
40
|
@collection = collection
|
41
|
+
@params = options.delete(:params)
|
40
42
|
@param_name = options.delete(:param_name)
|
41
43
|
@download_links = options.delete(:download_links)
|
42
44
|
@display_total = options.delete(:pagination_total) { true }
|
@@ -95,8 +97,20 @@ module ActiveAdmin
|
|
95
97
|
|
96
98
|
def build_pagination
|
97
99
|
options = {}
|
100
|
+
options[:params] = @params if @params
|
98
101
|
options[:param_name] = @param_name if @param_name
|
99
102
|
|
103
|
+
if !@display_total && collection.respond_to?(:offset)
|
104
|
+
# The #paginate method in kaminari will query the resource with a
|
105
|
+
# count(*) to determine how many pages there should be unless
|
106
|
+
# you pass in the :total_pages option. We issue a query to determine
|
107
|
+
# if there is another page or not, but the limit/offset make this
|
108
|
+
# query fast.
|
109
|
+
offset = collection.offset(collection.current_page * @per_page.to_i).limit(1).count
|
110
|
+
options[:total_pages] = collection.current_page + offset
|
111
|
+
options[:right] = 0
|
112
|
+
end
|
113
|
+
|
100
114
|
text_node paginate collection, options
|
101
115
|
end
|
102
116
|
|
@@ -117,22 +131,30 @@ module ActiveAdmin
|
|
117
131
|
entries_name = I18n.translate key, count: collection.size, default: entry_name.pluralize
|
118
132
|
end
|
119
133
|
|
120
|
-
if
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
134
|
+
if @display_total
|
135
|
+
if collection.num_pages < 2
|
136
|
+
case collection_size
|
137
|
+
when 0; I18n.t("active_admin.pagination.empty", model: entries_name)
|
138
|
+
when 1; I18n.t("active_admin.pagination.one", model: entry_name)
|
139
|
+
else; I18n.t("active_admin.pagination.one_page", model: entries_name, n: collection.total_count)
|
140
|
+
end
|
141
|
+
else
|
142
|
+
offset = (collection.current_page - 1) * collection.limit_value
|
143
|
+
total = collection.total_count
|
144
|
+
I18n.t "active_admin.pagination.multiple",
|
145
|
+
model: entries_name,
|
146
|
+
total: total,
|
147
|
+
from: offset + 1,
|
148
|
+
to: offset + collection_size
|
125
149
|
end
|
126
150
|
else
|
151
|
+
# Do not display total count, in order to prevent a `SELECT count(*)`.
|
152
|
+
# To do so we must not call `collection.num_pages`
|
127
153
|
offset = (collection.current_page - 1) * collection.limit_value
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
else
|
133
|
-
I18n.t 'active_admin.pagination.multiple_without_total', model: entries_name,
|
134
|
-
from: offset + 1, to: offset + collection_size
|
135
|
-
end
|
154
|
+
I18n.t "active_admin.pagination.multiple_without_total",
|
155
|
+
model: entries_name,
|
156
|
+
from: offset + 1,
|
157
|
+
to: offset + collection_size
|
136
158
|
end
|
137
159
|
end
|
138
160
|
|
@@ -5,11 +5,9 @@ module ActiveAdmin
|
|
5
5
|
builder_method :panel
|
6
6
|
|
7
7
|
def build(title, attributes = {})
|
8
|
-
icon_name = attributes.delete(:icon)
|
9
|
-
icn = icon_name ? icon(icon_name) : "".html_safe
|
10
8
|
super(attributes)
|
11
9
|
add_class "panel"
|
12
|
-
@title = h3(
|
10
|
+
@title = h3(title.to_s)
|
13
11
|
@contents = div(class: "panel_contents")
|
14
12
|
end
|
15
13
|
|
@@ -7,12 +7,17 @@ module ActiveAdmin
|
|
7
7
|
# Takes a ActiveAdmin::SidebarSection instance
|
8
8
|
def build(section)
|
9
9
|
@section = section
|
10
|
-
super(@section.title
|
10
|
+
super(@section.title)
|
11
11
|
add_class @section.custom_class if @section.custom_class
|
12
12
|
self.id = @section.id
|
13
13
|
build_sidebar_content
|
14
14
|
end
|
15
15
|
|
16
|
+
# Renders attributes_table_for current resource
|
17
|
+
def attributes_table(*args, &block)
|
18
|
+
attributes_table_for resource, *args, &block
|
19
|
+
end
|
20
|
+
|
16
21
|
protected
|
17
22
|
|
18
23
|
def build_sidebar_content
|
@@ -10,8 +10,9 @@ module ActiveAdmin
|
|
10
10
|
def build(obj, *attrs)
|
11
11
|
options = attrs.extract_options!
|
12
12
|
@sortable = options.delete(:sortable)
|
13
|
-
@resource_class = options.delete(:i18n)
|
14
13
|
@collection = obj.respond_to?(:each) && !obj.is_a?(Hash) ? obj : [obj]
|
14
|
+
@resource_class = options.delete(:i18n)
|
15
|
+
@resource_class ||= @collection.klass if @collection.respond_to? :klass
|
15
16
|
@columns = []
|
16
17
|
@row_class = options.delete(:row_class)
|
17
18
|
|
@@ -91,7 +91,7 @@ module ActiveAdmin
|
|
91
91
|
# index do
|
92
92
|
# column :title
|
93
93
|
# actions do |post|
|
94
|
-
# a
|
94
|
+
# a "View", href: admin_post_path(post)
|
95
95
|
# end
|
96
96
|
# end
|
97
97
|
# ```
|
@@ -277,7 +277,7 @@ module ActiveAdmin
|
|
277
277
|
#
|
278
278
|
# # Append some actions onto the end of the default actions using arbre dsl.
|
279
279
|
# actions do |admin_user|
|
280
|
-
# a
|
280
|
+
# a 'Grant Admin', href: grant_admin_admin_user_path(admin_user)
|
281
281
|
# end
|
282
282
|
#
|
283
283
|
# # Custom actions without the defaults.
|
@@ -35,6 +35,10 @@ module ActiveAdmin
|
|
35
35
|
text_node(favicon_link_tag(active_admin_namespace.favicon))
|
36
36
|
end
|
37
37
|
|
38
|
+
active_admin_namespace.meta_tags.each do |name, content|
|
39
|
+
text_node(tag(:meta, name: name, content: content))
|
40
|
+
end
|
41
|
+
|
38
42
|
text_node csrf_meta_tag
|
39
43
|
end
|
40
44
|
end
|
@@ -6,7 +6,7 @@ module ActiveAdmin
|
|
6
6
|
|
7
7
|
def install_assets
|
8
8
|
template 'active_admin.js.coffee', 'app/assets/javascripts/active_admin.js.coffee'
|
9
|
-
template
|
9
|
+
template "active_admin.scss", "app/assets/stylesheets/active_admin.scss"
|
10
10
|
end
|
11
11
|
|
12
12
|
end
|
data/lib/generators/active_admin/assets/templates/{active_admin.css.scss → active_admin.scss}
RENAMED
File without changes
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require "active_admin/error"
|
2
|
+
require "active_admin/dependency"
|
2
3
|
|
3
4
|
module ActiveAdmin
|
4
5
|
module Generators
|
@@ -16,7 +17,7 @@ module ActiveAdmin
|
|
16
17
|
|
17
18
|
def install_devise
|
18
19
|
begin
|
19
|
-
Dependency.devise! Dependency::DEVISE
|
20
|
+
Dependency.devise! Dependency::Requirements::DEVISE
|
20
21
|
rescue DependencyError => e
|
21
22
|
raise ActiveAdmin::GeneratorError, "#{e.message} If you don't want to use devise, run the generator with --skip-users."
|
22
23
|
end
|
@@ -50,27 +51,14 @@ module ActiveAdmin
|
|
50
51
|
gsub_file routes_file, /devise_for :#{plural_table_name}$/, "devise_for :#{plural_table_name}, ActiveAdmin::Devise.config"
|
51
52
|
end
|
52
53
|
|
53
|
-
def
|
54
|
-
|
55
|
-
|
56
|
-
return if
|
57
|
-
|
58
|
-
devise_migration_content = File.read(devise_migration_file)
|
54
|
+
def add_default_user_to_seed
|
55
|
+
seeds_paths = Rails.application.paths["db/seeds.rb"] || Rails.application.paths["db/seeds"] # "db/seeds" => Rails 3.2 fallback
|
56
|
+
seeds_file = seeds_paths.existent.first
|
57
|
+
return if seeds_file.nil? || !options[:default_user]
|
59
58
|
|
60
59
|
create_user_code = "#{class_name}.create!(email: 'admin@example.com', password: 'password', password_confirmation: 'password')"
|
61
60
|
|
62
|
-
|
63
|
-
inject_into_file devise_migration_file,
|
64
|
-
"def migrate(direction)\n super\n # Create a default user\n #{create_user_code} if direction == :up\n end\n\n ",
|
65
|
-
before: "def change"
|
66
|
-
elsif devise_migration_content[/def (self.)?up/]
|
67
|
-
inject_into_file devise_migration_file,
|
68
|
-
"# Create a default user\n #{create_user_code}\n\n ",
|
69
|
-
before: "add_index :#{table_name}, :email"
|
70
|
-
else
|
71
|
-
puts devise_migration_content
|
72
|
-
raise "Failed to add default admin user to migration."
|
73
|
-
end
|
61
|
+
append_to_file seeds_file, create_user_code
|
74
62
|
end
|
75
63
|
end
|
76
64
|
end
|
@@ -126,6 +126,10 @@ ActiveAdmin.setup do |config|
|
|
126
126
|
#
|
127
127
|
# You can change the name under which comments are registered:
|
128
128
|
# config.comments_registration_name = 'AdminComment'
|
129
|
+
#
|
130
|
+
# You can change the order for the comments and you can change the column
|
131
|
+
# to be used for ordering
|
132
|
+
# config.comments_order = 'created_at ASC'
|
129
133
|
|
130
134
|
# == Batch Actions
|
131
135
|
#
|
@@ -140,10 +144,31 @@ ActiveAdmin.setup do |config|
|
|
140
144
|
#
|
141
145
|
# config.before_filter :do_something_awesome
|
142
146
|
|
147
|
+
# == Localize Date/Time Format
|
148
|
+
#
|
149
|
+
# Set the localize format to display dates and times.
|
150
|
+
# To understand how to localize your app with I18n, read more at
|
151
|
+
# https://github.com/svenfuchs/i18n/blob/master/lib%2Fi18n%2Fbackend%2Fbase.rb#L52
|
152
|
+
#
|
153
|
+
config.localize_format = :long
|
154
|
+
|
143
155
|
# == Setting a Favicon
|
144
156
|
#
|
145
157
|
# config.favicon = 'favicon.ico'
|
146
158
|
|
159
|
+
# == Meta Tags
|
160
|
+
#
|
161
|
+
# Add additional meta tags to the head element of active admin pages.
|
162
|
+
#
|
163
|
+
# Add tags to all pages logged in users see:
|
164
|
+
# config.meta_tags = { author: 'My Company' }
|
165
|
+
|
166
|
+
# By default, sign up/sign in/recover password pages are excluded
|
167
|
+
# from showing up in search engine results by adding a robots meta
|
168
|
+
# tag. You can reset the hash of meta tags included in logged out
|
169
|
+
# pages:
|
170
|
+
# config.meta_tags_for_logged_out_pages = {}
|
171
|
+
|
147
172
|
# == Removing Breadcrumbs
|
148
173
|
#
|
149
174
|
# Breadcrumbs are enabled by default. You can customize them for individual
|
@@ -222,6 +247,10 @@ ActiveAdmin.setup do |config|
|
|
222
247
|
# You can control the default per page count for all resources here.
|
223
248
|
#
|
224
249
|
# config.default_per_page = 30
|
250
|
+
#
|
251
|
+
# You can control the max per page count too.
|
252
|
+
#
|
253
|
+
# config.max_per_page = 10_000
|
225
254
|
|
226
255
|
# == Filters
|
227
256
|
#
|
@@ -1,11 +1,17 @@
|
|
1
|
+
require 'active_admin/generators/boilerplate'
|
2
|
+
|
1
3
|
module ActiveAdmin
|
2
4
|
module Generators
|
3
5
|
class ResourceGenerator < Rails::Generators::NamedBase
|
4
6
|
desc "Registers resources with Active Admin"
|
5
7
|
|
8
|
+
class_option :include_boilerplate, type: :boolean, default: false,
|
9
|
+
desc: "Generate boilerplate code for your resource."
|
10
|
+
|
6
11
|
source_root File.expand_path("../templates", __FILE__)
|
7
12
|
|
8
13
|
def generate_config_file
|
14
|
+
@boilerplate = ActiveAdmin::Generators::Boilerplate.new(class_name)
|
9
15
|
template "admin.rb", "app/admin/#{file_path.tr('/', '_')}.rb"
|
10
16
|
end
|
11
17
|
|
@@ -1,18 +1,39 @@
|
|
1
1
|
ActiveAdmin.register <%= class_name %> do
|
2
|
-
|
3
2
|
<% if Rails::VERSION::MAJOR == 4 || defined?(ActionController::StrongParameters) %>
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
3
|
+
# See permitted parameters documentation:
|
4
|
+
# https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters
|
5
|
+
#
|
6
|
+
# permit_params :list, :of, :attributes, :on, :model
|
7
|
+
#
|
8
|
+
# or
|
9
|
+
#
|
10
|
+
# permit_params do
|
11
|
+
# permitted = [:permitted, :attributes]
|
12
|
+
# permitted << :other if resource.something?
|
13
|
+
# permitted
|
14
|
+
# end
|
16
15
|
<% end %>
|
16
|
+
<% if options.include_boilerplate? %>
|
17
|
+
# Limit actions available to your users by adding them to the 'except' array
|
18
|
+
# actions :all, except: []
|
19
|
+
|
20
|
+
# Add or remove filters (you can use any ActiveRecord scope) to toggle their
|
21
|
+
# visibility in the sidebar
|
22
|
+
<%= @boilerplate.filters %>
|
23
|
+
|
24
|
+
# Add or remove columns to toggle their visiblity in the index action
|
25
|
+
# index do
|
26
|
+
# selectable_column
|
27
|
+
# id_column
|
28
|
+
<%= @boilerplate.columns %>
|
29
|
+
# actions
|
30
|
+
# end
|
17
31
|
|
32
|
+
# Add or remove rows to toggle their visiblity in the show action
|
33
|
+
# show do |<%= class_name.downcase %>|
|
34
|
+
<%= @boilerplate.rows %>
|
35
|
+
# end
|
36
|
+
|
37
|
+
# Add or remove fields to toggle their visibility in the form
|
38
|
+
<% end %>
|
18
39
|
end
|
data/spec/rails_helper.rb
CHANGED
@@ -107,6 +107,10 @@ require ENV['RAILS_ROOT'] + '/config/environment'
|
|
107
107
|
|
108
108
|
require 'rspec/rails'
|
109
109
|
|
110
|
+
# Prevent Test::Unit's AutoRunner from executing during RSpec's rake task on
|
111
|
+
# JRuby
|
112
|
+
Test::Unit.run = true if defined?(Test::Unit) && Test::Unit.respond_to?(:run=)
|
113
|
+
|
110
114
|
# Setup Some Admin stuff for us to play with
|
111
115
|
include ActiveAdminIntegrationSpecHelper
|
112
116
|
load_defaults!
|
@@ -133,9 +137,9 @@ end
|
|
133
137
|
|
134
138
|
# All RSpec configuration needs to happen before any examples
|
135
139
|
# or else it whines.
|
136
|
-
require
|
140
|
+
require "support/active_admin_request_helpers"
|
137
141
|
RSpec.configure do |c|
|
138
|
-
c.include
|
142
|
+
c.include ActiveAdminRequestHelpers, type: :request
|
139
143
|
c.include Devise::TestHelpers, type: :controller
|
140
144
|
end
|
141
145
|
|