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
@@ -4,16 +4,16 @@ module ActiveAdmin
|
|
4
4
|
|
5
5
|
# Returns an array of links to use in a breadcrumb
|
6
6
|
def breadcrumb_links(path = request.path)
|
7
|
-
parts = path[1..-1].split('/')
|
8
|
-
parts.pop
|
7
|
+
parts = path[1..-1].split('/') # remove leading "/" and split up the URL
|
8
|
+
parts.pop # remove last since it's used as the page title
|
9
9
|
|
10
10
|
parts.each_with_index.map do |part, index|
|
11
|
-
#
|
12
|
-
#
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
name
|
11
|
+
# 1. try using `display_name` if we can locate a DB object
|
12
|
+
# 2. try using the model name translation
|
13
|
+
# 3. default to calling `titlecase` on the URL fragment
|
14
|
+
if part =~ /\A(\d+|[a-f0-9]{24})\z/ && parts[index-1]
|
15
|
+
config = active_admin_config.belongs_to_config.try(:target) || active_admin_config
|
16
|
+
name = display_name config.find_resource(part)
|
17
17
|
end
|
18
18
|
name ||= I18n.t "activerecord.models.#{part.singularize}", :count => 1.1, :default => part.titlecase
|
19
19
|
|
@@ -2,16 +2,25 @@ module ActiveAdmin
|
|
2
2
|
module ViewHelpers
|
3
3
|
module DisplayHelper
|
4
4
|
|
5
|
+
# Attempts to call any known display name methods on the resource.
|
6
|
+
# See the setting in `application.rb` for the list of methods and their priority.
|
7
|
+
def display_name(resource)
|
8
|
+
resource.send display_name_method_for resource if resource
|
9
|
+
end
|
10
|
+
|
11
|
+
# Looks up and caches the first available display name method.
|
5
12
|
def display_name_method_for(resource)
|
6
13
|
@@display_name_methods_cache ||= {}
|
7
|
-
@@display_name_methods_cache[resource.class] ||=
|
8
|
-
active_admin_application.display_name_methods
|
14
|
+
@@display_name_methods_cache[resource.class] ||= begin
|
15
|
+
methods = active_admin_application.display_name_methods - association_methods_for(resource)
|
16
|
+
methods.detect{ |method| resource.respond_to? method }
|
17
|
+
end
|
9
18
|
end
|
10
19
|
|
11
|
-
#
|
12
|
-
|
13
|
-
|
14
|
-
resource.
|
20
|
+
# To prevent conflicts, we exclude any methods that happen to be associations.
|
21
|
+
def association_methods_for(resource)
|
22
|
+
return [] unless resource.class.respond_to? :reflect_on_all_associations
|
23
|
+
resource.class.reflect_on_all_associations.map(&:name)
|
15
24
|
end
|
16
25
|
|
17
26
|
# Return a pretty string for any object
|
@@ -13,10 +13,10 @@ module ActiveAdmin
|
|
13
13
|
@formats ||= [:csv, :xml, :json]
|
14
14
|
@formats.clone
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
# Adds a mime type extension to the list of available formats.
|
18
18
|
# You must register the extension prior to adding it to the list
|
19
|
-
# of avilable formats. This should be used by plugins that want
|
19
|
+
# of avilable formats. This should be used by plugins that want
|
20
20
|
# to add additional formats to the download format links.
|
21
21
|
# @param [Symbol] extension the mime extension to add
|
22
22
|
# @return [Array] A copy of the updated formats array.
|
@@ -1,10 +1,15 @@
|
|
1
1
|
module ActiveAdmin
|
2
2
|
module ViewHelpers
|
3
3
|
module FormHelper
|
4
|
-
|
4
|
+
|
5
5
|
def active_admin_form_for(resource, options = {}, &block)
|
6
6
|
options = Marshal.load( Marshal.dump(options) )
|
7
7
|
options[:builder] ||= ActiveAdmin::FormBuilder
|
8
|
+
|
9
|
+
if ! options.fetch(:decorate, true)
|
10
|
+
resource = resource.model
|
11
|
+
end
|
12
|
+
|
8
13
|
semantic_form_for resource, options, &block
|
9
14
|
end
|
10
15
|
|
@@ -41,7 +41,7 @@ module MethodOrProcHelper
|
|
41
41
|
# proc = Proc.new{|s| s.size }
|
42
42
|
# call_method_or_proc_on(@my_obj, proc, :exec => false)
|
43
43
|
#
|
44
|
-
# You can pass along any necessary arguments to the method / Proc as arguments. For
|
44
|
+
# You can pass along any necessary arguments to the method / Proc as arguments. For
|
45
45
|
# example:
|
46
46
|
#
|
47
47
|
# call_method_or_proc_on(@my_obj, :find, 1) #=> @my_obj.find(1)
|
@@ -76,16 +76,16 @@ module MethodOrProcHelper
|
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
|
-
# This method is different from the others in that it calls `
|
79
|
+
# This method is different from the others in that it calls `instance_exec` on the reciever,
|
80
80
|
# passing it the proc. This evaluates the proc in the context of the reciever, thus changing
|
81
81
|
# what `self` means inside the proc.
|
82
|
-
def render_in_context(context, obj)
|
82
|
+
def render_in_context(context, obj, *args)
|
83
83
|
context ||= self # default to `self`
|
84
84
|
case obj
|
85
85
|
when Proc
|
86
|
-
context.instance_exec &obj
|
86
|
+
context.instance_exec *args, &obj
|
87
87
|
when Symbol
|
88
|
-
context.send obj
|
88
|
+
context.send obj, *args
|
89
89
|
else
|
90
90
|
obj
|
91
91
|
end
|
@@ -5,16 +5,16 @@ module ActiveAdmin
|
|
5
5
|
# Build an ActionListPopover
|
6
6
|
class ActionListPopover < ActiveAdmin::Views::Popover
|
7
7
|
builder_method :action_list_popover
|
8
|
-
|
9
|
-
|
8
|
+
|
9
|
+
|
10
10
|
def build(*args, &block)
|
11
11
|
@contents = ul :class => "popover_contents"
|
12
|
-
|
12
|
+
|
13
13
|
options = args.extract_options!
|
14
|
-
|
14
|
+
|
15
15
|
super(options)
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
def action(title, url, *args)
|
19
19
|
options = args.extract_options!
|
20
20
|
within @contents do
|
@@ -26,4 +26,4 @@ module ActiveAdmin
|
|
26
26
|
|
27
27
|
end
|
28
28
|
end
|
29
|
-
end
|
29
|
+
end
|
@@ -49,20 +49,17 @@ module ActiveAdmin
|
|
49
49
|
span I18n.t('active_admin.empty'), :class => "empty"
|
50
50
|
end
|
51
51
|
|
52
|
-
def content_for(
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
else
|
57
|
-
content_for_attribute(attr_or_proc)
|
58
|
-
end
|
59
|
-
value = pretty_format(value)
|
60
|
-
value == "" || value.nil? ? empty_value : value
|
52
|
+
def content_for(attr)
|
53
|
+
previous = current_arbre_element.to_s
|
54
|
+
value = pretty_format find_attr_value attr
|
55
|
+
value.blank? && previous == current_arbre_element.to_s ? empty_value : value
|
61
56
|
end
|
62
57
|
|
63
|
-
def
|
64
|
-
if attr.
|
65
|
-
|
58
|
+
def find_attr_value(attr)
|
59
|
+
if attr.is_a?(Proc)
|
60
|
+
attr.call(@record)
|
61
|
+
elsif attr.to_s[/\A(.+)_id\z/] && @record.respond_to?($1.to_sym)
|
62
|
+
@record.send($1.to_sym)
|
66
63
|
else
|
67
64
|
@record.send(attr.to_sym)
|
68
65
|
end
|
@@ -3,15 +3,15 @@ module ActiveAdmin
|
|
3
3
|
# Build a Blank Slate
|
4
4
|
class BlankSlate < ActiveAdmin::Component
|
5
5
|
builder_method :blank_slate
|
6
|
-
|
6
|
+
|
7
7
|
def default_class_name
|
8
8
|
'blank_slate_container'
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
def build(content)
|
12
12
|
super(span(content.html_safe, :class => "blank_slate"))
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
end
|
16
16
|
end
|
17
|
-
end
|
17
|
+
end
|
@@ -9,7 +9,7 @@ module ActiveAdmin
|
|
9
9
|
#
|
10
10
|
# == Simple Columns
|
11
11
|
#
|
12
|
-
# To display columns, use the #columns method. Within the block, call the
|
12
|
+
# To display columns, use the #columns method. Within the block, call the
|
13
13
|
# #column method to create a new column.
|
14
14
|
#
|
15
15
|
# To createa a two column layout:
|
@@ -20,7 +20,7 @@ module ActiveAdmin
|
|
20
20
|
|
21
21
|
# Builds the links for presenting different index views to the user
|
22
22
|
#
|
23
|
-
# @param [Array] index_classes The class constants that represent index page presenters
|
23
|
+
# @param [Array] index_classes The class constants that represent index page presenters
|
24
24
|
def build(index_classes)
|
25
25
|
unless current_filter_search_empty?
|
26
26
|
index_classes.each do |index_class|
|
@@ -36,14 +36,15 @@ module ActiveAdmin
|
|
36
36
|
# download_links => Download links override (false or [:csv, :pdf])
|
37
37
|
#
|
38
38
|
def build(collection, options = {})
|
39
|
-
@collection
|
39
|
+
@collection = collection
|
40
40
|
@param_name = options.delete(:param_name)
|
41
41
|
@download_links = options.delete(:download_links)
|
42
|
+
@display_total = options.delete(:pagination_total) { true }
|
42
43
|
|
43
44
|
unless collection.respond_to?(:num_pages)
|
44
45
|
raise(StandardError, "Collection is not a paginated scope. Set collection.page(params[:page]).per(10) before calling :paginated_collection.")
|
45
46
|
end
|
46
|
-
|
47
|
+
|
47
48
|
@contents = div(:class => "paginated_collection_contents")
|
48
49
|
build_pagination_with_formats(options)
|
49
50
|
@built = true
|
@@ -83,30 +84,37 @@ module ActiveAdmin
|
|
83
84
|
|
84
85
|
include ::ActiveAdmin::Helpers::Collection
|
85
86
|
include ::ActiveAdmin::ViewHelpers::DownloadFormatLinksHelper
|
86
|
-
|
87
|
+
|
87
88
|
# modified from will_paginate
|
88
89
|
def page_entries_info(options = {})
|
89
90
|
if options[:entry_name]
|
90
|
-
entry_name
|
91
|
+
entry_name = options[:entry_name]
|
91
92
|
entries_name = options[:entries_name] || entry_name.pluralize
|
92
93
|
elsif collection_is_empty?
|
93
|
-
entry_name
|
94
|
-
entries_name = I18n.
|
94
|
+
entry_name = I18n.t "active_admin.pagination.entry", :count => 1, :default => 'entry'
|
95
|
+
entries_name = I18n.t "active_admin.pagination.entry", :count => 2, :default => 'entries'
|
95
96
|
else
|
96
|
-
|
97
|
-
|
97
|
+
key = "activerecord.models." + collection.first.class.model_name.i18n_key.to_s
|
98
|
+
entry_name = I18n.translate key, :count => 1, :default => collection.first.class.name.underscore.sub('_', ' ')
|
99
|
+
entries_name = I18n.translate key, :count => collection.size, :default => entry_name.pluralize
|
98
100
|
end
|
99
101
|
|
100
102
|
if collection.num_pages < 2
|
101
103
|
case collection_size
|
102
|
-
when 0; I18n.t('active_admin.pagination.empty',
|
103
|
-
when 1; I18n.t('active_admin.pagination.one',
|
104
|
+
when 0; I18n.t('active_admin.pagination.empty', :model => entries_name)
|
105
|
+
when 1; I18n.t('active_admin.pagination.one', :model => entry_name)
|
104
106
|
else; I18n.t('active_admin.pagination.one_page', :model => entries_name, :n => collection.total_count)
|
105
107
|
end
|
106
108
|
else
|
107
109
|
offset = (collection.current_page - 1) * collection.limit_value
|
108
|
-
|
109
|
-
|
110
|
+
if @display_total
|
111
|
+
total = collection.total_count
|
112
|
+
I18n.t 'active_admin.pagination.multiple', :model => entries_name, :total => total,
|
113
|
+
:from => offset + 1, :to => offset + collection_size
|
114
|
+
else
|
115
|
+
I18n.t 'active_admin.pagination.multiple_without_total', :model => entries_name,
|
116
|
+
:from => offset + 1, :to => offset + collection_size
|
117
|
+
end
|
110
118
|
end
|
111
119
|
end
|
112
120
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'active_admin/helpers/collection'
|
2
|
+
require 'active_admin/view_helpers/method_or_proc_helper'
|
2
3
|
|
3
4
|
module ActiveAdmin
|
4
5
|
module Views
|
@@ -51,7 +52,7 @@ module ActiveAdmin
|
|
51
52
|
if params[:scope]
|
52
53
|
params[:scope] == scope.id
|
53
54
|
else
|
54
|
-
active_admin_config.default_scope == scope
|
55
|
+
active_admin_config.default_scope(self) == scope
|
55
56
|
end
|
56
57
|
end
|
57
58
|
|
@@ -4,7 +4,7 @@ module ActiveAdmin
|
|
4
4
|
class SidebarSection < Panel
|
5
5
|
builder_method :sidebar_section
|
6
6
|
|
7
|
-
# Takes a ActiveAdmin::
|
7
|
+
# Takes a ActiveAdmin::SidebarSection instance
|
8
8
|
def build(section)
|
9
9
|
@section = section
|
10
10
|
super(@section.title, :icon => @section.icon)
|
@@ -29,7 +29,7 @@ module ActiveAdmin
|
|
29
29
|
#
|
30
30
|
# status_tag('active', :ok, :class => 'important', :id => 'status_123', :label => 'on')
|
31
31
|
# # => <span class='status_tag active ok important' id='status_123'>on</span>
|
32
|
-
#
|
32
|
+
#
|
33
33
|
def build(*args)
|
34
34
|
options = args.extract_options!
|
35
35
|
status = args[0]
|
@@ -20,11 +20,11 @@ module ActiveAdmin
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def build_global_navigation
|
23
|
-
insert_tag view_factory.global_navigation, @menu, :class => 'header-item tabs'
|
23
|
+
insert_tag view_factory.global_navigation, @menu, :class => 'header-item tabs'
|
24
24
|
end
|
25
25
|
|
26
26
|
def build_utility_navigation
|
27
|
-
insert_tag view_factory.
|
27
|
+
insert_tag view_factory.utility_navigation, @utility_menu, :id => "utility_nav", :class => 'header-item tabs'
|
28
28
|
end
|
29
29
|
|
30
30
|
end
|
@@ -67,7 +67,7 @@ module ActiveAdmin
|
|
67
67
|
@page_presenter = page_presenter
|
68
68
|
@collection = collection
|
69
69
|
|
70
|
-
# Call the block passed in. This will set the
|
70
|
+
# Call the block passed in. This will set the
|
71
71
|
# title and body methods
|
72
72
|
instance_eval &page_presenter.block if page_presenter.block
|
73
73
|
|
@@ -117,7 +117,9 @@ module ActiveAdmin
|
|
117
117
|
def build_title(post)
|
118
118
|
if @title
|
119
119
|
h3 do
|
120
|
-
|
120
|
+
a(:href => resource_path(post)) do
|
121
|
+
render_method_on_post_or_call_proc post, @title
|
122
|
+
end
|
121
123
|
end
|
122
124
|
else
|
123
125
|
h3 do
|
@@ -128,7 +130,18 @@ module ActiveAdmin
|
|
128
130
|
|
129
131
|
def build_body(post)
|
130
132
|
if @body
|
131
|
-
div
|
133
|
+
div :class => 'content' do
|
134
|
+
render_method_on_post_or_call_proc post, @body
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
def render_method_on_post_or_call_proc(post, proc)
|
140
|
+
case proc
|
141
|
+
when String,Symbol
|
142
|
+
post.send proc
|
143
|
+
else
|
144
|
+
instance_exec post, &proc
|
132
145
|
end
|
133
146
|
end
|
134
147
|
|
@@ -69,7 +69,7 @@ module ActiveAdmin
|
|
69
69
|
# If a column is defined using a block, you must pass the key to turn on sorting. The key
|
70
70
|
# is the attribute which gets used to sort objects using Active Record.
|
71
71
|
#
|
72
|
-
# By default, this is the column on the resource's table that the attribute corresponds to.
|
72
|
+
# By default, this is the column on the resource's table that the attribute corresponds to.
|
73
73
|
# Otherwise, any attribute that the resource collection responds to can be used.
|
74
74
|
#
|
75
75
|
# index do
|
@@ -154,7 +154,7 @@ module ActiveAdmin
|
|
154
154
|
|
155
155
|
# Display a column for the id
|
156
156
|
def id_column
|
157
|
-
column(resource_class.human_attribute_name(resource_class.primary_key), :sortable => resource_class.primary_key) do |resource|
|
157
|
+
column(resource_class.human_attribute_name(resource_class.primary_key), :sortable => resource_class.primary_key) do |resource|
|
158
158
|
link_to resource.id, resource_path(resource), :class => "resource_id_link"
|
159
159
|
end
|
160
160
|
end
|
@@ -23,13 +23,18 @@ module ActiveAdmin
|
|
23
23
|
def build_active_admin_head
|
24
24
|
within @head do
|
25
25
|
insert_tag Arbre::HTML::Title, [title, render_or_call_method_or_proc_on(self, active_admin_application.site_title)].join(" | ")
|
26
|
-
active_admin_application.stylesheets.each do |style|
|
27
|
-
text_node
|
26
|
+
active_admin_application.stylesheets.each do |style, options|
|
27
|
+
text_node stylesheet_link_tag(style, options).html_safe
|
28
28
|
end
|
29
29
|
|
30
30
|
active_admin_application.javascripts.each do |path|
|
31
|
-
|
31
|
+
text_node(javascript_include_tag(path))
|
32
32
|
end
|
33
|
+
|
34
|
+
if active_admin_application.favicon
|
35
|
+
text_node(favicon_link_tag(active_admin_application.favicon))
|
36
|
+
end
|
37
|
+
|
33
38
|
text_node csrf_meta_tag
|
34
39
|
end
|
35
40
|
end
|
@@ -5,8 +5,8 @@ module ActiveAdmin
|
|
5
5
|
class Form < Base
|
6
6
|
|
7
7
|
def title
|
8
|
-
I18n.t("active_admin.#{params[:action]}_model",
|
9
|
-
|
8
|
+
assigns[:page_title] || I18n.t("active_admin.#{params[:action]}_model",
|
9
|
+
:model => active_admin_config.resource_label)
|
10
10
|
end
|
11
11
|
|
12
12
|
def form_presenter
|