andrewroth_activeadmin 0.3.4 → 0.3.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +159 -3
- data/CONTRIBUTING.md +113 -0
- data/LICENSE +1 -1
- data/README.rdoc +19 -20
- data/activeadmin.gemspec +3 -1
- data/app/assets/javascripts/active_admin/application.js +9 -0
- data/app/assets/javascripts/active_admin/base.js +4 -12
- data/app/assets/stylesheets/active_admin/_base.css.scss +16 -340
- data/app/assets/stylesheets/active_admin/_forms.css.scss +13 -7
- data/app/assets/stylesheets/active_admin/_header.css.scss +23 -4
- data/app/assets/stylesheets/active_admin/components/_blank_slates.scss +31 -0
- data/app/assets/stylesheets/active_admin/components/_breadcrumbs.scss +20 -0
- data/app/assets/stylesheets/active_admin/components/_buttons.scss +12 -0
- data/app/assets/stylesheets/active_admin/components/_flash_messages.css.scss +2 -0
- data/app/assets/stylesheets/active_admin/components/_grid.scss +9 -0
- data/app/assets/stylesheets/active_admin/components/_links.scss +5 -0
- data/app/assets/stylesheets/active_admin/components/_pagination.scss +34 -0
- data/app/assets/stylesheets/active_admin/components/_panels.scss +6 -0
- data/app/assets/stylesheets/active_admin/components/_scopes.scss +10 -0
- data/app/assets/stylesheets/active_admin/components/_status_tags.scss +12 -0
- data/app/assets/stylesheets/active_admin/components/_table_tools.css.scss +101 -0
- data/app/assets/stylesheets/active_admin/mixins/_all.css.scss +2 -1
- data/app/assets/stylesheets/active_admin/mixins/_buttons.css.scss +50 -13
- data/app/assets/stylesheets/active_admin/mixins/_gradients.css.scss +9 -1
- data/app/assets/stylesheets/active_admin/mixins/_sections.css.scss +7 -5
- data/app/assets/stylesheets/active_admin/mixins/_shadows.css.scss +1 -0
- data/app/assets/stylesheets/active_admin/mixins/_typography.scss +3 -0
- data/app/assets/stylesheets/active_admin/mixins/_variables.css.scss +1 -0
- data/app/assets/stylesheets/active_admin/pages/_dashboard.scss +5 -0
- data/app/assets/stylesheets/active_admin/pages/_logged_out.scss +44 -0
- data/app/assets/stylesheets/active_admin/structure/_footer.scss +14 -0
- data/app/assets/stylesheets/active_admin/structure/_main_structure.scss +26 -0
- data/app/assets/stylesheets/active_admin/structure/_title_bar.scss +44 -0
- data/app/views/active_admin/devise/passwords/edit.html.erb +1 -1
- data/app/views/active_admin/devise/passwords/new.html.erb +1 -1
- data/app/views/active_admin/devise/sessions/new.html.erb +1 -1
- data/app/views/active_admin/devise/shared/_links.erb +1 -1
- data/app/views/active_admin/devise/unlocks/new.html.erb +1 -1
- data/app/views/active_admin/page/index.html.arb +1 -0
- data/app/views/layouts/active_admin_logged_out.html.erb +2 -2
- data/cucumber.yml +3 -2
- data/docs/1-general-configuration.md +46 -10
- data/docs/6-show-screens.md +7 -0
- data/docs/8-custom-actions.md +12 -2
- data/docs/9-custom-pages.md +84 -0
- data/features/belongs_to.feature +27 -0
- data/features/comments/commenting.feature +3 -2
- data/features/dashboard.feature +18 -0
- data/features/development_reloading.feature +19 -0
- data/features/index/filter_with_check_boxes.feature +25 -0
- data/features/index/index_as_table.feature +14 -0
- data/features/index/index_scopes.feature +42 -0
- data/features/index/pagination.feature +19 -1
- data/features/menu.feature +22 -2
- data/features/registering_assets.feature +2 -2
- data/features/registering_pages.feature +66 -0
- data/features/specifying_actions.feature +5 -0
- data/features/step_definitions/action_item_steps.rb +2 -6
- data/features/step_definitions/action_link_steps.rb +7 -0
- data/features/step_definitions/additional_web_steps.rb +8 -0
- data/features/step_definitions/asset_steps.rb +5 -1
- data/features/step_definitions/breadcrumb_steps.rb +5 -0
- data/features/step_definitions/configuration_steps.rb +56 -8
- data/features/step_definitions/dashboard_steps.rb +5 -1
- data/features/step_definitions/factory_steps.rb +9 -2
- data/features/step_definitions/flash_steps.rb +9 -1
- data/features/step_definitions/index_scope_steps.rb +16 -4
- data/features/step_definitions/member_link_steps.rb +7 -0
- data/features/step_definitions/site_title_steps.rb +15 -0
- data/features/support/paths.rb +6 -0
- data/features/users/logging_out.feature +11 -0
- data/lib/active_admin.rb +25 -10
- data/lib/active_admin/application.rb +63 -20
- data/lib/active_admin/arbre/html/element.rb +10 -0
- data/lib/active_admin/asset_registration.rb +15 -2
- data/lib/active_admin/base_controller.rb +61 -0
- data/lib/active_admin/{resource_controller → base_controller}/menu.rb +1 -1
- data/lib/active_admin/comments.rb +48 -54
- data/lib/active_admin/comments/comment.rb +13 -2
- data/lib/active_admin/comments/namespace_helper.rb +1 -1
- data/lib/active_admin/comments/views/active_admin_comments.rb +7 -3
- data/lib/active_admin/dashboards.rb +4 -0
- data/lib/active_admin/dashboards/dashboard_controller.rb +20 -4
- data/lib/active_admin/dsl.rb +6 -159
- data/lib/active_admin/event.rb +5 -3
- data/lib/active_admin/filter_form_builder.rb +53 -0
- data/lib/active_admin/form_builder.rb +25 -19
- data/lib/active_admin/inputs.rb +14 -0
- data/lib/active_admin/inputs/datepicker_input.rb +11 -0
- data/lib/active_admin/inputs/filter_base.rb +46 -0
- data/lib/active_admin/inputs/filter_check_boxes_input.rb +40 -0
- data/lib/active_admin/inputs/filter_date_range_input.rb +34 -0
- data/lib/active_admin/inputs/filter_numeric_input.rb +55 -0
- data/lib/active_admin/inputs/filter_select_input.rb +23 -0
- data/lib/active_admin/inputs/filter_string_input.rb +22 -0
- data/lib/active_admin/locales/ca.yml +44 -0
- data/lib/active_admin/locales/cs.yml +14 -10
- data/lib/active_admin/locales/de.yml +43 -0
- data/lib/active_admin/locales/en.yml +5 -0
- data/lib/active_admin/locales/hr.yml +40 -0
- data/lib/active_admin/locales/ko.yml +40 -0
- data/lib/active_admin/locales/lv.yml +43 -0
- data/lib/active_admin/locales/nl.yml +40 -0
- data/lib/active_admin/locales/no-NB.yml +40 -0
- data/lib/active_admin/locales/pl.yml +7 -1
- data/lib/active_admin/locales/pt-BR.yml +6 -2
- data/lib/active_admin/namespace.rb +48 -33
- data/lib/active_admin/page.rb +54 -0
- data/lib/active_admin/page_controller.rb +15 -0
- data/lib/active_admin/page_dsl.rb +21 -0
- data/lib/active_admin/page_presenter.rb +30 -0
- data/lib/active_admin/resource.rb +38 -44
- data/lib/active_admin/resource/action_items.rb +5 -0
- data/lib/active_admin/resource/belongs_to.rb +4 -2
- data/lib/active_admin/resource/controllers.rb +35 -0
- data/lib/active_admin/resource/menu.rb +1 -2
- data/lib/active_admin/resource/naming.rb +43 -31
- data/lib/active_admin/resource/page_presenters.rb +28 -0
- data/lib/active_admin/resource/scopes.rb +16 -3
- data/lib/active_admin/resource/sidebars.rb +4 -0
- data/lib/active_admin/resource_collection.rb +88 -0
- data/lib/active_admin/resource_controller.rb +18 -54
- data/lib/active_admin/resource_controller/action_builder.rb +1 -1
- data/lib/active_admin/resource_controller/actions.rb +1 -1
- data/lib/active_admin/resource_controller/callbacks.rb +1 -1
- data/lib/active_admin/resource_controller/collection.rb +8 -4
- data/lib/active_admin/resource_controller/filters.rb +1 -1
- data/lib/active_admin/resource_controller/resource_class_methods.rb +24 -0
- data/lib/active_admin/resource_controller/scoping.rb +1 -1
- data/lib/active_admin/resource_controller/sidebars.rb +1 -1
- data/lib/active_admin/resource_dsl.rb +157 -0
- data/lib/active_admin/router.rb +21 -14
- data/lib/active_admin/scope.rb +15 -3
- data/lib/active_admin/version.rb +1 -1
- data/lib/active_admin/view_factory.rb +4 -3
- data/lib/active_admin/view_helpers/auto_link_helper.rb +1 -10
- data/lib/active_admin/view_helpers/breadcrumb_helper.rb +25 -21
- data/lib/active_admin/view_helpers/filter_form_helper.rb +0 -150
- data/lib/active_admin/views/components/attributes_table.rb +1 -1
- data/lib/active_admin/views/components/paginated_collection.rb +42 -13
- data/lib/active_admin/views/components/scopes.rb +17 -17
- data/lib/active_admin/views/components/status_tag.rb +6 -5
- data/lib/active_admin/views/components/table_for.rb +6 -2
- data/lib/active_admin/views/header_renderer.rb +31 -12
- data/lib/active_admin/views/index_as_block.rb +2 -2
- data/lib/active_admin/views/index_as_blog.rb +3 -3
- data/lib/active_admin/views/index_as_grid.rb +4 -4
- data/lib/active_admin/views/index_as_table.rb +13 -6
- data/lib/active_admin/views/pages/base.rb +4 -4
- data/lib/active_admin/views/pages/form.rb +49 -0
- data/lib/active_admin/views/pages/index.rb +18 -6
- data/lib/active_admin/views/pages/page.rb +24 -0
- data/lib/active_admin/views/pages/show.rb +1 -1
- data/lib/generators/active_admin/assets/assets_generator.rb +19 -1
- data/lib/generators/active_admin/install/templates/active_admin.rb.erb +38 -12
- data/lib/generators/active_admin/install/templates/dashboards.rb +6 -0
- data/spec/spec_helper.rb +4 -0
- data/spec/support/rails_template.rb +11 -0
- data/spec/support/templates/cucumber_with_reloading.rb +5 -0
- data/spec/unit/active_admin_spec.rb +8 -0
- data/spec/unit/application_spec.rb +48 -2
- data/spec/unit/arbre/html/element_finder_methods_spec.rb +58 -2
- data/spec/unit/asset_registration_spec.rb +9 -3
- data/spec/unit/auto_link_spec.rb +2 -2
- data/spec/unit/base_controller_shared_examples.rb +28 -0
- data/spec/unit/base_controller_spec.rb +8 -0
- data/spec/unit/belongs_to_spec.rb +30 -33
- data/spec/unit/comments_spec.rb +45 -15
- data/spec/unit/config_shared_examples.rb +108 -0
- data/spec/unit/dashboard_controller_spec.rb +44 -0
- data/spec/unit/event_spec.rb +6 -0
- data/spec/unit/filter_form_builder_spec.rb +9 -0
- data/spec/unit/form_builder_spec.rb +8 -14
- data/spec/unit/namespace/register_page_spec.rb +102 -0
- data/spec/unit/namespace/register_resource_spec.rb +188 -0
- data/spec/unit/namespace_spec.rb +11 -183
- data/spec/unit/page_controller_spec.rb +8 -0
- data/spec/unit/page_spec.rb +60 -0
- data/spec/unit/resource/menu_spec.rb +1 -51
- data/spec/unit/resource/naming_spec.rb +24 -19
- data/spec/unit/resource/page_presenters_spec.rb +32 -0
- data/spec/unit/resource/scopes_spec.rb +13 -0
- data/spec/unit/resource_collection_spec.rb +101 -0
- data/spec/unit/resource_controller_spec.rb +40 -32
- data/spec/unit/{registration_spec.rb → resource_registration_spec.rb} +0 -0
- data/spec/unit/resource_spec.rb +8 -24
- data/spec/unit/routing_spec.rb +50 -1
- data/spec/unit/scope_spec.rb +18 -4
- data/spec/unit/views/components/paginated_collection_spec.rb +150 -0
- data/spec/unit/views/components/status_tag_spec.rb +9 -0
- data/tasks/test.rake +43 -27
- metadata +140 -31
- data/app/assets/javascripts/active_admin/vendor.js +0 -382
- data/lib/active_admin/comments/configuration.rb +0 -18
- data/lib/active_admin/page_config.rb +0 -15
- data/lib/active_admin/resource_controller/form.rb +0 -42
- data/lib/active_admin/resource_controller/page_configurations.rb +0 -53
- data/lib/active_admin/views/pages/edit.rb +0 -28
- data/lib/active_admin/views/pages/new.rb +0 -28
- data/lib/generators/active_admin/assets/templates/3.0/active_admin.js +0 -427
- data/spec/integration/belongs_to_spec.rb +0 -42
@@ -6,30 +6,36 @@ module ActiveAdmin
|
|
6
6
|
class Scopes < ActiveAdmin::Component
|
7
7
|
builder_method :scopes_renderer
|
8
8
|
|
9
|
+
def default_class_name
|
10
|
+
"scopes table_tools_segmented_control"
|
11
|
+
end
|
12
|
+
|
13
|
+
def tag_name
|
14
|
+
'ul'
|
15
|
+
end
|
16
|
+
|
9
17
|
def build(scopes)
|
10
18
|
scopes.each do |scope|
|
11
|
-
build_scope(scope)
|
19
|
+
build_scope(scope) if call_method_or_proc_on(self, scope.display_if_block)
|
12
20
|
end
|
13
21
|
end
|
14
22
|
|
15
23
|
protected
|
16
24
|
|
17
25
|
def build_scope(scope)
|
18
|
-
|
26
|
+
li :class => classes_for_scope(scope) do
|
19
27
|
begin
|
20
|
-
scope_name = I18n.t!("active_admin.scopes.#{scope.
|
28
|
+
scope_name = I18n.t!("active_admin.scopes.#{scope.id}")
|
21
29
|
rescue I18n::MissingTranslationData
|
22
30
|
scope_name = scope.name
|
23
31
|
end
|
24
32
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
33
|
+
a :href => url_for(params.merge(:scope => scope.id, :page => 1)), :class => "table_tools_button" do
|
34
|
+
text_node scope_name
|
35
|
+
span :class => 'count' do
|
36
|
+
"(" + get_scope_count(scope).to_s + ")"
|
37
|
+
end
|
29
38
|
end
|
30
|
-
text_node(" ")
|
31
|
-
scope_count(scope)
|
32
|
-
text_node(" ")
|
33
39
|
end
|
34
40
|
end
|
35
41
|
|
@@ -47,12 +53,6 @@ module ActiveAdmin
|
|
47
53
|
end
|
48
54
|
end
|
49
55
|
|
50
|
-
def scope_count(scope)
|
51
|
-
span :class => 'count' do
|
52
|
-
"(" + get_scope_count(scope).to_s + ")"
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
56
|
include ActiveAdmin::ScopeChain
|
57
57
|
|
58
58
|
# Return the count for the scope passed in.
|
@@ -61,7 +61,7 @@ module ActiveAdmin
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def scoping_class
|
64
|
-
assigns["before_scope_collection"] || active_admin_config.
|
64
|
+
assigns["before_scope_collection"] || active_admin_config.resource_class
|
65
65
|
end
|
66
66
|
|
67
67
|
end
|
@@ -16,7 +16,7 @@ module ActiveAdmin
|
|
16
16
|
#
|
17
17
|
# @param [String] status the status to display. One of the span classes will be an underscored version of the status.
|
18
18
|
# @param [Symbol] type type of status. Will become a class of the span. ActiveAdmin provide style for :ok, :warning and :error.
|
19
|
-
# @param [Hash] options such as :class, :id
|
19
|
+
# @param [Hash] options such as :class, :id and :label to override the default label
|
20
20
|
#
|
21
21
|
# @return [ActiveAdmin::Views::StatusTag]
|
22
22
|
#
|
@@ -27,18 +27,19 @@ module ActiveAdmin
|
|
27
27
|
# status_tag('active', :ok)
|
28
28
|
# # => <span class='status active ok'>Active</span>
|
29
29
|
#
|
30
|
-
# status_tag('active', :ok, :class => 'important', :id => 'status_123')
|
31
|
-
# # => <span class='status active ok important' id='status_123'>
|
30
|
+
# status_tag('active', :ok, :class => 'important', :id => 'status_123', :label => 'on')
|
31
|
+
# # => <span class='status active ok important' id='status_123'>on</span>
|
32
32
|
#
|
33
33
|
def build(*args)
|
34
34
|
options = args.extract_options!
|
35
35
|
status = args[0]
|
36
36
|
type = args[1]
|
37
|
+
label = options.delete(:label)
|
37
38
|
classes = options.delete(:class)
|
38
39
|
|
39
|
-
|
40
|
+
content = label || status.titleize if status
|
40
41
|
|
41
|
-
super(
|
42
|
+
super(content, options)
|
42
43
|
|
43
44
|
add_class(status_to_class(status)) if status
|
44
45
|
add_class(type.to_s) if type
|
@@ -63,7 +63,7 @@ module ActiveAdmin
|
|
63
63
|
if sortable? && col.sortable?
|
64
64
|
build_sortable_header_for(col.title, col.sort_key)
|
65
65
|
else
|
66
|
-
th(col.title)
|
66
|
+
th(col.title, :class => (col.data.to_s.downcase.underscore if col.data.is_a?(Symbol)))
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
@@ -72,6 +72,10 @@ module ActiveAdmin
|
|
72
72
|
if current_sort[0] == sort_key
|
73
73
|
classes << "sorted-#{current_sort[1]}"
|
74
74
|
end
|
75
|
+
|
76
|
+
header_class = title.downcase.underscore
|
77
|
+
|
78
|
+
classes << header_class
|
75
79
|
|
76
80
|
th :class => classes do
|
77
81
|
link_to(title, params.merge(:order => "#{sort_key}_#{order_for_sort_key(sort_key)}").except(:page))
|
@@ -86,7 +90,7 @@ module ActiveAdmin
|
|
86
90
|
end
|
87
91
|
|
88
92
|
def build_table_cell(col, item)
|
89
|
-
td do
|
93
|
+
td(:class => (col.data.to_s.downcase if col.data.is_a?(Symbol))) do
|
90
94
|
rvalue = call_method_or_proc_on(item, col.data, :exec => false)
|
91
95
|
if col.data.is_a?(Symbol)
|
92
96
|
rvalue = pretty_format(rvalue)
|
@@ -11,11 +11,30 @@ module ActiveAdmin
|
|
11
11
|
|
12
12
|
protected
|
13
13
|
|
14
|
+
# Renders the title/branding area for the site
|
14
15
|
def title
|
15
|
-
if
|
16
|
-
|
16
|
+
if active_admin_namespace.site_title_image.blank?
|
17
|
+
title_text
|
17
18
|
else
|
18
|
-
|
19
|
+
title_image
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# Renders an image for the site's header/branding area
|
24
|
+
def title_image
|
25
|
+
if !active_admin_namespace.site_title_link.blank?
|
26
|
+
content_tag 'h1', link_to( image_tag(active_admin_namespace.site_title_image, :id => "site_title_image", :alt => active_admin_namespace.site_title), active_admin_namespace.site_title_link ), :id => "site_title"
|
27
|
+
else
|
28
|
+
content_tag 'h1', image_tag( active_admin_namespace.site_title_image, :id => "site_title_image", :alt => active_admin_namespace.site_title ), :id => "site_title"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# Renders a the site's header/branding area as a string
|
33
|
+
def title_text
|
34
|
+
if !active_admin_namespace.site_title_link || active_admin_namespace.site_title_link == ""
|
35
|
+
content_tag 'h1', active_admin_namespace.site_title, :id => 'site_title'
|
36
|
+
else
|
37
|
+
content_tag 'h1', link_to(active_admin_namespace.site_title, active_admin_namespace.site_title_link), :id => 'site_title'
|
19
38
|
end
|
20
39
|
end
|
21
40
|
|
@@ -24,32 +43,32 @@ module ActiveAdmin
|
|
24
43
|
#
|
25
44
|
# It uses the ActiveAdmin.tabs_renderer option
|
26
45
|
def global_navigation
|
27
|
-
render view_factory.global_navigation, current_menu
|
46
|
+
render view_factory.global_navigation, current_menu, :class => 'header-item'
|
28
47
|
end
|
29
48
|
|
30
49
|
def utility_navigation
|
31
|
-
content_tag 'p', :id => "utility_nav" do
|
50
|
+
content_tag 'p', :id => "utility_nav", :class => 'header-item' do
|
32
51
|
if current_active_admin_user?
|
33
52
|
html = content_tag(:span, display_name(current_active_admin_user), :class => "current_user")
|
34
53
|
|
35
|
-
if
|
36
|
-
html << link_to(I18n.t('active_admin.logout'),
|
54
|
+
if active_admin_namespace.logout_link_path
|
55
|
+
html << link_to(I18n.t('active_admin.logout'), active_admin_logout_path, :method => logout_method)
|
37
56
|
end
|
38
57
|
end
|
39
58
|
end
|
40
59
|
end
|
41
60
|
|
42
61
|
# Returns the logout path from the application settings
|
43
|
-
def
|
44
|
-
if
|
45
|
-
send(
|
62
|
+
def active_admin_logout_path
|
63
|
+
if active_admin_namespace.logout_link_path.is_a?(Symbol)
|
64
|
+
send(active_admin_namespace.logout_link_path)
|
46
65
|
else
|
47
|
-
|
66
|
+
active_admin_namespace.logout_link_path
|
48
67
|
end
|
49
68
|
end
|
50
69
|
|
51
70
|
def logout_method
|
52
|
-
|
71
|
+
active_admin_namespace.logout_link_method || :get
|
53
72
|
end
|
54
73
|
end
|
55
74
|
|
@@ -18,9 +18,9 @@ module ActiveAdmin
|
|
18
18
|
#
|
19
19
|
class IndexAsBlock < ActiveAdmin::Component
|
20
20
|
|
21
|
-
def build(
|
21
|
+
def build(page_presenter, collection)
|
22
22
|
collection.each do |obj|
|
23
|
-
instance_exec(obj, &
|
23
|
+
instance_exec(obj, &page_presenter.block)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -63,13 +63,13 @@ module ActiveAdmin
|
|
63
63
|
#
|
64
64
|
class IndexAsBlog < ActiveAdmin::Component
|
65
65
|
|
66
|
-
def build(
|
67
|
-
@
|
66
|
+
def build(page_presenter, collection)
|
67
|
+
@page_presenter = page_presenter
|
68
68
|
@collection = collection
|
69
69
|
|
70
70
|
# Call the block passed in. This will set the
|
71
71
|
# title and body methods
|
72
|
-
instance_eval &
|
72
|
+
instance_eval &page_presenter.block if page_presenter.block
|
73
73
|
|
74
74
|
build_posts
|
75
75
|
end
|
@@ -23,14 +23,14 @@ module ActiveAdmin
|
|
23
23
|
#
|
24
24
|
class IndexAsGrid < ActiveAdmin::Component
|
25
25
|
|
26
|
-
def build(
|
27
|
-
@
|
26
|
+
def build(page_presenter, collection)
|
27
|
+
@page_presenter = page_presenter
|
28
28
|
@collection = collection
|
29
29
|
build_table
|
30
30
|
end
|
31
31
|
|
32
32
|
def number_of_columns
|
33
|
-
@
|
33
|
+
@page_presenter[:columns] || default_number_of_columns
|
34
34
|
end
|
35
35
|
|
36
36
|
protected
|
@@ -53,7 +53,7 @@ module ActiveAdmin
|
|
53
53
|
|
54
54
|
def build_item(item)
|
55
55
|
td :for => item do
|
56
|
-
instance_exec(item, &@
|
56
|
+
instance_exec(item, &@page_presenter.block)
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
@@ -92,16 +92,16 @@ module ActiveAdmin
|
|
92
92
|
#
|
93
93
|
class IndexAsTable < ActiveAdmin::Component
|
94
94
|
|
95
|
-
def build(
|
95
|
+
def build(page_presenter, collection)
|
96
96
|
table_options = {
|
97
97
|
:id => active_admin_config.plural_underscored_resource_name,
|
98
98
|
:sortable => true,
|
99
99
|
:class => "index_table",
|
100
|
-
:i18n => active_admin_config.
|
100
|
+
:i18n => active_admin_config.resource_class
|
101
101
|
}
|
102
102
|
|
103
103
|
table_for collection, table_options do |t|
|
104
|
-
instance_exec(t, &
|
104
|
+
instance_exec(t, &page_presenter.block)
|
105
105
|
end
|
106
106
|
end
|
107
107
|
|
@@ -126,9 +126,16 @@ module ActiveAdmin
|
|
126
126
|
:name => ""
|
127
127
|
}.merge(options)
|
128
128
|
column options[:name] do |resource|
|
129
|
-
links =
|
130
|
-
|
131
|
-
|
129
|
+
links = ''.html_safe
|
130
|
+
if controller.action_methods.include?('show')
|
131
|
+
links += link_to I18n.t('active_admin.view'), resource_path(resource), :class => "member_link view_link"
|
132
|
+
end
|
133
|
+
if controller.action_methods.include?('edit')
|
134
|
+
links += link_to I18n.t('active_admin.edit'), edit_resource_path(resource), :class => "member_link edit_link"
|
135
|
+
end
|
136
|
+
if controller.action_methods.include?('destroy')
|
137
|
+
links += link_to I18n.t('active_admin.delete'), resource_path(resource), :method => :delete, :confirm => I18n.t('active_admin.delete_confirmation'), :class => "member_link delete_link"
|
138
|
+
end
|
132
139
|
links
|
133
140
|
end
|
134
141
|
end
|
@@ -23,8 +23,8 @@ module ActiveAdmin
|
|
23
23
|
within @head do
|
24
24
|
meta :"http-equiv" => "Content-type", :content => "text/html; charset=utf-8"
|
25
25
|
insert_tag Arbre::HTML::Title, [title, active_admin_application.site_title].join(" | ")
|
26
|
-
active_admin_application.stylesheets.each do |
|
27
|
-
|
26
|
+
active_admin_application.stylesheets.each do |style|
|
27
|
+
text_node(stylesheet_link_tag(style.path, style.options).html_safe)
|
28
28
|
end
|
29
29
|
active_admin_application.javascripts.each do |path|
|
30
30
|
script :src => javascript_path(path), :type => "text/javascript"
|
@@ -86,7 +86,7 @@ module ActiveAdmin
|
|
86
86
|
end
|
87
87
|
|
88
88
|
def build_action_items
|
89
|
-
if active_admin_config
|
89
|
+
if active_admin_config && active_admin_config.action_items?
|
90
90
|
items = active_admin_config.action_items_for(params[:action])
|
91
91
|
insert_tag view_factory.action_items, items
|
92
92
|
end
|
@@ -134,7 +134,7 @@ module ActiveAdmin
|
|
134
134
|
|
135
135
|
# Returns the sidebar sections to render for the current action
|
136
136
|
def sidebar_sections_for_action
|
137
|
-
if active_admin_config
|
137
|
+
if active_admin_config && active_admin_config.sidebar_sections?
|
138
138
|
active_admin_config.sidebar_sections_for(params[:action])
|
139
139
|
else
|
140
140
|
[]
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module ActiveAdmin
|
2
|
+
module Views
|
3
|
+
module Pages
|
4
|
+
|
5
|
+
class Form < Base
|
6
|
+
|
7
|
+
def title
|
8
|
+
I18n.t("active_admin.#{params[:action]}_model",
|
9
|
+
:model => active_admin_config.resource_name)
|
10
|
+
end
|
11
|
+
|
12
|
+
def form_presenter
|
13
|
+
active_admin_config.get_page_presenter(:form) || default_form_config
|
14
|
+
end
|
15
|
+
|
16
|
+
def main_content
|
17
|
+
form_options = default_form_options.merge(form_presenter.options)
|
18
|
+
|
19
|
+
if form_options[:partial]
|
20
|
+
render(form_options[:partial])
|
21
|
+
else
|
22
|
+
active_admin_form_for(resource, form_options, &form_presenter.block)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def default_form_options
|
29
|
+
{
|
30
|
+
:url => default_form_path,
|
31
|
+
:as => active_admin_config.underscored_resource_name
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
def default_form_path
|
36
|
+
resource.persisted? ? resource_path(resource) : collection_path
|
37
|
+
end
|
38
|
+
|
39
|
+
def default_form_config
|
40
|
+
ActiveAdmin::PagePresenter.new do |f|
|
41
|
+
f.inputs
|
42
|
+
f.buttons
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -9,7 +9,7 @@ module ActiveAdmin
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def config
|
12
|
-
|
12
|
+
active_admin_config.get_page_presenter(:index) || default_index_config
|
13
13
|
end
|
14
14
|
|
15
15
|
# Render's the index configuration that was set in the
|
@@ -29,17 +29,28 @@ module ActiveAdmin
|
|
29
29
|
end
|
30
30
|
|
31
31
|
protected
|
32
|
+
|
33
|
+
|
34
|
+
# TODO: Refactor to new HTML DSL
|
35
|
+
def build_download_format_links(formats = [:csv, :xml, :json])
|
36
|
+
links = formats.collect do |format|
|
37
|
+
link_to format.to_s.upcase, { :format => format}.merge(request.query_parameters.except(:commit, :format))
|
38
|
+
end
|
39
|
+
text_node [I18n.t('active_admin.download'), links].flatten.join(" ").html_safe
|
40
|
+
end
|
32
41
|
|
33
42
|
def build_scopes
|
34
43
|
if active_admin_config.scopes.any?
|
35
|
-
|
44
|
+
div :class => "table_tools" do
|
45
|
+
scopes_renderer active_admin_config.scopes
|
46
|
+
end
|
36
47
|
end
|
37
48
|
end
|
38
49
|
|
39
50
|
# Creates a default configuration for the resource class. This is a table
|
40
51
|
# with each column displayed as well as all the default actions
|
41
52
|
def default_index_config
|
42
|
-
@default_index_config ||= ::ActiveAdmin::
|
53
|
+
@default_index_config ||= ::ActiveAdmin::PagePresenter.new(:as => :table) do |display|
|
43
54
|
id_column
|
44
55
|
resource_class.content_columns.each do |col|
|
45
56
|
column col.name.to_sym
|
@@ -49,7 +60,7 @@ module ActiveAdmin
|
|
49
60
|
end
|
50
61
|
|
51
62
|
# Returns the actual class for renderering the main content on the index
|
52
|
-
# page. To set this, use the :as option in the
|
63
|
+
# page. To set this, use the :as option in the page_presenter block.
|
53
64
|
def find_index_renderer_class(symbol_or_class)
|
54
65
|
case symbol_or_class
|
55
66
|
when Symbol
|
@@ -62,7 +73,7 @@ module ActiveAdmin
|
|
62
73
|
end
|
63
74
|
|
64
75
|
def render_blank_slate
|
65
|
-
blank_slate_content = I18n.t("active_admin.blank_slate.content", :resource_name => active_admin_config.
|
76
|
+
blank_slate_content = I18n.t("active_admin.blank_slate.content", :resource_name => active_admin_config.plural_resource_name)
|
66
77
|
if controller.action_methods.include?('new')
|
67
78
|
blank_slate_content += " " + link_to(I18n.t("active_admin.blank_slate.link"), new_resource_path)
|
68
79
|
end
|
@@ -77,7 +88,8 @@ module ActiveAdmin
|
|
77
88
|
def render_index
|
78
89
|
renderer_class = find_index_renderer_class(config[:as])
|
79
90
|
|
80
|
-
paginated_collection(collection, :entry_name
|
91
|
+
paginated_collection(collection, :entry_name => active_admin_config.resource_name,
|
92
|
+
:entries_name => active_admin_config.plural_resource_name) do
|
81
93
|
div :class => 'index_content' do
|
82
94
|
insert_tag(renderer_class, config, collection)
|
83
95
|
end
|