activeadmin 0.5.1 → 0.6.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.
- data/.travis.yml +8 -5
- data/CHANGELOG.md +151 -0
- data/Gemfile +16 -16
- data/LICENSE +1 -1
- data/activeadmin.gemspec +1 -0
- data/app/assets/images/active_admin/index_list_icons/block_icon.svg +10 -0
- data/app/assets/images/active_admin/index_list_icons/blog_icon.svg +4 -0
- data/app/assets/images/active_admin/index_list_icons/grid_icon.svg +13 -0
- data/app/assets/images/active_admin/index_list_icons/table_icon.svg +3 -0
- data/app/assets/javascripts/active_admin/components/jquery.aa.checkbox-toggler.js.coffee +17 -44
- data/app/assets/javascripts/active_admin/components/jquery.aa.dropdown-menu.js.coffee +2 -4
- data/app/assets/javascripts/active_admin/components/jquery.aa.popover.js.coffee +0 -3
- data/app/assets/javascripts/active_admin/components/jquery.aa.table-checkbox-toggler.js.coffee +10 -12
- data/app/assets/javascripts/active_admin/pages/application.js.coffee +13 -10
- data/app/assets/javascripts/active_admin/pages/batch_actions.js.coffee +3 -3
- data/app/assets/stylesheets/active_admin/_base.css.scss +1 -0
- data/app/assets/stylesheets/active_admin/_header.css.scss +5 -2
- data/app/assets/stylesheets/active_admin/components/_dropdown_menu.scss +2 -2
- data/app/assets/stylesheets/active_admin/components/_index_list.scss +12 -0
- data/app/assets/stylesheets/active_admin/components/_popovers.css.scss +2 -2
- data/app/assets/stylesheets/active_admin/components/_table_tools.css.scss +2 -2
- data/app/assets/stylesheets/active_admin/mixins/_buttons.css.scss +4 -4
- data/app/assets/stylesheets/active_admin/mixins/_gradients.css.scss +5 -4
- data/app/assets/stylesheets/active_admin/mixins/_sections.css.scss +1 -1
- data/app/assets/stylesheets/active_admin/pages/_logged_out.scss +1 -1
- data/app/assets/stylesheets/active_admin/print.css.scss +2 -2
- data/app/assets/stylesheets/active_admin/structure/_title_bar.scss +1 -1
- data/app/views/active_admin/devise/unlocks/new.html.erb +14 -12
- data/docs/1-general-configuration.md +13 -0
- data/docs/10-custom-pages.md +40 -28
- data/docs/11-decorators.md +6 -4
- data/docs/12-arbre-components.md +1 -1
- data/docs/13-authorization-adapter.md +206 -0
- data/docs/2-resource-customization.md +129 -14
- data/docs/3-index-pages.md +65 -0
- data/docs/3-index-pages/create-an-index.md +29 -0
- data/docs/3-index-pages/index-as-table.md +35 -11
- data/docs/5-forms.md +2 -2
- data/features/authorization.feature +64 -0
- data/features/authorization_cancan.feature +52 -0
- data/features/belongs_to.feature +41 -5
- data/features/index/batch_actions.feature +27 -3
- data/features/index/formats.feature +27 -0
- data/features/index/index_as_table.feature +74 -2
- data/features/index/index_parameters.feature +69 -0
- data/features/index/index_scopes.feature +7 -11
- data/features/index/page_title.feature +18 -0
- data/features/index/switch_index_view.feature +73 -0
- data/features/menu.feature +27 -0
- data/features/registering_pages.feature +21 -0
- data/features/step_definitions/additional_web_steps.rb +4 -0
- data/features/step_definitions/batch_action_steps.rb +16 -6
- data/features/step_definitions/index_scope_steps.rb +3 -3
- data/features/step_definitions/index_views_steps.rb +3 -0
- data/features/step_definitions/menu_steps.rb +4 -0
- data/features/support/env.rb +4 -0
- data/features/support/paths.rb +3 -0
- data/lib/active_admin.rb +4 -0
- data/lib/active_admin/application.rb +43 -76
- data/lib/active_admin/authorization_adapter.rb +128 -0
- data/lib/active_admin/base_controller.rb +18 -1
- data/lib/active_admin/base_controller/authorization.rb +153 -0
- data/lib/active_admin/base_controller/menu.rb +8 -3
- data/lib/active_admin/batch_actions/resource_extension.rb +8 -7
- data/lib/active_admin/batch_actions/views/batch_action_form.rb +1 -1
- data/lib/active_admin/cancan_adapter.rb +40 -0
- data/lib/active_admin/dashboards.rb +4 -5
- data/lib/active_admin/dashboards/dashboard_controller.rb +1 -1
- data/lib/active_admin/devise.rb +22 -7
- data/lib/active_admin/dsl.rb +18 -5
- data/lib/active_admin/engine.rb +1 -1
- data/lib/active_admin/filters/dsl.rb +1 -1
- data/lib/active_admin/filters/forms.rb +9 -7
- data/lib/active_admin/filters/resource_extension.rb +20 -15
- data/lib/active_admin/form_builder.rb +44 -49
- data/lib/active_admin/helpers/optional_display.rb +4 -8
- data/lib/active_admin/inputs/filter_boolean_input.rb +1 -1
- data/lib/active_admin/inputs/filter_string_input.rb +5 -1
- data/lib/active_admin/locales/bg.yml +1 -1
- data/lib/active_admin/locales/ca.yml +1 -1
- data/lib/active_admin/locales/cs.yml +26 -25
- data/lib/active_admin/locales/da.yml +1 -1
- data/lib/active_admin/locales/de.yml +1 -1
- data/lib/active_admin/locales/en.yml +11 -1
- data/lib/active_admin/locales/es.yml +16 -16
- data/lib/active_admin/locales/fr.yml +1 -1
- data/lib/active_admin/locales/he.yml +1 -1
- data/lib/active_admin/locales/hr.yml +1 -1
- data/lib/active_admin/locales/hu.yml +1 -1
- data/lib/active_admin/locales/it.yml +1 -1
- data/lib/active_admin/locales/ja.yml +4 -1
- data/lib/active_admin/locales/ko.yml +1 -1
- data/lib/active_admin/locales/lt.yml +1 -1
- data/lib/active_admin/locales/lv.yml +12 -1
- data/lib/active_admin/locales/nl.yml +2 -2
- data/lib/active_admin/locales/no-NB.yml +22 -1
- data/lib/active_admin/locales/pl.yml +1 -1
- data/lib/active_admin/locales/pt-BR.yml +1 -1
- data/lib/active_admin/locales/pt-PT.yml +81 -0
- data/lib/active_admin/locales/ro.yml +1 -1
- data/lib/active_admin/locales/ru.yml +1 -1
- data/lib/active_admin/locales/sv-SE.yml +1 -1
- data/lib/active_admin/locales/tr.yml +1 -1
- data/lib/active_admin/locales/vi.yml +1 -1
- data/lib/active_admin/locales/zh-CN.yml +1 -1
- data/lib/active_admin/locales/zh-TW.yml +1 -1
- data/lib/active_admin/menu.rb +76 -38
- data/lib/active_admin/menu_collection.rb +96 -0
- data/lib/active_admin/menu_item.rb +61 -71
- data/lib/active_admin/namespace.rb +67 -5
- data/lib/active_admin/page.rb +6 -0
- data/lib/active_admin/page_controller.rb +13 -3
- data/lib/active_admin/resource.rb +11 -20
- data/lib/active_admin/resource/action_items.rb +3 -3
- data/lib/active_admin/resource/controllers.rb +0 -17
- data/lib/active_admin/resource/menu.rb +52 -24
- data/lib/active_admin/resource/naming.rb +6 -10
- data/lib/active_admin/resource/page_presenters.rb +57 -3
- data/lib/active_admin/resource/routes.rb +46 -0
- data/lib/active_admin/resource_controller.rb +2 -17
- data/lib/active_admin/resource_controller/data_access.rb +299 -0
- data/lib/active_admin/resource_controller/decorators.rb +2 -1
- data/lib/active_admin/resource_dsl.rb +12 -14
- data/lib/active_admin/router.rb +61 -56
- data/lib/active_admin/scope.rb +28 -18
- data/lib/active_admin/version.rb +1 -1
- data/lib/active_admin/view_factory.rb +0 -1
- data/lib/active_admin/view_helpers/breadcrumb_helper.rb +13 -19
- data/lib/active_admin/view_helpers/fields_for.rb +2 -0
- data/lib/active_admin/view_helpers/form_helper.rb +1 -1
- data/lib/active_admin/view_helpers/method_or_proc_helper.rb +66 -11
- data/lib/active_admin/views/components/attributes_table.rb +7 -4
- data/lib/active_admin/views/components/index_list.rb +68 -0
- data/lib/active_admin/views/components/paginated_collection.rb +13 -9
- data/lib/active_admin/views/components/scopes.rb +2 -8
- data/lib/active_admin/views/components/table_for.rb +1 -1
- data/lib/active_admin/views/footer.rb +1 -1
- data/lib/active_admin/views/header.rb +3 -2
- data/lib/active_admin/views/index_as_block.rb +4 -0
- data/lib/active_admin/views/index_as_blog.rb +4 -0
- data/lib/active_admin/views/index_as_grid.rb +4 -0
- data/lib/active_admin/views/index_as_table.rb +49 -7
- data/lib/active_admin/views/pages/index.rb +19 -4
- data/lib/active_admin/views/tabbed_navigation.rb +10 -54
- data/lib/generators/active_admin/install/install_generator.rb +5 -1
- data/lib/generators/active_admin/install/templates/active_admin.rb.erb +58 -0
- data/spec/integration/{default_namespace.rb → default_namespace_spec.rb} +0 -16
- data/spec/spec_helper.rb +3 -0
- data/spec/support/detect_rails_version.rb +10 -3
- data/spec/support/rails_template.rb +1 -1
- data/spec/support/templates/post_decorator.rb +6 -6
- data/spec/unit/application_spec.rb +5 -5
- data/spec/unit/authorization/authorization_adapter_spec.rb +61 -0
- data/spec/unit/authorization/controller_authorization_spec.rb +47 -0
- data/spec/unit/base_controller_spec.rb +0 -2
- data/spec/unit/batch_actions/resource_spec.rb +1 -1
- data/spec/unit/breadcrumbs_spec.rb +3 -3
- data/spec/unit/cancan_adapter_spec.rb +35 -0
- data/spec/unit/config_shared_examples.rb +9 -30
- data/spec/unit/devise_spec.rb +29 -0
- data/spec/unit/dsl_spec.rb +61 -0
- data/spec/unit/filters/filter_form_builder_spec.rb +58 -4
- data/spec/unit/filters/resource_spec.rb +17 -5
- data/spec/unit/form_builder_spec.rb +15 -0
- data/spec/unit/menu_collection_spec.rb +62 -0
- data/spec/unit/menu_item_spec.rb +51 -37
- data/spec/unit/menu_spec.rb +33 -29
- data/spec/unit/namespace/authorization_spec.rb +31 -0
- data/spec/unit/namespace/register_page_spec.rb +6 -28
- data/spec/unit/namespace/register_resource_spec.rb +11 -34
- data/spec/unit/namespace_spec.rb +63 -2
- data/spec/unit/page_controller_spec.rb +0 -3
- data/spec/unit/reloader_spec.rb +5 -5
- data/spec/unit/resource/menu_spec.rb +1 -13
- data/spec/unit/resource/naming_spec.rb +20 -2
- data/spec/unit/resource/page_presenters_spec.rb +14 -2
- data/spec/unit/resource_controller/{collection_spec.rb → data_access_spec.rb} +31 -13
- data/spec/unit/resource_controller_spec.rb +4 -5
- data/spec/unit/resource_spec.rb +33 -11
- data/spec/unit/routing_spec.rb +43 -0
- data/spec/unit/scope_spec.rb +13 -0
- data/spec/unit/view_factory_spec.rb +0 -1
- data/spec/unit/view_helpers/fields_for_spec.rb +4 -0
- data/spec/unit/view_helpers/form_helper_spec.rb +6 -2
- data/spec/unit/view_helpers/method_or_proc_helper_spec.rb +97 -0
- data/spec/unit/views/components/attributes_table_spec.rb +11 -0
- data/spec/unit/views/components/index_list_spec.rb +32 -0
- data/spec/unit/views/tabbed_navigation_spec.rb +42 -40
- data/tasks/test.rake +1 -1
- metadata +127 -40
- data/lib/active_admin/menu_builder.rb +0 -65
- data/lib/active_admin/resource_controller/callbacks.rb +0 -59
- data/lib/active_admin/resource_controller/collection.rb +0 -158
- data/lib/active_admin/views/utility_nav.rb +0 -41
- data/spec/unit/base_controller_shared_examples.rb +0 -25
- data/spec/unit/dsl_include_spec.rb +0 -20
data/lib/active_admin/scope.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module ActiveAdmin
|
2
2
|
class Scope
|
3
3
|
|
4
|
-
attr_reader :
|
4
|
+
attr_reader :scope_method, :id, :scope_block, :display_if_block, :show_count
|
5
5
|
|
6
6
|
# Create a Scope
|
7
7
|
#
|
@@ -13,32 +13,42 @@ module ActiveAdmin
|
|
13
13
|
# Scope.new('Published', :public)
|
14
14
|
# # => Scope with name 'Published' and scope method :public
|
15
15
|
#
|
16
|
-
# Scope.new
|
17
|
-
#
|
16
|
+
# Scope.new 'Published', :public, :if => proc { current_admin_user.can? :manage, resource_class } do |articles|
|
17
|
+
# articles.where :published => true
|
18
|
+
# end
|
19
|
+
# # => Scope with name 'Published' and scope method :public, optionally displaying the scope per the :if block
|
18
20
|
#
|
19
21
|
# Scope.new('Published') { |articles| articles.where(:published => true) }
|
20
22
|
# # => Scope with name 'Published' using a block to scope
|
21
23
|
#
|
24
|
+
# Scope.new ->{Date.today.strftime '%A'}, :published_today
|
25
|
+
# # => Scope with dynamic title using the :published_today scope method
|
26
|
+
#
|
22
27
|
def initialize(name, method = nil, options = {}, &block)
|
23
|
-
@name = name.
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
@
|
31
|
-
@scope_block = block
|
28
|
+
@name, @scope_method = name, method.try(:to_sym)
|
29
|
+
|
30
|
+
if name.is_a? Proc
|
31
|
+
raise "A string/symbol is required as the second argument if your label is a proc." unless method
|
32
|
+
@id = method.to_s.gsub(' ', '').underscore
|
33
|
+
else
|
34
|
+
@scope_method ||= name.to_sym
|
35
|
+
@id = name.to_s.gsub(' ', '').underscore
|
32
36
|
end
|
33
37
|
|
34
|
-
@
|
35
|
-
@
|
38
|
+
@scope_method = nil if @scope_method == :all
|
39
|
+
@scope_method, @scope_block = nil, block if block_given?
|
40
|
+
|
41
|
+
@show_count = options[:show_count].nil? ? true : options[:show_count]
|
42
|
+
@display_if_block = options[:if] || proc{ true }
|
36
43
|
end
|
37
44
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
45
|
+
def name
|
46
|
+
case @name
|
47
|
+
when Proc then @name.call.to_s
|
48
|
+
when String then @name
|
49
|
+
when Symbol then @name.to_s.titleize
|
50
|
+
else @name.to_s
|
51
|
+
end
|
42
52
|
end
|
43
53
|
|
44
54
|
end
|
data/lib/active_admin/version.rb
CHANGED
@@ -6,7 +6,6 @@ module ActiveAdmin
|
|
6
6
|
# Register Helper Renderers
|
7
7
|
register :global_navigation => ActiveAdmin::Views::TabbedNavigation,
|
8
8
|
:site_title => ActiveAdmin::Views::SiteTitle,
|
9
|
-
:utility_navigation => ActiveAdmin::Views::UtilityNav,
|
10
9
|
:action_items => ActiveAdmin::Views::ActionItems,
|
11
10
|
:title_bar => ActiveAdmin::Views::TitleBar,
|
12
11
|
:header => ActiveAdmin::Views::Header,
|
@@ -3,28 +3,22 @@ module ActiveAdmin
|
|
3
3
|
module BreadcrumbHelper
|
4
4
|
|
5
5
|
# Returns an array of links to use in a breadcrumb
|
6
|
-
def breadcrumb_links(path =
|
7
|
-
path
|
8
|
-
parts
|
9
|
-
parts.pop unless %w{ create update }.include?(params[:action])
|
10
|
-
crumbs = []
|
11
|
-
parts.each_with_index do |part, index|
|
12
|
-
name = nil
|
13
|
-
if part =~ /^\d|^[a-f0-9]{24}$/ && (parent = parts[index - 1])
|
14
|
-
begin
|
15
|
-
parent_class = parent.singularize.camelcase.constantize
|
16
|
-
obj = parent_class.find(part[/^[a-f0-9]{24}$/] ? part : part.to_i)
|
17
|
-
name = display_name(obj)
|
18
|
-
rescue
|
19
|
-
# ignored
|
20
|
-
end
|
21
|
-
end
|
6
|
+
def breadcrumb_links(path = request.path)
|
7
|
+
parts = path[1..-1].split('/') # remove leading "/" and split up URL path
|
8
|
+
parts.pop unless params[:action] =~ /^create|update$/ # remove last if not create/update
|
22
9
|
|
23
|
-
|
10
|
+
parts.each_with_index.map do |part, index|
|
11
|
+
# If an object (users/23), look it up via ActiveRecord and capture its name.
|
12
|
+
# If name is nil, look up the model translation, using `titlecase` as the backup.
|
13
|
+
if part =~ /^\d|^[a-f0-9]{24}$/ && parent = parts[index-1]
|
14
|
+
klass = parent.singularize.camelcase.constantize rescue nil
|
15
|
+
obj = klass.find_by_id(part) if klass
|
16
|
+
name = display_name(obj) if obj
|
17
|
+
end
|
18
|
+
name ||= I18n.t "activerecord.models.#{part.singularize}", :count => 1.1, :default => part.titlecase
|
24
19
|
|
25
|
-
|
20
|
+
link_to name, '/' + parts[0..index].join('/')
|
26
21
|
end
|
27
|
-
crumbs
|
28
22
|
end
|
29
23
|
|
30
24
|
end
|
@@ -11,7 +11,7 @@ module ActiveAdmin
|
|
11
11
|
def hidden_field_tags_for(params, options={})
|
12
12
|
fields_for_params(params, options).map do |kv|
|
13
13
|
k, v = kv.first
|
14
|
-
hidden_field_tag k, v
|
14
|
+
hidden_field_tag k, v, :id => sanitize_to_id("hidden_active_admin_#{k}")
|
15
15
|
end.join("\n").html_safe
|
16
16
|
end
|
17
17
|
end
|
@@ -1,24 +1,64 @@
|
|
1
1
|
module MethodOrProcHelper
|
2
2
|
|
3
|
+
# This method will either call the symbol on self or instance_exec the Proc
|
4
|
+
# within self. Any args will be passed along to the method dispatch.
|
5
|
+
#
|
6
|
+
# Calling with a Symbol:
|
7
|
+
#
|
8
|
+
# call_method_or_exec_proc(:to_s) #=> will call #to_s
|
9
|
+
#
|
10
|
+
# Calling with a Proc
|
11
|
+
#
|
12
|
+
# my_proc = Proc.new{ to_s }
|
13
|
+
# call_method_or_exec_proc(my_proc) #=> will instance_exec in self
|
14
|
+
#
|
15
|
+
def call_method_or_exec_proc(symbol_or_proc, *args)
|
16
|
+
case symbol_or_proc
|
17
|
+
when Symbol, String
|
18
|
+
send(symbol_or_proc, *args)
|
19
|
+
when Proc
|
20
|
+
instance_exec(*args, &symbol_or_proc)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
3
24
|
# Many times throughout the views we want to either call a method on an object
|
4
25
|
# or instance_exec a proc passing in the object as the first parameter. This
|
5
|
-
# method
|
26
|
+
# method wraps that pattern.
|
27
|
+
#
|
28
|
+
# Calling with a Symbol:
|
6
29
|
#
|
7
|
-
#
|
8
|
-
# OR
|
9
|
-
# proc = Proc.new{|s| s.size }
|
10
|
-
# call_method_or_proc_on(@my_obj, proc)
|
30
|
+
# call_method_or_proc_on(@my_obj, :size) same as @my_obj.size
|
11
31
|
#
|
12
|
-
|
13
|
-
|
32
|
+
# Calling with a Proc:
|
33
|
+
#
|
34
|
+
# proc = Proc.new{|s| s.size }
|
35
|
+
# call_method_or_proc_on(@my_obj, proc)
|
36
|
+
#
|
37
|
+
# By default, the Proc will be instance_exec'd within self. If you would rather
|
38
|
+
# not instance exec, but just call the Proc, then pass along `:exec => false` in
|
39
|
+
# the options hash.
|
40
|
+
#
|
41
|
+
# proc = Proc.new{|s| s.size }
|
42
|
+
# call_method_or_proc_on(@my_obj, proc, :exec => false)
|
43
|
+
#
|
44
|
+
# You can pass along any necessary arguments to the method / Proc as arguments. For
|
45
|
+
# example:
|
46
|
+
#
|
47
|
+
# call_method_or_proc_on(@my_obj, :find, 1) #=> @my_obj.find(1)
|
48
|
+
#
|
49
|
+
def call_method_or_proc_on(receiver, *args)
|
50
|
+
options = { :exec => true }.merge(args.extract_options!)
|
51
|
+
|
52
|
+
symbol_or_proc = args.shift
|
53
|
+
|
14
54
|
case symbol_or_proc
|
15
55
|
when Symbol, String
|
16
|
-
|
56
|
+
receiver.send(symbol_or_proc.to_sym, *args)
|
17
57
|
when Proc
|
18
|
-
if exec
|
19
|
-
instance_exec(
|
58
|
+
if options[:exec]
|
59
|
+
instance_exec(receiver, *args, &symbol_or_proc)
|
20
60
|
else
|
21
|
-
symbol_or_proc.call(
|
61
|
+
symbol_or_proc.call(receiver, *args)
|
22
62
|
end
|
23
63
|
end
|
24
64
|
end
|
@@ -35,4 +75,19 @@ module MethodOrProcHelper
|
|
35
75
|
string_symbol_or_proc
|
36
76
|
end
|
37
77
|
end
|
78
|
+
|
79
|
+
# This method is different from the others in that it calls `instance_eval` on the reciever,
|
80
|
+
# passing it the proc. This evaluates the proc in the context of the reciever, thus changing
|
81
|
+
# what `self` means inside the proc.
|
82
|
+
def render_in_context(context, obj)
|
83
|
+
context ||= self # default to `self`
|
84
|
+
case obj
|
85
|
+
when Proc
|
86
|
+
context.instance_exec &obj
|
87
|
+
when Symbol
|
88
|
+
context.send obj
|
89
|
+
else
|
90
|
+
obj
|
91
|
+
end
|
92
|
+
end
|
38
93
|
end
|
@@ -17,13 +17,16 @@ module ActiveAdmin
|
|
17
17
|
attrs.each {|attr| row(attr) }
|
18
18
|
end
|
19
19
|
|
20
|
-
def row(
|
21
|
-
|
20
|
+
def row(*args, &block)
|
21
|
+
title = args[0]
|
22
|
+
options = args.extract_options!
|
23
|
+
options[:class] ||= :row
|
24
|
+
@table << tr(options) do
|
22
25
|
th do
|
23
|
-
header_content_for(
|
26
|
+
header_content_for(title)
|
24
27
|
end
|
25
28
|
td do
|
26
|
-
content_for(block ||
|
29
|
+
content_for(block || title)
|
27
30
|
end
|
28
31
|
end
|
29
32
|
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'active_admin/helpers/collection'
|
2
|
+
|
3
|
+
module ActiveAdmin
|
4
|
+
module Views
|
5
|
+
|
6
|
+
# Renders a collection of index views available to the resource
|
7
|
+
# as a list with a separator
|
8
|
+
class IndexList < ActiveAdmin::Component
|
9
|
+
builder_method :index_list_renderer
|
10
|
+
|
11
|
+
include ::ActiveAdmin::Helpers::Collection
|
12
|
+
|
13
|
+
def default_class_name
|
14
|
+
"indexes table_tools_segmented_control"
|
15
|
+
end
|
16
|
+
|
17
|
+
def tag_name
|
18
|
+
'ul'
|
19
|
+
end
|
20
|
+
|
21
|
+
# Builds the links for presenting different index views to the user
|
22
|
+
#
|
23
|
+
# @param [Array] index_classes The class constants that represent index page presenters
|
24
|
+
def build(index_classes)
|
25
|
+
unless current_filter_search_empty?
|
26
|
+
index_classes.each do |index_class|
|
27
|
+
build_index_list(index_class)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
protected
|
33
|
+
|
34
|
+
# Builds the individual link and HTML classes for each index page presenter
|
35
|
+
#
|
36
|
+
# @param [Class] index_class The class on which to build the link and html classes
|
37
|
+
def build_index_list(index_class)
|
38
|
+
li :class => classes_for_index(index_class) do
|
39
|
+
a :href => url_for(params.merge(:as => index_class.index_name.to_sym)), :class => "table_tools_button" do
|
40
|
+
name = index_class.index_name
|
41
|
+
I18n.t("active_admin.index_list.#{name}", :default => name.to_s.titleize)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def classes_for_index(index_class)
|
47
|
+
classes = ["index"]
|
48
|
+
classes << "selected" if current_index?(index_class)
|
49
|
+
classes.join(" ")
|
50
|
+
end
|
51
|
+
|
52
|
+
def current_index?(index_class)
|
53
|
+
if params[:as]
|
54
|
+
params[:as] == index_class.index_name
|
55
|
+
else
|
56
|
+
active_admin_config.default_index_class == index_class
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def current_filter_search_empty?
|
61
|
+
params.include?(:q) && collection_is_empty?
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
|
@@ -29,13 +29,12 @@ module ActiveAdmin
|
|
29
29
|
|
30
30
|
# Builds a new paginated collection component
|
31
31
|
#
|
32
|
-
#
|
33
|
-
#
|
34
|
-
#
|
35
|
-
#
|
36
|
-
#
|
37
|
-
#
|
38
|
-
# :download_links - Set to false to skip download format links
|
32
|
+
# collection => A paginated collection from kaminari
|
33
|
+
# options => These options will be passed to `page_entries_info`
|
34
|
+
# entry_name => The name to display for this resource collection
|
35
|
+
# param_name => Parameter name for page number in the links (:page by default)
|
36
|
+
# download_links => Download links override (false or [:csv, :pdf])
|
37
|
+
#
|
39
38
|
def build(collection, options = {})
|
40
39
|
@collection = collection
|
41
40
|
@param_name = options.delete(:param_name)
|
@@ -45,7 +44,6 @@ module ActiveAdmin
|
|
45
44
|
raise(StandardError, "Collection is not a paginated scope. Set collection.page(params[:page]).per(10) before calling :paginated_collection.")
|
46
45
|
end
|
47
46
|
|
48
|
-
|
49
47
|
@contents = div(:class => "paginated_collection_contents")
|
50
48
|
build_pagination_with_formats(options)
|
51
49
|
@built = true
|
@@ -66,7 +64,13 @@ module ActiveAdmin
|
|
66
64
|
div :id => "index_footer" do
|
67
65
|
build_pagination
|
68
66
|
div(page_entries_info(options).html_safe, :class => "pagination_information")
|
69
|
-
|
67
|
+
|
68
|
+
if @download_links.is_a?(Array) && !@download_links.empty?
|
69
|
+
build_download_format_links @download_links
|
70
|
+
else
|
71
|
+
build_download_format_links unless @download_links == false
|
72
|
+
end
|
73
|
+
|
70
74
|
end
|
71
75
|
end
|
72
76
|
|
@@ -21,10 +21,8 @@ module ActiveAdmin
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def build(scopes, options = {})
|
24
|
-
|
25
|
-
|
26
|
-
build_scope(scope, options) if call_method_or_proc_on(self, scope.display_if_block)
|
27
|
-
end
|
24
|
+
scopes.each do |scope|
|
25
|
+
build_scope(scope, options) if call_method_or_proc_on(self, scope.display_if_block)
|
28
26
|
end
|
29
27
|
end
|
30
28
|
|
@@ -57,10 +55,6 @@ module ActiveAdmin
|
|
57
55
|
end
|
58
56
|
end
|
59
57
|
|
60
|
-
def current_filter_search_empty?
|
61
|
-
params.include?(:q) && collection_is_empty?
|
62
|
-
end
|
63
|
-
|
64
58
|
# Return the count for the scope passed in.
|
65
59
|
def get_scope_count(scope)
|
66
60
|
collection_size(scope_chain(scope, collection_before_scope))
|
@@ -79,7 +79,7 @@ module ActiveAdmin
|
|
79
79
|
def build_table_body
|
80
80
|
@tbody = tbody do
|
81
81
|
# Build enough rows for our collection
|
82
|
-
@collection.each{|
|
82
|
+
@collection.each{|elem| tr(:class => cycle('odd', 'even'), :id => dom_id(elem)) }
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
@@ -10,7 +10,7 @@ module ActiveAdmin
|
|
10
10
|
private
|
11
11
|
|
12
12
|
def powered_by_message
|
13
|
-
para t('active_admin.powered_by',
|
13
|
+
para I18n.t('active_admin.powered_by',
|
14
14
|
:active_admin => link_to("Active Admin", "http://www.activeadmin.info"),
|
15
15
|
:version => ActiveAdmin::VERSION).html_safe
|
16
16
|
end
|
@@ -7,6 +7,7 @@ module ActiveAdmin
|
|
7
7
|
|
8
8
|
@namespace = namespace
|
9
9
|
@menu = menu
|
10
|
+
@utility_menu = @namespace.fetch_menu(:utility_navigation)
|
10
11
|
|
11
12
|
build_site_title
|
12
13
|
build_global_navigation
|
@@ -19,11 +20,11 @@ module ActiveAdmin
|
|
19
20
|
end
|
20
21
|
|
21
22
|
def build_global_navigation
|
22
|
-
insert_tag view_factory.global_navigation, @menu, :class => 'header-item'
|
23
|
+
insert_tag view_factory.global_navigation, @menu, :class => 'header-item tabs'
|
23
24
|
end
|
24
25
|
|
25
26
|
def build_utility_navigation
|
26
|
-
insert_tag view_factory.
|
27
|
+
insert_tag view_factory.global_navigation, @utility_menu, :id => "utility_nav", :class => 'header-item tabs'
|
27
28
|
end
|
28
29
|
|
29
30
|
end
|