activeadmin 0.3.4 → 0.4.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/.gitignore +1 -0
- data/.travis.yml +3 -0
- data/CHANGELOG.md +164 -5
- data/CONTRIBUTING.md +113 -0
- data/Gemfile +7 -9
- data/LICENSE +1 -1
- data/README.rdoc +19 -20
- data/activeadmin.gemspec +4 -2
- 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 +17 -341
- 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/components/_tables.css.scss +43 -2
- 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/_utilities.scss +9 -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 +43 -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 +59 -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 +11 -3
- data/features/step_definitions/asset_steps.rb +5 -1
- data/features/step_definitions/breadcrumb_steps.rb +5 -0
- data/features/step_definitions/comment_steps.rb +3 -3
- data/features/step_definitions/configuration_steps.rb +69 -13
- data/features/step_definitions/dashboard_steps.rb +7 -3
- data/features/step_definitions/factory_steps.rb +9 -2
- data/features/step_definitions/flash_steps.rb +9 -1
- data/features/step_definitions/format_steps.rb +9 -1
- data/features/step_definitions/index_scope_steps.rb +18 -6
- data/features/step_definitions/member_link_steps.rb +7 -0
- data/features/step_definitions/pagination_steps.rb +2 -2
- data/features/step_definitions/site_title_steps.rb +15 -0
- data/features/step_definitions/tab_steps.rb +1 -1
- data/features/step_definitions/user_steps.rb +1 -1
- data/features/step_definitions/web_steps.rb +4 -4
- data/features/support/paths.rb +6 -0
- data/features/users/logging_out.feature +11 -0
- data/lib/active_admin.rb +26 -10
- data/lib/active_admin/application.rb +64 -22
- data/lib/active_admin/arbre.rb +0 -1
- data/lib/active_admin/arbre/builder.rb +8 -5
- data/lib/active_admin/arbre/context.rb +1 -1
- data/lib/active_admin/arbre/html/attributes.rb +1 -1
- data/lib/active_admin/arbre/html/class_list.rb +0 -4
- data/lib/active_admin/arbre/html/collection.rb +2 -2
- data/lib/active_admin/arbre/html/document.rb +1 -1
- data/lib/active_admin/arbre/html/element.rb +19 -9
- data/lib/active_admin/arbre/html/tag.rb +3 -3
- data/lib/active_admin/arbre/html/text_node.rb +2 -2
- 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/callbacks.rb +16 -18
- 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 +21 -5
- 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/helpers/settings.rb +6 -10
- 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 +44 -0
- data/lib/active_admin/locales/en.yml +5 -0
- data/lib/active_admin/locales/hr.yml +40 -0
- data/lib/active_admin/locales/hu.yml +45 -0
- data/lib/active_admin/locales/it.yml +11 -6
- 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/menu_item.rb +25 -17
- data/lib/active_admin/namespace.rb +48 -33
- data/lib/active_admin/page.rb +65 -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/reloader.rb +109 -42
- 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 +53 -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 +8 -8
- 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/columns.rb +4 -4
- data/lib/active_admin/views/components/paginated_collection.rb +42 -13
- data/lib/active_admin/views/components/panel.rb +8 -0
- data/lib/active_admin/views/components/scopes.rb +24 -18
- 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/script/use_rails +14 -7
- data/spec/spec_helper.rb +9 -14
- data/spec/spec_helper_without_rails.rb +10 -0
- data/spec/support/detect_rails_version.rb +22 -3
- data/spec/support/integration_example_group.rb +5 -7
- data/spec/support/rails_template.rb +11 -0
- data/spec/support/rails_template_with_data.rb +25 -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/context_spec.rb +1 -1
- data/spec/unit/arbre/html/element_finder_methods_spec.rb +58 -2
- data/spec/unit/arbre/html/element_spec.rb +18 -5
- data/spec/unit/arbre/html/tag_attributes_spec.rb +3 -3
- data/spec/unit/arbre/html/tag_spec.rb +1 -1
- data/spec/unit/arbre/html_spec.rb +32 -22
- 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 +119 -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/menu_item_spec.rb +25 -20
- 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/reloader_spec.rb +82 -38
- data/spec/unit/resource/menu_spec.rb +1 -51
- data/spec/unit/resource/naming_spec.rb +25 -20
- 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 +163 -0
- data/spec/unit/views/components/panel_spec.rb +9 -0
- data/spec/unit/views/components/status_tag_spec.rb +9 -0
- data/spec/unit/views/tabbed_navigation_spec.rb +2 -1
- data/tasks/test.rake +44 -26
- metadata +176 -69
- data/app/assets/javascripts/active_admin/vendor.js +0 -382
- data/lib/active_admin/arbre/core_extensions.rb +0 -5
- 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
@@ -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
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module ActiveAdmin
|
2
|
+
module Views
|
3
|
+
module Pages
|
4
|
+
class Page < Base
|
5
|
+
|
6
|
+
def main_content
|
7
|
+
page_presenter = active_admin_config.get_page_presenter(:index)
|
8
|
+
|
9
|
+
if page_presenter && page_presenter.block
|
10
|
+
instance_exec &page_presenter.block
|
11
|
+
else
|
12
|
+
nil
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
protected
|
17
|
+
|
18
|
+
def title
|
19
|
+
active_admin_config.name
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -2,20 +2,38 @@ module ActiveAdmin
|
|
2
2
|
module Generators
|
3
3
|
class AssetsGenerator < Rails::Generators::Base
|
4
4
|
|
5
|
+
class_option :bourbon, :type => :boolean, :default => true,
|
6
|
+
:desc => "Generate Bourbon scss files if using Rails 3.0.x"
|
7
|
+
|
8
|
+
class_option :jquery, :type => :boolean, :default => true,
|
9
|
+
:desc => "Generate jQuery js files if using Rails 3.0.x"
|
10
|
+
|
5
11
|
def self.source_root
|
6
12
|
@_active_admin_source_root ||= File.expand_path("../templates", __FILE__)
|
7
13
|
end
|
8
14
|
|
9
15
|
def install_assets
|
16
|
+
require 'rails'
|
17
|
+
require 'active_admin'
|
18
|
+
|
10
19
|
if ActiveAdmin.use_asset_pipeline?
|
11
20
|
template '3.1/active_admin.js', 'app/assets/javascripts/active_admin.js'
|
12
21
|
template '3.1/active_admin.css.scss', 'app/assets/stylesheets/active_admin.css.scss'
|
13
22
|
else
|
14
|
-
template '
|
23
|
+
template '../../../../../app/assets/javascripts/active_admin/application.js', 'public/javascripts/active_admin.js'
|
15
24
|
directory '../../../../../app/assets/images/active_admin', 'public/images/active_admin'
|
25
|
+
generate "jquery:install --ui" if options.jquery?
|
26
|
+
install_bourbon if options.bourbon?
|
16
27
|
end
|
17
28
|
end
|
18
29
|
|
30
|
+
private
|
31
|
+
|
32
|
+
def install_bourbon
|
33
|
+
rake "bourbon:install"
|
34
|
+
create_file "public/stylesheets/sass/_bourbon.scss", '@import "bourbon/bourbon"'
|
35
|
+
end
|
36
|
+
|
19
37
|
end
|
20
38
|
end
|
21
39
|
end
|
@@ -7,17 +7,24 @@ ActiveAdmin.setup do |config|
|
|
7
7
|
#
|
8
8
|
config.site_title = "<%= Rails.application.class.name.split("::").first.titlecase %>"
|
9
9
|
|
10
|
-
# Set the link url for the title. For example, to take
|
10
|
+
# Set the link url for the title. For example, to take
|
11
11
|
# users to your main site. Defaults to no link.
|
12
12
|
#
|
13
13
|
# config.site_title_link = "/"
|
14
14
|
|
15
|
+
# Set an optional image to be displayed for the header
|
16
|
+
# instead of a string (overrides :site_title)
|
17
|
+
#
|
18
|
+
# Note: Recommended image height is 21px to properly fit in the header
|
19
|
+
#
|
20
|
+
# config.site_title_image = "/images/logo.png"
|
21
|
+
|
15
22
|
# == Default Namespace
|
16
23
|
#
|
17
24
|
# Set the default namespace each administration resource
|
18
|
-
# will be added to.
|
25
|
+
# will be added to.
|
19
26
|
#
|
20
|
-
# eg:
|
27
|
+
# eg:
|
21
28
|
# config.default_namespace = :hello_world
|
22
29
|
#
|
23
30
|
# This will create resources in the HelloWorld module and
|
@@ -28,11 +35,22 @@ ActiveAdmin.setup do |config|
|
|
28
35
|
#
|
29
36
|
# Default:
|
30
37
|
# config.default_namespace = :admin
|
38
|
+
#
|
39
|
+
# You can customize the settings for each namespace by using
|
40
|
+
# a namespace block. For example, to change the site title
|
41
|
+
# within a namespace:
|
42
|
+
#
|
43
|
+
# config.namespace :admin do |admin|
|
44
|
+
# admin.site_title = "Custom Admin Title"
|
45
|
+
# end
|
46
|
+
#
|
47
|
+
# This will ONLY change the title for the admin section. Other
|
48
|
+
# namespaces will continue to use the main "site_title" configuration.
|
31
49
|
|
32
50
|
# == User Authentication
|
33
51
|
#
|
34
|
-
# Active Admin will automatically call an authentication
|
35
|
-
# method in a before filter of all controller actions to
|
52
|
+
# Active Admin will automatically call an authentication
|
53
|
+
# method in a before filter of all controller actions to
|
36
54
|
# ensure that there is a currently logged in admin user.
|
37
55
|
#
|
38
56
|
# This setting changes the method which Active Admin calls
|
@@ -71,20 +89,25 @@ ActiveAdmin.setup do |config|
|
|
71
89
|
|
72
90
|
# == Admin Comments
|
73
91
|
#
|
74
|
-
# Admin comments allow you to add comments to any model for admin use
|
75
|
-
#
|
76
|
-
# Admin comments are enabled by default in the default
|
77
|
-
# namespace only. You can turn them on in a namesapce
|
78
|
-
# by adding them to the comments array.
|
92
|
+
# Admin comments allow you to add comments to any model for admin use.
|
93
|
+
# Admin comments are enabled by default.
|
79
94
|
#
|
80
95
|
# Default:
|
81
|
-
# config.
|
96
|
+
# config.allow_comments = true
|
97
|
+
#
|
98
|
+
# You can turn them on and off for any given namespace by using a
|
99
|
+
# namespace config block.
|
100
|
+
#
|
101
|
+
# Eg:
|
102
|
+
# config.namespace :without_comments do |without_comments|
|
103
|
+
# without_comments.allow_comments = false
|
104
|
+
# end
|
82
105
|
|
83
106
|
|
84
107
|
# == Controller Filters
|
85
108
|
#
|
86
109
|
# You can add before, after and around filters to all of your
|
87
|
-
# Active Admin resources from here.
|
110
|
+
# Active Admin resources from here.
|
88
111
|
#
|
89
112
|
# config.before_filter :do_something_awesome
|
90
113
|
|
@@ -98,6 +121,9 @@ ActiveAdmin.setup do |config|
|
|
98
121
|
# To load a stylesheet:
|
99
122
|
# config.register_stylesheet 'my_stylesheet.css'
|
100
123
|
#
|
124
|
+
# You can provide an options hash for more control, which is passed along to stylesheet_link_tag():
|
125
|
+
# config.register_stylesheet 'my_print_stylesheet.css', :media => :print
|
126
|
+
#
|
101
127
|
# To load a javascript file:
|
102
128
|
# config.register_javascript 'my_javascript.js'
|
103
129
|
end
|