activeadmin 0.6.0 → 0.6.1
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 +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
@@ -72,7 +72,7 @@ module ActiveAdmin
|
|
72
72
|
:notice => I18n.t("active_admin.batch_actions.succesfully_destroyed",
|
73
73
|
:count => selected_ids.count,
|
74
74
|
:model => active_admin_config.resource_label.downcase,
|
75
|
-
:plural_model => active_admin_config.plural_resource_label.downcase)
|
75
|
+
:plural_model => active_admin_config.plural_resource_label(:count => selected_ids.count).downcase)
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
@@ -89,11 +89,11 @@ module ActiveAdmin
|
|
89
89
|
#
|
90
90
|
# Examples:
|
91
91
|
#
|
92
|
-
# BatchAction.new :flag
|
92
|
+
# BatchAction.new :flag
|
93
93
|
# => Will create an action that appears in the action list popover
|
94
94
|
#
|
95
95
|
# BatchAction.new( :flag ) { |selection| redirect_to collection_path, :notice => "#{selection.length} users flagged" }
|
96
|
-
# => Will create an action that uses a block to process the request (which receives one paramater of the selected objects)
|
96
|
+
# => Will create an action that uses a block to process the request (which receives one paramater of the selected objects)
|
97
97
|
#
|
98
98
|
# BatchAction.new( "Perform Long Operation on the" ) { |selection| }
|
99
99
|
# => You can create batch actions with a title instead of a Symbol
|
@@ -23,7 +23,7 @@ module ActiveAdmin
|
|
23
23
|
private
|
24
24
|
|
25
25
|
def build_drop_down
|
26
|
-
dropdown_menu I18n.t("active_admin.batch_actions.button_label"),
|
26
|
+
dropdown_menu I18n.t("active_admin.batch_actions.button_label"),
|
27
27
|
:id => "batch_actions_selector",
|
28
28
|
:button => { :class => "disabled" } do
|
29
29
|
batch_actions_to_display.each do |batch_action|
|
@@ -17,7 +17,7 @@ module ActiveAdmin
|
|
17
17
|
builder_method :resource_selection_cell
|
18
18
|
|
19
19
|
def build(resource)
|
20
|
-
input :type => "checkbox", :id => "batch_action_item_#{resource.id}", :value => resource.id, :class => "collection_selection", :name => "collection_selection[]"
|
20
|
+
input :type => "checkbox", :id => "batch_action_item_#{resource.id}", :value => resource.id, :class => "collection_selection", :name => "collection_selection[]"
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
@@ -15,8 +15,8 @@ module ActiveAdmin
|
|
15
15
|
@cancan_ability ||= initialize_cancan_ability
|
16
16
|
end
|
17
17
|
|
18
|
-
def scope_collection(collection)
|
19
|
-
collection.accessible_by(cancan_ability)
|
18
|
+
def scope_collection(collection, action = ActiveAdmin::Auth::READ)
|
19
|
+
collection.accessible_by(cancan_ability, action)
|
20
20
|
end
|
21
21
|
|
22
22
|
private
|
@@ -5,7 +5,9 @@ require 'active_admin/comments/namespace_helper'
|
|
5
5
|
require 'active_admin/comments/resource_helper'
|
6
6
|
|
7
7
|
# Add the comments configuration
|
8
|
-
ActiveAdmin::Application.inheritable_setting :allow_comments,
|
8
|
+
ActiveAdmin::Application.inheritable_setting :allow_comments, true
|
9
|
+
ActiveAdmin::Application.inheritable_setting :show_comments_in_menu, true
|
10
|
+
ActiveAdmin::Application.inheritable_setting :comments_registration_name, 'Comment'
|
9
11
|
|
10
12
|
# Add the comments module to ActiveAdmin::Namespace
|
11
13
|
ActiveAdmin::Namespace.send :include, ActiveAdmin::Comments::NamespaceHelper
|
@@ -20,66 +22,58 @@ ActiveAdmin.application.view_factory.show_page.send :include, ActiveAdmin::Comme
|
|
20
22
|
ActiveAdmin.after_load do |app|
|
21
23
|
app.namespaces.values.each do |namespace|
|
22
24
|
if namespace.comments?
|
23
|
-
namespace.register ActiveAdmin::Comment, :as =>
|
25
|
+
namespace.register ActiveAdmin::Comment, :as => namespace.comments_registration_name do
|
24
26
|
actions :index, :show, :create
|
25
27
|
|
26
|
-
|
27
|
-
config.filters = true
|
28
|
+
menu false unless namespace.show_comments_in_menu
|
28
29
|
|
29
|
-
# Don't
|
30
|
-
|
30
|
+
config.comments = false # Don't allow comments on comments
|
31
|
+
config.batch_actions = false # The default destroy batch action isn't showing up anyway...
|
31
32
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
# Only view comments in this namespace
|
41
|
-
scope :all, :default => true do |comments|
|
42
|
-
comments.where(:namespace => active_admin_config.namespace.name.to_s)
|
43
|
-
end
|
44
|
-
|
45
|
-
# Always redirect to the resource on show
|
46
|
-
before_filter :only => :show do
|
47
|
-
flash[:notice] = flash[:notice].dup if flash[:notice]
|
48
|
-
comment = ActiveAdmin::Comment.find(params[:id])
|
49
|
-
resource_config = active_admin_config.namespace.resource_for(comment.resource.class)
|
50
|
-
redirect_to send(resource_config.route_instance_path, comment.resource)
|
33
|
+
scope :all, :show_count => false
|
34
|
+
# Register a scope for every namespace that exists.
|
35
|
+
# The current namespace will be the default scope.
|
36
|
+
app.namespaces.values.map(&:name).each do |name|
|
37
|
+
scope name, :default => namespace.name == name do |scope|
|
38
|
+
scope.where :namespace => name.to_s
|
39
|
+
end
|
51
40
|
end
|
52
41
|
|
53
42
|
# Store the author and namespace
|
54
43
|
before_save do |comment|
|
55
44
|
comment.namespace = active_admin_config.namespace.name
|
56
|
-
comment.author
|
45
|
+
comment.author = current_active_admin_user
|
57
46
|
end
|
58
47
|
|
59
|
-
# Redirect to the resource show page
|
60
|
-
# TODO: Provide helpers to make such kind of customization much simpler
|
48
|
+
# Redirect to the resource show page after comment creation
|
61
49
|
controller do
|
50
|
+
# Prevent N+1 queries
|
51
|
+
def scoped_collection
|
52
|
+
resource_class.includes :author, :resource
|
53
|
+
end unless Rails::VERSION::MAJOR == 3 && Rails::VERSION::MINOR == 0
|
62
54
|
def create
|
63
55
|
create! do |success, failure|
|
64
|
-
|
65
|
-
|
56
|
+
# FYI: below we call `resource.resource`. First is the comment, second is the associated resource.
|
57
|
+
resource_config = active_admin_config.namespace.resource_for resource.resource.class
|
58
|
+
resource_url = resource_config.route_instance_path resource.resource
|
59
|
+
success.html{ redirect_to resource_url }
|
60
|
+
failure.html do
|
66
61
|
flash[:error] = I18n.t('active_admin.comments.errors.empty_text')
|
67
|
-
redirect_to
|
62
|
+
redirect_to resource_url
|
68
63
|
end
|
69
64
|
end
|
70
65
|
end
|
71
66
|
end
|
72
67
|
|
73
|
-
# Display as a table
|
74
68
|
index do
|
75
|
-
column
|
76
|
-
column
|
77
|
-
column
|
69
|
+
column I18n.t('active_admin.comments.resource_type'), :resource_type
|
70
|
+
column I18n.t('active_admin.comments.author_type'), :author_type
|
71
|
+
column I18n.t('active_admin.comments.resource'), :resource
|
72
|
+
column I18n.t('active_admin.comments.author'), :author
|
73
|
+
column I18n.t('active_admin.comments.body'), :body
|
74
|
+
actions
|
78
75
|
end
|
79
76
|
end
|
80
77
|
end
|
81
78
|
end
|
82
79
|
end
|
83
|
-
|
84
|
-
# @deprecated #allow_comments_on - Remove in 0.5.0
|
85
|
-
ActiveAdmin::Application.deprecated_setting :allow_comments_in, [], 'The "allow_comments_in = []" setting is deprecated and will be remove by Active Admin 0.5.0. Please use "allow_comments = true|false" instead.'
|
@@ -7,13 +7,11 @@ module ActiveAdmin
|
|
7
7
|
|
8
8
|
class Comment < ActiveRecord::Base
|
9
9
|
belongs_to :resource, :polymorphic => true
|
10
|
-
belongs_to :author,
|
10
|
+
belongs_to :author, :polymorphic => true
|
11
11
|
|
12
12
|
attr_accessible :resource, :resource_id, :resource_type, :body, :namespace
|
13
13
|
|
14
|
-
validates_presence_of :resource
|
15
|
-
validates_presence_of :body
|
16
|
-
validates_presence_of :namespace
|
14
|
+
validates_presence_of :body, :namespace, :resource
|
17
15
|
|
18
16
|
# @returns [String] The name of the record to use for the polymorphic relationship
|
19
17
|
def self.resource_type(record)
|
@@ -30,13 +28,13 @@ module ActiveAdmin
|
|
30
28
|
end
|
31
29
|
|
32
30
|
def self.find_for_resource_in_namespace(resource, namespace)
|
33
|
-
where
|
34
|
-
:resource_id
|
35
|
-
:namespace
|
31
|
+
where :resource_type => resource_type(resource),
|
32
|
+
:resource_id => resource_id_cast(resource),
|
33
|
+
:namespace => namespace.to_s
|
36
34
|
end
|
37
35
|
|
38
36
|
def self.resource_id_type
|
39
|
-
columns.
|
37
|
+
columns.detect{ |i| i.name == "resource_id" }.type
|
40
38
|
end
|
41
39
|
|
42
40
|
def self.table_name
|
@@ -8,70 +8,59 @@ module ActiveAdmin
|
|
8
8
|
class Comments < ActiveAdmin::Views::Panel
|
9
9
|
builder_method :active_admin_comments_for
|
10
10
|
|
11
|
-
def build(
|
12
|
-
@
|
13
|
-
|
11
|
+
def build(resource)
|
12
|
+
@resource = resource
|
13
|
+
@comments = ActiveAdmin::Comment.find_for_resource_in_namespace @resource, active_admin_namespace.name
|
14
|
+
super(title, :for => resource)
|
14
15
|
build_comments
|
15
16
|
end
|
16
17
|
|
17
18
|
protected
|
18
19
|
|
19
|
-
def
|
20
|
-
I18n.t
|
21
|
-
end
|
22
|
-
|
23
|
-
def record_comments
|
24
|
-
@record_comments ||= ActiveAdmin::Comment.find_for_resource_in_namespace(@record, active_admin_namespace.name)
|
20
|
+
def title
|
21
|
+
I18n.t 'active_admin.comments.title_content', :count => @comments.count
|
25
22
|
end
|
26
23
|
|
27
24
|
def build_comments
|
28
|
-
|
29
|
-
record_comments.each do |comment|
|
30
|
-
build_comment(comment)
|
31
|
-
end
|
32
|
-
else
|
33
|
-
build_empty_message
|
34
|
-
end
|
25
|
+
@comments.any? ? @comments.each(&method(:build_comment)) : build_empty_message
|
35
26
|
build_comment_form
|
36
27
|
end
|
37
28
|
|
38
29
|
def build_comment(comment)
|
39
30
|
div :for => comment do
|
40
|
-
div :class =>
|
41
|
-
|
42
|
-
|
43
|
-
|
31
|
+
div :class => 'active_admin_comment_meta' do
|
32
|
+
h4 :class => 'active_admin_comment_author' do
|
33
|
+
comment.author ? auto_link(comment.author) : 'Anonymous'
|
34
|
+
end
|
35
|
+
span pretty_format comment.created_at
|
44
36
|
end
|
45
|
-
div :class =>
|
46
|
-
simple_format
|
37
|
+
div :class => 'active_admin_comment_body' do
|
38
|
+
simple_format comment.body
|
47
39
|
end
|
48
|
-
div :style => "clear:both;"
|
49
40
|
end
|
50
41
|
end
|
51
42
|
|
52
43
|
def build_empty_message
|
53
|
-
span :class =>
|
54
|
-
I18n.t('active_admin.comments.no_comments_yet')
|
55
|
-
end
|
44
|
+
span I18n.t('active_admin.comments.no_comments_yet'), :class => 'empty'
|
56
45
|
end
|
57
46
|
|
58
47
|
def comment_form_url
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
48
|
+
parts = []
|
49
|
+
parts << active_admin_namespace.name unless active_admin_namespace.root?
|
50
|
+
parts << active_admin_namespace.comments_registration_name.underscore.pluralize
|
51
|
+
parts << 'path'
|
52
|
+
send parts.join '_'
|
64
53
|
end
|
65
54
|
|
66
55
|
def build_comment_form
|
67
|
-
self << active_admin_form_for(ActiveAdmin::Comment.new, :url => comment_form_url
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
56
|
+
self << active_admin_form_for(ActiveAdmin::Comment.new, :url => comment_form_url) do |f|
|
57
|
+
f.inputs do
|
58
|
+
f.input :resource_type, :as => :hidden, :input_html => { :value => ActiveAdmin::Comment.resource_type(@resource) }
|
59
|
+
f.input :resource_id, :as => :hidden, :input_html => { :value => @resource.id }
|
60
|
+
f.input :body, :label => false, :input_html => { :size => '80x8' }
|
72
61
|
end
|
73
|
-
|
74
|
-
|
62
|
+
f.actions do
|
63
|
+
f.action :submit, :label => I18n.t('active_admin.comments.add')
|
75
64
|
end
|
76
65
|
end
|
77
66
|
end
|
@@ -7,7 +7,7 @@ module ActiveAdmin
|
|
7
7
|
# csv_builder.column :id
|
8
8
|
# csv_builder.column("Name") { |resource| resource.full_name }
|
9
9
|
#
|
10
|
-
# csv_builder = CSVBuilder.new :
|
10
|
+
# csv_builder = CSVBuilder.new :col_sep => ";"
|
11
11
|
# csv_builder.column :id
|
12
12
|
#
|
13
13
|
#
|
@@ -25,12 +25,10 @@ module ActiveAdmin
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
attr_reader :columns, :
|
28
|
+
attr_reader :columns, :options
|
29
29
|
|
30
30
|
def initialize(options={}, &block)
|
31
|
-
@columns
|
32
|
-
@column_separator = options.delete(:separator)
|
33
|
-
@options = options.delete(:options)
|
31
|
+
@columns, @options = [], options
|
34
32
|
instance_eval &block if block_given?
|
35
33
|
end
|
36
34
|
|
@@ -41,7 +39,7 @@ module ActiveAdmin
|
|
41
39
|
|
42
40
|
class Column
|
43
41
|
attr_reader :name, :data
|
44
|
-
|
42
|
+
|
45
43
|
def initialize(name, block = nil)
|
46
44
|
@name = name.is_a?(Symbol) ? name.to_s.titleize : name
|
47
45
|
@data = block || name.to_sym
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module ActiveAdmin
|
2
2
|
module Deprecation
|
3
|
-
|
3
|
+
module_function
|
4
4
|
|
5
5
|
def warn(message, callstack = caller)
|
6
6
|
ActiveSupport::Deprecation.warn "Active Admin: #{message}", callstack
|
@@ -23,8 +23,8 @@ module ActiveAdmin
|
|
23
23
|
# end
|
24
24
|
#
|
25
25
|
def deprecate(klass, method, message)
|
26
|
-
klass.class_eval <<-EOC, __FILE__, __LINE__
|
27
|
-
alias_method :
|
26
|
+
klass.class_eval <<-EOC, __FILE__, __LINE__ + 1
|
27
|
+
alias_method :deprecated_#{method}, :#{method}
|
28
28
|
def #{method}(*args)
|
29
29
|
ActiveAdmin::Deprecation.warn('#{message}', caller)
|
30
30
|
send(:deprecated_#{method}, *args)
|
data/lib/active_admin/dsl.rb
CHANGED
@@ -2,7 +2,7 @@ module ActiveAdmin
|
|
2
2
|
|
3
3
|
#
|
4
4
|
# The Active Admin DSL. This class is where all the registration blocks
|
5
|
-
# are instance eval'd. This is the central place for the API given to
|
5
|
+
# are instance eval'd. This is the central place for the API given to
|
6
6
|
# users of Active Admin
|
7
7
|
#
|
8
8
|
class DSL
|
@@ -21,7 +21,7 @@ module ActiveAdmin
|
|
21
21
|
# modify options:
|
22
22
|
#
|
23
23
|
# eg:
|
24
|
-
#
|
24
|
+
#
|
25
25
|
# ActiveAdmin.register Post do
|
26
26
|
# config.sort_order = "id_desc"
|
27
27
|
# end
|
@@ -89,7 +89,7 @@ module ActiveAdmin
|
|
89
89
|
|
90
90
|
# Add a new batch action item to the resource
|
91
91
|
# Provide a symbol/string to register the action, options, & block to execute on request
|
92
|
-
#
|
92
|
+
#
|
93
93
|
# To unregister an existing action, just provide the symbol & pass false as the second param
|
94
94
|
#
|
95
95
|
# @param [Symbol or String] title
|
@@ -100,13 +100,13 @@ module ActiveAdmin
|
|
100
100
|
#
|
101
101
|
def batch_action(title, options = {}, &block)
|
102
102
|
# Create symbol & title information
|
103
|
-
if title.is_a?
|
103
|
+
if title.is_a? String
|
104
104
|
sym = title.titleize.gsub(' ', '').underscore.to_sym
|
105
105
|
else
|
106
106
|
sym = title
|
107
107
|
title = sym.to_s.titleize
|
108
108
|
end
|
109
|
-
|
109
|
+
|
110
110
|
# Either add/remove the batch action
|
111
111
|
unless options == false
|
112
112
|
config.add_batch_action( sym, title, options, &block )
|
data/lib/active_admin/engine.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module ActiveAdmin
|
2
|
-
class Engine < Rails::Engine
|
2
|
+
class Engine < ::Rails::Engine
|
3
3
|
if Rails.version > "3.1"
|
4
4
|
initializer "ActiveAdmin precompile hook", :group => :all do |app|
|
5
5
|
app.config.assets.precompile += %w(active_admin.js active_admin.css active_admin/print.css)
|
data/lib/active_admin/filters.rb
CHANGED
@@ -4,37 +4,40 @@ module ActiveAdmin
|
|
4
4
|
# This form builder defines methods to build filter forms such
|
5
5
|
# as the one found in the sidebar of the index page of a standard resource.
|
6
6
|
class FormBuilder < ::ActiveAdmin::FormBuilder
|
7
|
+
include ::ActiveAdmin::Filters::FormtasticAddons
|
8
|
+
|
9
|
+
def initialize(*args)
|
10
|
+
@use_form_buffer = true # force ActiveAdmin::FormBuilder to use the form buffer
|
11
|
+
super
|
12
|
+
end
|
7
13
|
|
8
14
|
def filter(method, options = {})
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
form_buffers.last << content.html_safe if content
|
15
|
+
if method.present? && options[:as] ||= default_input_type(method)
|
16
|
+
input(method, options)
|
17
|
+
end
|
13
18
|
end
|
14
19
|
|
15
20
|
protected
|
16
21
|
|
17
|
-
# Returns the default filter type for a given attribute
|
22
|
+
# Returns the default filter type for a given attribute. If you want
|
23
|
+
# to use a custom search method, you have to specify the type yourself.
|
18
24
|
def default_input_type(method, options = {})
|
19
|
-
if
|
25
|
+
if method =~ /_(contains|starts_with|ends_with)\z/
|
26
|
+
:string
|
27
|
+
elsif reflection_for(method) || polymorphic_foreign_type?(method)
|
28
|
+
:select
|
29
|
+
elsif column = column_for(method)
|
20
30
|
case column.type
|
21
31
|
when :date, :datetime
|
22
|
-
|
32
|
+
:date_range
|
23
33
|
when :string, :text
|
24
|
-
|
25
|
-
when :integer
|
26
|
-
|
27
|
-
return :numeric
|
28
|
-
when :float, :decimal
|
29
|
-
return :numeric
|
34
|
+
:string
|
35
|
+
when :integer, :float, :decimal
|
36
|
+
:numeric
|
30
37
|
when :boolean
|
31
|
-
|
38
|
+
:boolean
|
32
39
|
end
|
33
40
|
end
|
34
|
-
|
35
|
-
if (reflection = reflection_for(method))
|
36
|
-
return :select if reflection.macro == :belongs_to && !reflection.options[:polymorphic]
|
37
|
-
end
|
38
41
|
end
|
39
42
|
|
40
43
|
def custom_input_class_name(as)
|
@@ -45,17 +48,6 @@ module ActiveAdmin
|
|
45
48
|
"ActiveAdmin::Inputs::Filter#{as.to_s.camelize}Input"
|
46
49
|
end
|
47
50
|
|
48
|
-
# Returns the column for an attribute on the object being searched
|
49
|
-
# if it exists. Otherwise returns nil
|
50
|
-
def column_for(method)
|
51
|
-
@object.base.columns_hash[method.to_s] if @object.base.respond_to?(:columns_hash)
|
52
|
-
end
|
53
|
-
|
54
|
-
# Returns the association reflection for the method if it exists
|
55
|
-
def reflection_for(method)
|
56
|
-
@object.base.reflect_on_association(method) if @object.base.respond_to?(:reflect_on_association)
|
57
|
-
end
|
58
|
-
|
59
51
|
end
|
60
52
|
|
61
53
|
|
@@ -64,26 +56,27 @@ module ActiveAdmin
|
|
64
56
|
|
65
57
|
# Helper method to render a filter form
|
66
58
|
def active_admin_filters_form_for(search, filters, options = {})
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
options
|
73
|
-
|
59
|
+
defaults = { :builder => ActiveAdmin::Filters::FormBuilder,
|
60
|
+
:url => collection_path,
|
61
|
+
:html => {:class => 'filter_form'} }
|
62
|
+
required = { :html => {:method => :get},
|
63
|
+
:as => :q }
|
64
|
+
options = defaults.deep_merge(options).deep_merge(required)
|
65
|
+
|
74
66
|
form_for search, options do |f|
|
75
67
|
filters.group_by{ |o| o[:attribute] }.each do |attribute, array|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
68
|
+
opts = array.last # grab last-defined `filter` call from DSL
|
69
|
+
should = opts.delete(:if) || proc{ true }
|
70
|
+
shouldnt = opts.delete(:unless) || proc{ false }
|
71
|
+
|
72
|
+
if call_method_or_proc_on(self, should) && !call_method_or_proc_on(self, shouldnt)
|
73
|
+
f.filter attribute, opts
|
81
74
|
end
|
82
75
|
end
|
83
76
|
|
84
77
|
buttons = content_tag :div, :class => "buttons" do
|
85
|
-
f.submit(I18n.t('active_admin.filter')) +
|
86
|
-
|
78
|
+
f.submit(I18n.t('active_admin.filters.buttons.filter')) +
|
79
|
+
link_to(I18n.t('active_admin.filters.buttons.clear'), '#', :class => 'clear_filters_btn') +
|
87
80
|
hidden_field_tags_for(params, :except => [:q, :page])
|
88
81
|
end
|
89
82
|
|