activeadmin 0.6.0 → 0.6.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/.gitignore +5 -1
- data/.travis.yml +1 -1
- data/.yardopts +2 -3
- data/CHANGELOG.md +180 -36
- data/CONTRIBUTING.md +12 -2
- data/Gemfile +9 -3
- data/README.rdoc +38 -65
- data/Rakefile +1 -3
- data/activeadmin.gemspec +10 -11
- data/app/assets/images/active_admin/index_list_icons/block_icon.svg +1 -1
- data/app/assets/images/active_admin/index_list_icons/blog_icon.svg +1 -1
- data/app/assets/images/active_admin/index_list_icons/grid_icon.svg +1 -1
- data/app/assets/images/active_admin/index_list_icons/table_icon.svg +1 -1
- data/app/assets/javascripts/active_admin/components/jquery.aa.checkbox-toggler.js.coffee +2 -2
- data/app/assets/javascripts/active_admin/components/jquery.aa.dropdown-menu.js.coffee +2 -2
- data/app/assets/javascripts/active_admin/components/jquery.aa.popover.js.coffee +2 -2
- data/app/assets/javascripts/active_admin/components/jquery.aa.table-checkbox-toggler.js.coffee +2 -2
- data/app/assets/javascripts/active_admin/lib/namespace.js.coffee +2 -1
- data/app/assets/javascripts/active_admin/pages/application.js.coffee +6 -1
- data/app/assets/stylesheets/active_admin/_base.css.scss +29 -34
- data/app/assets/stylesheets/active_admin/_forms.css.scss +65 -62
- data/app/assets/stylesheets/active_admin/_header.css.scss +57 -45
- data/app/assets/stylesheets/active_admin/_typography.css.scss +9 -9
- data/app/assets/stylesheets/active_admin/components/_batch_actions.css.scss +1 -1
- data/app/assets/stylesheets/active_admin/components/_blank_slates.scss +5 -5
- data/app/assets/stylesheets/active_admin/components/_breadcrumbs.scss +2 -2
- data/app/assets/stylesheets/active_admin/components/_comments.css.scss +1 -1
- data/app/assets/stylesheets/active_admin/components/_date_picker.css.scss +20 -20
- data/app/assets/stylesheets/active_admin/components/_dropdown_menu.scss +16 -16
- data/app/assets/stylesheets/active_admin/components/_flash_messages.css.scss +25 -23
- data/app/assets/stylesheets/active_admin/components/_grid.scss +2 -2
- data/app/assets/stylesheets/active_admin/components/_index_list.scss +1 -1
- data/app/assets/stylesheets/active_admin/components/_pagination.scss +10 -10
- data/app/assets/stylesheets/active_admin/components/_panels.scss +1 -1
- data/app/assets/stylesheets/active_admin/components/_popovers.css.scss +27 -27
- data/app/assets/stylesheets/active_admin/components/_scopes.scss +1 -1
- data/app/assets/stylesheets/active_admin/components/_table_tools.css.scss +10 -10
- data/app/assets/stylesheets/active_admin/components/_tables.css.scss +9 -9
- data/app/assets/stylesheets/active_admin/mixins/_buttons.css.scss +3 -3
- data/app/assets/stylesheets/active_admin/mixins/_gradients.css.scss +4 -4
- data/app/assets/stylesheets/active_admin/mixins/_icons.css.scss +4 -7
- data/app/assets/stylesheets/active_admin/mixins/_reset.css.scss +5 -5
- data/app/assets/stylesheets/active_admin/mixins/_rounded.css.scss +3 -3
- data/app/assets/stylesheets/active_admin/mixins/_sections.css.scss +6 -6
- data/app/assets/stylesheets/active_admin/mixins/_shadows.css.scss +8 -8
- data/app/assets/stylesheets/active_admin/mixins/_typography.scss +1 -1
- data/app/assets/stylesheets/active_admin/mixins/_utilities.scss +1 -1
- data/app/assets/stylesheets/active_admin/mixins/_variables.css.scss +9 -1
- data/app/assets/stylesheets/active_admin/pages/_logged_out.scss +1 -1
- data/app/assets/stylesheets/active_admin/print.css.scss +2 -8
- data/app/assets/stylesheets/active_admin/structure/_footer.scss +5 -5
- data/app/assets/stylesheets/active_admin/structure/_main_structure.scss +13 -13
- data/app/assets/stylesheets/active_admin/structure/_title_bar.scss +14 -14
- data/app/views/active_admin/devise/passwords/edit.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 +8 -1
- data/app/views/active_admin/resource/index.csv.erb +3 -3
- data/app/views/layouts/active_admin_logged_out.html.erb +5 -3
- data/config/locales/bg.yml +101 -0
- data/{lib/active_admin → config}/locales/ca.yml +24 -7
- data/{lib/active_admin → config}/locales/cs.yml +34 -12
- data/{lib/active_admin → config}/locales/da.yml +29 -7
- data/config/locales/de-CH.yml +117 -0
- data/{lib/active_admin → config}/locales/de.yml +19 -9
- data/config/locales/en-GB.yml +90 -0
- data/{lib/active_admin → config}/locales/en.yml +16 -6
- data/config/locales/es.yml +106 -0
- data/{lib/active_admin/locales/es.yml → config/locales/es_MX.yml} +14 -8
- data/{lib/active_admin → config}/locales/fr.yml +14 -6
- data/{lib/active_admin → config}/locales/he.yml +16 -6
- data/{lib/active_admin → config}/locales/hr.yml +14 -6
- data/{lib/active_admin → config}/locales/hu.yml +31 -6
- data/{lib/active_admin → config}/locales/it.yml +14 -6
- data/{lib/active_admin → config}/locales/ja.yml +32 -7
- data/{lib/active_admin → config}/locales/ko.yml +14 -6
- data/{lib/active_admin → config}/locales/lt.yml +15 -6
- data/{lib/active_admin → config}/locales/lv.yml +14 -6
- data/{lib/active_admin → config}/locales/nl.yml +14 -6
- data/{lib/active_admin → config}/locales/no-NB.yml +14 -6
- data/{lib/active_admin → config}/locales/pl.yml +14 -6
- data/{lib/active_admin → config}/locales/pt-BR.yml +14 -6
- data/{lib/active_admin → config}/locales/pt-PT.yml +14 -6
- data/{lib/active_admin → config}/locales/ro.yml +32 -7
- data/{lib/active_admin → config}/locales/ru.yml +30 -8
- data/{lib/active_admin → config}/locales/sv-SE.yml +14 -6
- data/{lib/active_admin → config}/locales/tr.yml +15 -6
- data/config/locales/uk.yml +100 -0
- data/{lib/active_admin → config}/locales/vi.yml +15 -6
- data/{lib/active_admin → config}/locales/zh-CN.yml +15 -6
- data/{lib/active_admin → config}/locales/zh-TW.yml +15 -6
- data/docs/0-installation.md +22 -18
- data/docs/1-general-configuration.md +1 -1
- data/docs/10-custom-pages.md +3 -3
- data/docs/11-decorators.md +18 -2
- data/docs/12-arbre-components.md +53 -54
- data/docs/13-authorization-adapter.md +31 -10
- data/docs/2-resource-customization.md +16 -1
- data/docs/3-index-pages.md +13 -1
- data/docs/3-index-pages/create-an-index.md +4 -4
- data/docs/3-index-pages/index-as-block.md +1 -1
- data/docs/3-index-pages/index-as-blog.md +1 -1
- data/docs/3-index-pages/index-as-grid.md +1 -1
- data/docs/4-csv-format.md +4 -4
- data/docs/5-forms.md +46 -3
- data/docs/{6-show-screens.md → 6-show-pages.md} +3 -3
- data/docs/8-custom-actions.md +3 -3
- data/docs/9-batch-actions.md +9 -1
- data/features/action_item.feature +6 -6
- data/features/authorization_cancan.feature +1 -1
- data/features/belongs_to.feature +3 -3
- data/features/breadcrumb.feature +2 -2
- data/features/comments/commenting.feature +7 -5
- data/features/dashboard.feature +0 -51
- data/features/favicon.feature +20 -0
- data/features/global_navigation.feature +0 -1
- data/features/index/batch_actions.feature +12 -11
- data/features/index/filters.feature +6 -6
- data/features/index/format_as_csv.feature +4 -5
- data/features/index/index_as_blog.feature +20 -1
- data/features/index/index_as_table.feature +1 -1
- data/features/index/index_blank_slate.feature +3 -3
- data/features/index/index_parameters.feature +4 -10
- data/features/index/index_scope_to.feature +24 -0
- data/features/index/index_scopes.feature +17 -5
- data/features/index/pagination.feature +15 -0
- data/features/registering_pages.feature +1 -1
- data/features/registering_resources.feature +2 -2
- data/features/show/default_content.feature +3 -3
- data/features/sidebar_sections.feature +3 -3
- data/features/specifying_actions.feature +1 -1
- data/features/step_definitions/additional_web_steps.rb +3 -16
- data/features/step_definitions/asset_steps.rb +5 -1
- data/features/step_definitions/attribute_steps.rb +4 -4
- data/features/step_definitions/batch_action_steps.rb +25 -74
- data/features/step_definitions/breadcrumb_steps.rb +1 -3
- data/features/step_definitions/comment_steps.rb +0 -1
- data/features/step_definitions/configuration_steps.rb +53 -69
- data/features/step_definitions/dashboard_steps.rb +2 -2
- data/features/step_definitions/factory_steps.rb +17 -33
- data/features/step_definitions/filter_steps.rb +2 -2
- data/features/step_definitions/format_steps.rb +10 -14
- data/features/step_definitions/index_scope_steps.rb +9 -25
- data/features/step_definitions/index_views_steps.rb +1 -1
- data/features/step_definitions/sidebar_steps.rb +2 -1
- data/features/step_definitions/site_title_steps.rb +1 -1
- data/features/step_definitions/table_steps.rb +6 -1
- data/features/step_definitions/user_steps.rb +23 -38
- data/features/step_definitions/web_steps.rb +18 -147
- data/features/support/env.rb +13 -34
- data/features/support/paths.rb +2 -0
- data/features/users/logging_in.feature +2 -2
- data/features/users/logging_out.feature +0 -12
- data/features/users/resetting_password.feature +1 -1
- data/lib/active_admin.rb +4 -17
- data/lib/active_admin/abstract_view_factory.rb +1 -1
- data/lib/active_admin/application.rb +19 -28
- data/lib/active_admin/asset_registration.rb +7 -25
- data/lib/active_admin/authorization_adapter.rb +9 -5
- data/lib/active_admin/base_controller.rb +2 -2
- data/lib/active_admin/base_controller/authorization.rb +25 -27
- data/lib/active_admin/batch_actions/resource_extension.rb +3 -3
- data/lib/active_admin/batch_actions/views/batch_action_selector.rb +1 -1
- data/lib/active_admin/batch_actions/views/selection_cells.rb +1 -1
- data/lib/active_admin/callbacks.rb +1 -1
- data/lib/active_admin/cancan_adapter.rb +2 -2
- data/lib/active_admin/comments.rb +32 -38
- data/lib/active_admin/comments/comment.rb +6 -8
- data/lib/active_admin/comments/views.rb +0 -1
- data/lib/active_admin/comments/views/active_admin_comments.rb +27 -38
- data/lib/active_admin/csv_builder.rb +4 -6
- data/lib/active_admin/dependency_checker.rb +4 -0
- data/lib/active_admin/deprecation.rb +3 -3
- data/lib/active_admin/dsl.rb +5 -5
- data/lib/active_admin/engine.rb +1 -1
- data/lib/active_admin/filters.rb +2 -1
- data/lib/active_admin/filters/forms.rb +36 -43
- data/lib/active_admin/filters/formtastic_addons.rb +45 -0
- data/lib/active_admin/filters/resource_extension.rb +9 -1
- data/lib/active_admin/form_builder.rb +30 -19
- data/lib/active_admin/helpers/optional_display.rb +11 -13
- data/lib/active_admin/helpers/settings.rb +50 -8
- data/lib/active_admin/inputs/filter_base.rb +5 -18
- data/lib/active_admin/inputs/filter_base/search_method_select.rb +73 -0
- data/lib/active_admin/inputs/filter_boolean_input.rb +6 -14
- data/lib/active_admin/inputs/filter_check_boxes_input.rb +1 -1
- data/lib/active_admin/inputs/filter_numeric_input.rb +2 -47
- data/lib/active_admin/inputs/filter_select_input.rb +32 -10
- data/lib/active_admin/inputs/filter_string_input.rb +12 -14
- data/lib/active_admin/namespace.rb +8 -40
- data/lib/active_admin/page.rb +2 -2
- data/lib/active_admin/page_dsl.rb +1 -1
- data/lib/active_admin/reloader.rb +3 -3
- data/lib/active_admin/resource.rb +16 -23
- data/lib/active_admin/resource/belongs_to.rb +8 -5
- data/lib/active_admin/resource/menu.rb +10 -23
- data/lib/active_admin/resource/naming.rb +3 -3
- data/lib/active_admin/resource/page_presenters.rb +2 -2
- data/lib/active_admin/resource/routes.rb +74 -21
- data/lib/active_admin/resource/scope_to.rb +74 -0
- data/lib/active_admin/resource/scopes.rb +8 -4
- data/lib/active_admin/resource_collection.rb +20 -66
- data/lib/active_admin/resource_controller.rb +12 -16
- data/lib/active_admin/resource_controller/data_access.rb +19 -22
- data/lib/active_admin/resource_controller/resource_class_methods.rb +2 -2
- data/lib/active_admin/resource_controller/scoping.rb +4 -9
- data/lib/active_admin/resource_dsl.rb +5 -32
- data/lib/active_admin/router.rb +34 -47
- data/lib/active_admin/scope.rb +5 -3
- data/lib/active_admin/sidebar_section.rb +1 -1
- data/lib/active_admin/version.rb +1 -1
- data/lib/active_admin/view_factory.rb +1 -1
- data/lib/active_admin/view_helpers/auto_link_helper.rb +1 -1
- data/lib/active_admin/view_helpers/breadcrumb_helper.rb +8 -8
- data/lib/active_admin/view_helpers/display_helper.rb +15 -6
- data/lib/active_admin/view_helpers/download_format_links_helper.rb +2 -2
- data/lib/active_admin/view_helpers/form_helper.rb +6 -1
- data/lib/active_admin/view_helpers/icon_helper.rb +1 -1
- data/lib/active_admin/view_helpers/method_or_proc_helper.rb +5 -5
- data/lib/active_admin/view_helpers/title_helper.rb +1 -1
- data/lib/active_admin/views/components/action_list_popover.rb +6 -6
- data/lib/active_admin/views/components/attributes_table.rb +9 -12
- data/lib/active_admin/views/components/blank_slate.rb +4 -4
- data/lib/active_admin/views/components/columns.rb +1 -1
- data/lib/active_admin/views/components/index_list.rb +1 -1
- data/lib/active_admin/views/components/paginated_collection.rb +20 -12
- data/lib/active_admin/views/components/panel.rb +1 -1
- data/lib/active_admin/views/components/scopes.rb +2 -1
- data/lib/active_admin/views/components/sidebar_section.rb +1 -1
- data/lib/active_admin/views/components/status_tag.rb +1 -1
- data/lib/active_admin/views/header.rb +2 -2
- data/lib/active_admin/views/index_as_blog.rb +16 -3
- data/lib/active_admin/views/index_as_table.rb +2 -2
- data/lib/active_admin/views/pages/base.rb +8 -3
- data/lib/active_admin/views/pages/form.rb +2 -2
- data/lib/active_admin/views/pages/index.rb +19 -17
- data/lib/generators/active_admin/assets/templates/3.0/active_admin.js +1 -1
- data/lib/generators/active_admin/assets/templates/3.1/active_admin.css.scss +1 -13
- data/lib/generators/active_admin/devise/devise_generator.rb +22 -1
- data/lib/generators/active_admin/install/install_generator.rb +1 -5
- data/lib/generators/active_admin/install/templates/active_admin.rb.erb +40 -19
- data/lib/generators/active_admin/install/templates/admin_user.rb.erb +18 -18
- data/lib/generators/active_admin/install/templates/migrations/create_active_admin_comments.rb +19 -0
- data/lib/generators/active_admin/resource/resource_generator.rb +1 -1
- data/lib/generators/active_admin/resource/templates/admin.rb +1 -1
- data/script/use_rails +1 -1
- data/spec/integration/memory_spec.rb +3 -2
- data/spec/javascripts/coffeescripts/jquery.aa.checkbox-toggler-spec.js.coffee +4 -4
- data/spec/javascripts/coffeescripts/jquery.aa.popover-spec.js.coffee +1 -1
- data/spec/javascripts/coffeescripts/jquery.aa.table-checkbox-toggler-spec.js.coffee +2 -2
- data/spec/javascripts/compiled/jquery.aa.checkbox-toggler-spec.js +4 -4
- data/spec/javascripts/compiled/jquery.aa.popover-spec.js +1 -1
- data/spec/javascripts/compiled/jquery.aa.table-checkbox-toggler-spec.js +2 -2
- data/spec/spec_helper.rb +16 -6
- data/spec/spec_helper_without_rails.rb +2 -0
- data/spec/support/deferred_garbage_collection.rb +19 -0
- data/spec/support/jslint.yml +1 -1
- data/spec/support/rails_template.rb +29 -27
- data/spec/support/templates/admin/stores.rb +5 -1
- data/spec/unit/abstract_view_factory_spec.rb +1 -1
- data/spec/unit/action_builder_spec.rb +7 -7
- data/spec/unit/active_admin_spec.rb +0 -14
- data/spec/unit/application_spec.rb +16 -17
- data/spec/unit/asset_registration_spec.rb +21 -8
- data/spec/unit/authorization/authorization_adapter_spec.rb +3 -3
- data/spec/unit/authorization/controller_authorization_spec.rb +16 -24
- data/spec/unit/batch_actions/resource_spec.rb +11 -11
- data/spec/unit/belongs_to_spec.rb +1 -1
- data/spec/unit/cancan_adapter_spec.rb +11 -3
- data/spec/unit/comments_spec.rb +10 -28
- data/spec/unit/controller_filters_spec.rb +22 -24
- data/spec/unit/csv_builder_spec.rb +3 -3
- data/spec/unit/devise_spec.rb +10 -10
- data/spec/unit/filters/filter_form_builder_spec.rb +140 -45
- data/spec/unit/filters/resource_spec.rb +20 -19
- data/spec/unit/form_builder_spec.rb +122 -70
- data/spec/unit/menu_item_spec.rb +3 -3
- data/spec/unit/namespace/authorization_spec.rb +4 -8
- data/spec/unit/namespace/register_page_spec.rb +1 -1
- data/spec/unit/namespace/register_resource_spec.rb +12 -7
- data/spec/unit/namespace_spec.rb +4 -10
- data/spec/unit/page_spec.rb +1 -1
- data/spec/unit/resource/menu_spec.rb +1 -1
- data/spec/unit/resource/naming_spec.rb +9 -0
- data/spec/unit/resource/pagination_spec.rb +2 -2
- data/spec/unit/resource/routes_spec.rb +73 -0
- data/spec/unit/resource/scopes_spec.rb +1 -1
- data/spec/unit/resource_collection_spec.rb +95 -43
- data/spec/unit/resource_registration_spec.rb +3 -12
- data/spec/unit/resource_spec.rb +41 -48
- data/spec/unit/routing_spec.rb +10 -64
- data/spec/unit/scope_spec.rb +19 -0
- data/spec/unit/settings_spec.rb +88 -0
- data/spec/unit/view_factory_spec.rb +1 -0
- data/spec/unit/{breadcrumbs_spec.rb → view_helpers/breadcrumbs_spec.rb} +16 -7
- data/spec/unit/view_helpers/display_name_spec.rb +41 -0
- data/spec/unit/view_helpers/form_helper_spec.rb +36 -2
- data/spec/unit/views/components/attributes_table_spec.rb +17 -9
- data/spec/unit/views/components/batch_action_popover_spec.rb +4 -4
- data/spec/unit/views/components/index_list_spec.rb +2 -2
- data/spec/unit/views/components/paginated_collection_spec.rb +42 -0
- data/spec/unit/views/components/panel_spec.rb +8 -0
- data/spec/unit/views/components/site_title_spec.rb +2 -2
- data/spec/unit/views/components/table_for_spec.rb +4 -4
- data/spec/unit/views/pages/form_spec.rb +35 -0
- data/spec/unit/views/pages/layout_spec.rb +1 -1
- data/spec/unit/views/tabbed_navigation_spec.rb +10 -10
- data/tasks/parallel_tests.rake +1 -1
- data/tasks/test.rake +4 -1
- metadata +117 -106
- data/app/assets/stylesheets/active_admin/pages/_dashboard.scss +0 -5
- data/lib/active_admin/comments/views/active_admin_comment.rb +0 -0
- data/lib/active_admin/dashboards.rb +0 -68
- data/lib/active_admin/dashboards/dashboard_controller.rb +0 -50
- data/lib/active_admin/dashboards/section.rb +0 -34
- data/lib/active_admin/locales/bg.yml +0 -77
- data/lib/generators/active_admin/install/templates/migrations/1_create_admin_notes.rb +0 -17
- data/lib/generators/active_admin/install/templates/migrations/2_move_admin_notes_to_comments.rb +0 -26
- data/spec/unit/base_controller_spec.rb +0 -6
- data/spec/unit/dashboard_controller_spec.rb +0 -76
- data/spec/unit/dashboard_section_spec.rb +0 -56
- data/spec/unit/dashboards_spec.rb +0 -59
- data/spec/unit/display_name_spec.rb +0 -29
|
@@ -24,24 +24,20 @@ module ActiveAdmin
|
|
|
24
24
|
include Sidebars
|
|
25
25
|
extend ResourceClassMethods
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
defaults :resource_class => config.resource_class, :route_prefix => config.route_prefix, :instance_name => config.resource_name.singular
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
# Inherited Resources uses the inherited(base) hook method to
|
|
37
|
-
# add in the Base.resource_class class method. To override it, we
|
|
38
|
-
# need to install our resource_class method each time we're inherited from.
|
|
39
|
-
def inherited(base)
|
|
40
|
-
super(base)
|
|
41
|
-
base.override_resource_class_methods!
|
|
27
|
+
def self.active_admin_config=(config)
|
|
28
|
+
if @active_admin_config = config
|
|
29
|
+
defaults :resource_class => config.resource_class,
|
|
30
|
+
:route_prefix => config.route_prefix,
|
|
31
|
+
:instance_name => config.resource_name.singular
|
|
42
32
|
end
|
|
33
|
+
end
|
|
43
34
|
|
|
44
|
-
|
|
35
|
+
# Inherited Resources uses the `self.inherited(base)` hook to add
|
|
36
|
+
# in `self.resource_class`. To override it, we need to install
|
|
37
|
+
# our resource_class method each time we're inherited from.
|
|
38
|
+
def self.inherited(base)
|
|
39
|
+
super(base)
|
|
40
|
+
base.override_resource_class_methods!
|
|
45
41
|
end
|
|
46
42
|
|
|
47
43
|
private
|
|
@@ -21,8 +21,8 @@ module ActiveAdmin
|
|
|
21
21
|
# Retrieve, memoize and authorize the current collection from the db. This
|
|
22
22
|
# method delegates the finding of the collection to #find_collection.
|
|
23
23
|
#
|
|
24
|
-
# Once #collection has been called, the collection is available using
|
|
25
|
-
# either the @collection instance variable or an instance variable named
|
|
24
|
+
# Once #collection has been called, the collection is available using
|
|
25
|
+
# either the @collection instance variable or an instance variable named
|
|
26
26
|
# after the resource that the collection is for. eg: Post => @post.
|
|
27
27
|
#
|
|
28
28
|
# @returns [ActiveRecord::Relation] The collection for the index
|
|
@@ -38,15 +38,16 @@ module ActiveAdmin
|
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
|
|
41
|
-
# Does the actual work of retrieving the current collection from the db.
|
|
42
|
-
# This is a great method to override if you would like to perform
|
|
43
|
-
# some additional db # work before your controller returns and
|
|
41
|
+
# Does the actual work of retrieving the current collection from the db.
|
|
42
|
+
# This is a great method to override if you would like to perform
|
|
43
|
+
# some additional db # work before your controller returns and
|
|
44
44
|
# authorizes the collection.
|
|
45
45
|
#
|
|
46
46
|
# @returns [ActiveRecord::Relation] The collectin for the index
|
|
47
47
|
def find_collection
|
|
48
48
|
collection = scoped_collection
|
|
49
49
|
|
|
50
|
+
collection = apply_authorization_scope(collection)
|
|
50
51
|
collection = apply_sorting(collection)
|
|
51
52
|
collection = apply_filtering(collection)
|
|
52
53
|
collection = apply_scoping(collection)
|
|
@@ -67,10 +68,10 @@ module ActiveAdmin
|
|
|
67
68
|
# scope_to method from the Scoping module instead of overriding this
|
|
68
69
|
# method.
|
|
69
70
|
def scoped_collection
|
|
70
|
-
|
|
71
|
+
end_of_association_chain
|
|
71
72
|
end
|
|
72
73
|
|
|
73
|
-
# Retrieve, memoize and authorize a resource based on params[:id]. The
|
|
74
|
+
# Retrieve, memoize and authorize a resource based on params[:id]. The
|
|
74
75
|
# actual work of finding the resource is done in #find_resource.
|
|
75
76
|
#
|
|
76
77
|
# This method is used on all the member actions:
|
|
@@ -105,7 +106,7 @@ module ActiveAdmin
|
|
|
105
106
|
end
|
|
106
107
|
|
|
107
108
|
|
|
108
|
-
# Does the actual work of finding a resource in the database. This
|
|
109
|
+
# Does the actual work of finding a resource in the database. This
|
|
109
110
|
# method uses the finder method as defined in InheritedResources.
|
|
110
111
|
#
|
|
111
112
|
# @returns [ActiveRecord::Base] An active record object.
|
|
@@ -114,8 +115,8 @@ module ActiveAdmin
|
|
|
114
115
|
end
|
|
115
116
|
|
|
116
117
|
|
|
117
|
-
# Builds, memoize and authorize a new instance of the resource. The
|
|
118
|
-
# actual work of building the new instance is delegated to the
|
|
118
|
+
# Builds, memoize and authorize a new instance of the resource. The
|
|
119
|
+
# actual work of building the new instance is delegated to the
|
|
119
120
|
# #build_new_resource method.
|
|
120
121
|
#
|
|
121
122
|
# This method is used to instantiate and authorize new resources in the
|
|
@@ -202,14 +203,15 @@ module ActiveAdmin
|
|
|
202
203
|
|
|
203
204
|
# Gives the authorization library a change to pre-scope the collection.
|
|
204
205
|
#
|
|
205
|
-
# In the case of the CanCan adapter, it calls `#accessible_by` on
|
|
206
|
+
# In the case of the CanCan adapter, it calls `#accessible_by` on
|
|
206
207
|
# the collection.
|
|
207
208
|
#
|
|
208
209
|
# @param [ActiveRecord::Relation] collection The collection to scope
|
|
209
210
|
#
|
|
210
211
|
# @retruns [ActiveRecord::Relation] a scoped collection of query
|
|
211
|
-
def
|
|
212
|
-
|
|
212
|
+
def apply_authorization_scope(collection)
|
|
213
|
+
action_name = action_to_permission(params[:action])
|
|
214
|
+
active_admin_authorization.scope_collection(collection, action_name)
|
|
213
215
|
end
|
|
214
216
|
|
|
215
217
|
|
|
@@ -260,28 +262,23 @@ module ActiveAdmin
|
|
|
260
262
|
@current_scope ||= if params[:scope]
|
|
261
263
|
active_admin_config.get_scope_by_id(params[:scope]) if params[:scope]
|
|
262
264
|
else
|
|
263
|
-
active_admin_config.default_scope
|
|
265
|
+
active_admin_config.default_scope(self)
|
|
264
266
|
end
|
|
265
267
|
end
|
|
266
268
|
|
|
267
269
|
def apply_pagination(chain)
|
|
268
|
-
|
|
269
|
-
|
|
270
|
+
page_method = Kaminari.config.page_method_name
|
|
271
|
+
page_param = params[Kaminari.config.param_name]
|
|
270
272
|
|
|
271
|
-
chain.send(
|
|
273
|
+
chain.send(page_method, page_param).per(per_page)
|
|
272
274
|
end
|
|
273
275
|
|
|
274
276
|
def per_page
|
|
275
|
-
return max_csv_records if request.format == 'text/csv'
|
|
276
277
|
return max_per_page if active_admin_config.paginate == false
|
|
277
278
|
|
|
278
279
|
@per_page || active_admin_config.per_page
|
|
279
280
|
end
|
|
280
281
|
|
|
281
|
-
def max_csv_records
|
|
282
|
-
10_000
|
|
283
|
-
end
|
|
284
|
-
|
|
285
282
|
def max_per_page
|
|
286
283
|
10_000
|
|
287
284
|
end
|
|
@@ -2,11 +2,11 @@ module ActiveAdmin
|
|
|
2
2
|
class ResourceController < BaseController
|
|
3
3
|
module ResourceClassMethods
|
|
4
4
|
|
|
5
|
-
# Override the default resource_class class and instance
|
|
5
|
+
# Override the default `resource_class` class and instance
|
|
6
6
|
# methods to only return the class defined in the instance
|
|
7
7
|
# of ActiveAdmin::Resource
|
|
8
8
|
def override_resource_class_methods!
|
|
9
|
-
|
|
9
|
+
class_exec do
|
|
10
10
|
def self.resource_class=(klass); end
|
|
11
11
|
|
|
12
12
|
def self.resource_class
|
|
@@ -11,16 +11,11 @@ module ActiveAdmin
|
|
|
11
11
|
# the scope to be defined in the active admin configuration.
|
|
12
12
|
#
|
|
13
13
|
# If scope_to is a proc, we eval it, otherwise we call the method on the controller.
|
|
14
|
+
#
|
|
15
|
+
# Collection can be scoped conditionally with an :if or :unless proc.
|
|
14
16
|
def begin_of_association_chain
|
|
15
|
-
return nil unless active_admin_config.scope_to
|
|
16
|
-
|
|
17
|
-
when Proc
|
|
18
|
-
instance_eval &active_admin_config.scope_to
|
|
19
|
-
when Symbol
|
|
20
|
-
send active_admin_config.scope_to
|
|
21
|
-
else
|
|
22
|
-
raise ArgumentError, "#scope_to accepts a symbol or a block"
|
|
23
|
-
end
|
|
17
|
+
return nil unless active_admin_config.scope_to?(self)
|
|
18
|
+
render_in_context(self, active_admin_config.scope_to_method)
|
|
24
19
|
end
|
|
25
20
|
|
|
26
21
|
# Overriding from InheritedResources::BaseHelpers
|
|
@@ -7,36 +7,9 @@ module ActiveAdmin
|
|
|
7
7
|
config.belongs_to(target, options)
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
-
# Scope
|
|
11
|
-
# to the resource. Can either accept a block or a symbol
|
|
12
|
-
# of a method to call.
|
|
13
|
-
#
|
|
14
|
-
# Eg:
|
|
15
|
-
#
|
|
16
|
-
# ActiveAdmin.register Post do
|
|
17
|
-
# scope_to :current_user
|
|
18
|
-
# end
|
|
19
|
-
#
|
|
20
|
-
# Then every time we instantiate and object, it would call
|
|
21
|
-
#
|
|
22
|
-
# current_user.posts.build
|
|
23
|
-
#
|
|
24
|
-
# By default Active Admin will use the resource name to build a
|
|
25
|
-
# method to call as the association. If its different, you can
|
|
26
|
-
# pass in the association_method as an option.
|
|
27
|
-
#
|
|
28
|
-
# scope_to :current_user, :association_method => :blog_posts
|
|
29
|
-
#
|
|
30
|
-
# will result in the following
|
|
31
|
-
#
|
|
32
|
-
# current_user.blog_posts.build
|
|
33
|
-
#
|
|
10
|
+
# Scope collection to a relation
|
|
34
11
|
def scope_to(*args, &block)
|
|
35
|
-
|
|
36
|
-
method = args.first
|
|
37
|
-
|
|
38
|
-
config.scope_to = block_given? ? block : method
|
|
39
|
-
config.scope_to_association_method = options[:association_method]
|
|
12
|
+
config.scope_to(*args, &block)
|
|
40
13
|
end
|
|
41
14
|
|
|
42
15
|
# Create a scope
|
|
@@ -49,7 +22,7 @@ module ActiveAdmin
|
|
|
49
22
|
options[:as] ||= :table
|
|
50
23
|
config.set_page_presenter :index, ActiveAdmin::PagePresenter.new(options, &block)
|
|
51
24
|
end
|
|
52
|
-
|
|
25
|
+
|
|
53
26
|
# Configure the show page for the resource
|
|
54
27
|
def show(options = {}, &block)
|
|
55
28
|
config.set_page_presenter :show, ActiveAdmin::PagePresenter.new(options, &block)
|
|
@@ -68,7 +41,7 @@ module ActiveAdmin
|
|
|
68
41
|
# column("Author") { |post| post.author.full_name }
|
|
69
42
|
# end
|
|
70
43
|
#
|
|
71
|
-
# csv :
|
|
44
|
+
# csv :col_sep => ";", :force_quotes => true do
|
|
72
45
|
# column :name
|
|
73
46
|
# end
|
|
74
47
|
#
|
|
@@ -144,7 +117,7 @@ module ActiveAdmin
|
|
|
144
117
|
delegate :before_destroy, :after_destroy, :to => :controller
|
|
145
118
|
|
|
146
119
|
# Standard rails filters
|
|
147
|
-
delegate :before_filter, :skip_before_filter, :after_filter, :around_filter, :to => :controller
|
|
120
|
+
delegate :before_filter, :skip_before_filter, :after_filter, :around_filter, :skip_filter, :to => :controller
|
|
148
121
|
|
|
149
122
|
# Specify which actions to create in the controller
|
|
150
123
|
#
|
data/lib/active_admin/router.rb
CHANGED
|
@@ -13,101 +13,88 @@ module ActiveAdmin
|
|
|
13
13
|
# end
|
|
14
14
|
#
|
|
15
15
|
def apply(router)
|
|
16
|
-
|
|
16
|
+
define_root_routes router
|
|
17
17
|
define_resource_routes router
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
router.instance_exec(@application.namespaces.values, self) do |namespaces, aa_router|
|
|
20
|
+
def define_root_routes(router)
|
|
21
|
+
router.instance_exec @application.namespaces.values do |namespaces|
|
|
23
22
|
namespaces.each do |namespace|
|
|
24
23
|
if namespace.root?
|
|
25
|
-
|
|
24
|
+
root :to => namespace.root_to
|
|
26
25
|
else
|
|
27
|
-
namespace
|
|
28
|
-
|
|
26
|
+
namespace namespace.name do
|
|
27
|
+
root :to => namespace.root_to
|
|
29
28
|
end
|
|
30
29
|
end
|
|
31
30
|
end
|
|
32
31
|
end
|
|
33
32
|
end
|
|
34
33
|
|
|
35
|
-
|
|
36
|
-
Proc.new do
|
|
37
|
-
root :to => (namespace.root_to || "dashboard#index")
|
|
38
|
-
if ActiveAdmin::Dashboards.built?
|
|
39
|
-
match '/dashboard' => 'dashboard#index', :as => 'dashboard'
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
# Define the routes for each resource
|
|
34
|
+
# Defines the routes for each resource
|
|
45
35
|
def define_resource_routes(router)
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
router.instance_exec(@application.namespaces, self) do |namespaces, aa_router|
|
|
49
|
-
resources = namespaces.values.collect{|n| n.resources.resources }.flatten
|
|
36
|
+
router.instance_exec @application.namespaces, self do |namespaces, aa_router|
|
|
37
|
+
resources = namespaces.values.map{ |n| n.resources.values }.flatten
|
|
50
38
|
resources.each do |config|
|
|
51
|
-
|
|
39
|
+
routes = aa_router.resource_routes(config)
|
|
52
40
|
|
|
53
41
|
# Add in the parent if it exists
|
|
54
42
|
if config.belongs_to?
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
# If
|
|
58
|
-
|
|
43
|
+
belongs_to = routes
|
|
44
|
+
routes = Proc.new do
|
|
45
|
+
# If it's optional, make the normal resource routes
|
|
46
|
+
instance_exec &belongs_to if config.belongs_to_config.optional?
|
|
59
47
|
|
|
60
48
|
# Make the nested belongs_to routes
|
|
61
49
|
# :only is set to nothing so that we don't clobber any existing routes on the resource
|
|
62
50
|
resources config.belongs_to_config.target.resource_name.plural, :only => [] do
|
|
63
|
-
|
|
51
|
+
instance_exec &belongs_to
|
|
64
52
|
end
|
|
65
53
|
end
|
|
66
54
|
end
|
|
67
55
|
|
|
68
56
|
# Add on the namespace if required
|
|
69
57
|
unless config.namespace.root?
|
|
70
|
-
|
|
71
|
-
|
|
58
|
+
nested = routes
|
|
59
|
+
routes = Proc.new do
|
|
72
60
|
namespace config.namespace.name do
|
|
73
|
-
|
|
61
|
+
instance_exec &nested
|
|
74
62
|
end
|
|
75
63
|
end
|
|
76
64
|
end
|
|
77
65
|
|
|
78
|
-
|
|
66
|
+
instance_exec &routes
|
|
79
67
|
end
|
|
80
68
|
end
|
|
81
69
|
end
|
|
82
70
|
|
|
83
71
|
def resource_routes(config)
|
|
84
72
|
Proc.new do
|
|
73
|
+
# Builds one route for each HTTP verb passed in
|
|
74
|
+
build_route = proc{ |verbs, *args|
|
|
75
|
+
[*verbs].each{ |verb| send verb, *args }
|
|
76
|
+
}
|
|
77
|
+
# Deals with +ControllerAction+ instances
|
|
78
|
+
build_action = proc{ |action|
|
|
79
|
+
build_route.call(action.http_verb, action.name)
|
|
80
|
+
}
|
|
85
81
|
case config
|
|
86
|
-
when Resource
|
|
82
|
+
when ::ActiveAdmin::Resource
|
|
87
83
|
resources config.resource_name.route_key, :only => config.defined_actions do
|
|
88
|
-
# Define any member actions
|
|
89
84
|
member do
|
|
90
|
-
config.member_actions.each
|
|
91
|
-
[*action.http_verb].each do |http_verb|
|
|
92
|
-
# eg: get :comment
|
|
93
|
-
send(http_verb, action.name)
|
|
94
|
-
end
|
|
95
|
-
end
|
|
85
|
+
config.member_actions.each &build_action
|
|
96
86
|
end
|
|
97
87
|
|
|
98
|
-
# Define any collection actions
|
|
99
88
|
collection do
|
|
100
|
-
config.collection_actions.each
|
|
101
|
-
send(action.http_verb, action.name)
|
|
102
|
-
end
|
|
103
|
-
|
|
89
|
+
config.collection_actions.each &build_action
|
|
104
90
|
post :batch_action
|
|
105
91
|
end
|
|
106
92
|
end
|
|
107
|
-
when Page
|
|
108
|
-
|
|
93
|
+
when ::ActiveAdmin::Page
|
|
94
|
+
page = config.underscored_resource_name
|
|
95
|
+
get "/#{page}" => "#{page}#index"
|
|
109
96
|
config.page_actions.each do |action|
|
|
110
|
-
|
|
97
|
+
build_route.call action.http_verb, "/#{page}/#{action.name}" => "#{page}##{action.name}"
|
|
111
98
|
end
|
|
112
99
|
else
|
|
113
100
|
raise "Unsupported config class: #{config.class}"
|
data/lib/active_admin/scope.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module ActiveAdmin
|
|
2
2
|
class Scope
|
|
3
3
|
|
|
4
|
-
attr_reader :scope_method, :id, :scope_block, :display_if_block, :show_count
|
|
4
|
+
attr_reader :scope_method, :id, :scope_block, :display_if_block, :show_count, :default_block
|
|
5
5
|
|
|
6
6
|
# Create a Scope
|
|
7
7
|
#
|
|
@@ -13,7 +13,7 @@ module ActiveAdmin
|
|
|
13
13
|
# Scope.new('Published', :public)
|
|
14
14
|
# # => Scope with name 'Published' and scope method :public
|
|
15
15
|
#
|
|
16
|
-
# Scope.new 'Published', :public, :if => proc { current_admin_user.can? :manage, resource_class } do |articles|
|
|
16
|
+
# Scope.new 'Published', :public, :if => proc { current_admin_user.can? :manage, resource_class } do |articles|
|
|
17
17
|
# articles.where :published => true
|
|
18
18
|
# end
|
|
19
19
|
# # => Scope with name 'Published' and scope method :public, optionally displaying the scope per the :if block
|
|
@@ -39,7 +39,9 @@ module ActiveAdmin
|
|
|
39
39
|
@scope_method, @scope_block = nil, block if block_given?
|
|
40
40
|
|
|
41
41
|
@show_count = options[:show_count].nil? ? true : options[:show_count]
|
|
42
|
-
@display_if_block = options[:if]
|
|
42
|
+
@display_if_block = options[:if] || proc{ true }
|
|
43
|
+
@default_block = options[:default] || proc{ false }
|
|
44
|
+
|
|
43
45
|
end
|
|
44
46
|
|
|
45
47
|
def name
|
data/lib/active_admin/version.rb
CHANGED
|
@@ -5,12 +5,12 @@ module ActiveAdmin
|
|
|
5
5
|
|
|
6
6
|
# Register Helper Renderers
|
|
7
7
|
register :global_navigation => ActiveAdmin::Views::TabbedNavigation,
|
|
8
|
+
:utility_navigation => ActiveAdmin::Views::TabbedNavigation,
|
|
8
9
|
:site_title => ActiveAdmin::Views::SiteTitle,
|
|
9
10
|
:action_items => ActiveAdmin::Views::ActionItems,
|
|
10
11
|
:title_bar => ActiveAdmin::Views::TitleBar,
|
|
11
12
|
:header => ActiveAdmin::Views::Header,
|
|
12
13
|
:footer => ActiveAdmin::Views::Footer,
|
|
13
|
-
:dashboard_section => ActiveAdmin::Views::DashboardSection,
|
|
14
14
|
:index_scopes => ActiveAdmin::Views::Scopes,
|
|
15
15
|
:blank_slate => ActiveAdmin::Views::BlankSlate,
|
|
16
16
|
:action_list_popover => ActiveAdmin::Views::ActionListPopover
|
|
@@ -15,7 +15,7 @@ module ActiveAdmin
|
|
|
15
15
|
content = link_content || display_name(resource)
|
|
16
16
|
if (registration = active_admin_resource_for(resource.class))
|
|
17
17
|
begin
|
|
18
|
-
content = link_to(content,
|
|
18
|
+
content = link_to(content, registration.route_instance_path(resource))
|
|
19
19
|
rescue
|
|
20
20
|
# ignored
|
|
21
21
|
end
|