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
@@ -2,54 +2,9 @@ module ActiveAdmin
|
|
2
2
|
module Inputs
|
3
3
|
class FilterNumericInput < ::Formtastic::Inputs::NumberInput
|
4
4
|
include FilterBase
|
5
|
+
include FilterBase::SearchMethodSelect
|
5
6
|
|
6
|
-
|
7
|
-
input_wrapping do
|
8
|
-
[ label_html,
|
9
|
-
select_html,
|
10
|
-
" ",
|
11
|
-
input_html
|
12
|
-
].join("\n").html_safe
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def input_html
|
17
|
-
builder.text_field current_filter, input_html_options
|
18
|
-
end
|
19
|
-
|
20
|
-
def input_html_options
|
21
|
-
{ :size => 10, :id => "#{method}_numeric" }
|
22
|
-
end
|
23
|
-
|
24
|
-
def select_html
|
25
|
-
template.select_tag '', select_options, select_html_options
|
26
|
-
end
|
27
|
-
|
28
|
-
def select_options
|
29
|
-
template.options_for_select(filters, current_filter)
|
30
|
-
end
|
31
|
-
|
32
|
-
def select_html_options
|
33
|
-
{ :onchange => "document.getElementById('#{method}_numeric').name = 'q[' + this.value + ']';" }
|
34
|
-
end
|
35
|
-
|
36
|
-
# Returns the scope for which we are currently searching. If no search is available
|
37
|
-
# it returns the first scope
|
38
|
-
def current_filter
|
39
|
-
filters[1..-1].inject(filters.first){|a,b| @object.send(b[1].to_sym) ? b : a }[1]
|
40
|
-
end
|
41
|
-
|
42
|
-
def filters
|
43
|
-
(options[:filters] || default_filters).collect do |scope|
|
44
|
-
[scope[0], [method, scope[1]].join("_")]
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def default_filters
|
49
|
-
[ [I18n.t('active_admin.equal_to'), 'eq'],
|
50
|
-
[I18n.t('active_admin.greater_than'), 'gt'],
|
51
|
-
[I18n.t('active_admin.less_than'), 'lt'] ]
|
52
|
-
end
|
7
|
+
filter :equals, :greater_than, :less_than
|
53
8
|
end
|
54
9
|
end
|
55
10
|
end
|
@@ -3,25 +3,47 @@ module ActiveAdmin
|
|
3
3
|
class FilterSelectInput < ::Formtastic::Inputs::SelectInput
|
4
4
|
include FilterBase
|
5
5
|
|
6
|
+
# If MetaSearch already responds to the given method, just use it.
|
7
|
+
#
|
8
|
+
# Otherwise:
|
9
|
+
# When it's a HABTM or has_many association, Formtastic builds "object_ids".
|
10
|
+
# That doesn't fit our scenario, so we override it here.
|
6
11
|
def input_name
|
7
|
-
|
12
|
+
return method if @object.respond_to? method
|
13
|
+
|
14
|
+
name = method.to_s
|
15
|
+
name.concat '_id' if reflection
|
16
|
+
name.concat multiple? ? '_in' : '_eq'
|
17
|
+
end
|
18
|
+
|
19
|
+
# Provide the AA translation to the blank input field.
|
20
|
+
def include_blank
|
21
|
+
I18n.t 'active_admin.any' if super
|
8
22
|
end
|
9
23
|
|
10
|
-
|
11
|
-
|
24
|
+
# was "#{object_name}[#{association_primary_key}]"
|
25
|
+
def input_html_options_name
|
26
|
+
"#{object_name}[#{input_name}]"
|
12
27
|
end
|
13
28
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
29
|
+
# Would normally return true for has_many and HABTM, which would subsequently
|
30
|
+
# cause the select field to be multi-select instead of a dropdown.
|
31
|
+
def multiple_by_association?
|
32
|
+
false
|
33
|
+
end
|
34
|
+
|
35
|
+
# Provides an efficient default lookup query if the attribute is a DB column.
|
36
|
+
def collection
|
37
|
+
unless Rails::VERSION::MAJOR == 3 && Rails::VERSION::MINOR < 2
|
38
|
+
return pluck_column if !options[:collection] && column_for(method)
|
19
39
|
end
|
40
|
+
super
|
20
41
|
end
|
21
42
|
|
22
|
-
def
|
23
|
-
{}
|
43
|
+
def pluck_column
|
44
|
+
@object.base.reorder("#{method} asc").uniq.pluck method
|
24
45
|
end
|
46
|
+
|
25
47
|
end
|
26
48
|
end
|
27
49
|
end
|
@@ -2,25 +2,23 @@ module ActiveAdmin
|
|
2
2
|
module Inputs
|
3
3
|
class FilterStringInput < ::Formtastic::Inputs::StringInput
|
4
4
|
include FilterBase
|
5
|
+
include FilterBase::SearchMethodSelect
|
5
6
|
|
7
|
+
filter :contains, :equals, :starts_with, :ends_with
|
8
|
+
|
9
|
+
# If the filter method includes a search condition, build a normal string search field.
|
10
|
+
# Else, build a search field with a companion dropdown to choose a search condition from.
|
6
11
|
def to_html
|
7
|
-
|
8
|
-
|
9
|
-
|
12
|
+
if @object.respond_to? method
|
13
|
+
input_wrapping do
|
14
|
+
label_html <<
|
15
|
+
builder.text_field(method, input_html_options)
|
16
|
+
end
|
17
|
+
else
|
18
|
+
super # SearchMethodSelect#to_html
|
10
19
|
end
|
11
20
|
end
|
12
21
|
|
13
|
-
def label_text
|
14
|
-
I18n.t('active_admin.search_field', :field => super)
|
15
|
-
end
|
16
|
-
|
17
|
-
def input_name
|
18
|
-
method.to_s.match(metasearch_conditions) ? method : "#{method}_contains"
|
19
|
-
end
|
20
|
-
|
21
|
-
def metasearch_conditions
|
22
|
-
/starts_with|ends_with/
|
23
|
-
end
|
24
22
|
end
|
25
23
|
end
|
26
24
|
end
|
@@ -1,10 +1,7 @@
|
|
1
|
-
require 'active_admin/helpers/settings'
|
2
1
|
require 'active_admin/resource_collection'
|
3
2
|
|
4
3
|
module ActiveAdmin
|
5
4
|
|
6
|
-
class ResourceMismatchError < StandardError; end
|
7
|
-
|
8
5
|
# Namespaces are the basic organizing principle for resources within Active Admin
|
9
6
|
#
|
10
7
|
# Each resource is registered into a namespace which defines:
|
@@ -13,7 +10,7 @@ module ActiveAdmin
|
|
13
10
|
# * the menu which gets displayed (other resources in the same namespace)
|
14
11
|
#
|
15
12
|
# For example:
|
16
|
-
#
|
13
|
+
#
|
17
14
|
# ActiveAdmin.register Post, :namespace => :admin
|
18
15
|
#
|
19
16
|
# Will register the Post model into the "admin" namespace. This will namespace the
|
@@ -24,12 +21,10 @@ module ActiveAdmin
|
|
24
21
|
#
|
25
22
|
# ActiveAdmin.register Post, :namespace => false
|
26
23
|
#
|
27
|
-
# This will register the resource to an instantiated namespace called :root. The
|
24
|
+
# This will register the resource to an instantiated namespace called :root. The
|
28
25
|
# resource will be accessible from "/posts" and the controller will be PostsController.
|
29
26
|
#
|
30
27
|
class Namespace
|
31
|
-
include Settings
|
32
|
-
|
33
28
|
RegisterEvent = 'active_admin.namespace.register'.freeze
|
34
29
|
|
35
30
|
attr_reader :application, :resources, :name, :menus
|
@@ -39,12 +34,11 @@ module ActiveAdmin
|
|
39
34
|
@name = name.to_s.underscore.to_sym
|
40
35
|
@resources = ResourceCollection.new
|
41
36
|
register_module unless root?
|
42
|
-
generate_dashboard_controller
|
43
37
|
build_menu_collection
|
44
38
|
end
|
45
39
|
|
46
|
-
# Register a resource into this namespace. The preffered method to access this is to
|
47
|
-
# use the global registration ActiveAdmin.register which delegates to the proper
|
40
|
+
# Register a resource into this namespace. The preffered method to access this is to
|
41
|
+
# use the global registration ActiveAdmin.register which delegates to the proper
|
48
42
|
# namespace instance.
|
49
43
|
def register(resource_class, options = {}, &block)
|
50
44
|
config = find_or_build_resource(resource_class, options)
|
@@ -54,9 +48,6 @@ module ActiveAdmin
|
|
54
48
|
parse_registration_block(config, &block) if block_given?
|
55
49
|
reset_menu!
|
56
50
|
|
57
|
-
# Ensure that the dashboard is generated
|
58
|
-
generate_dashboard_controller
|
59
|
-
|
60
51
|
# Dispatch a registration event
|
61
52
|
ActiveAdmin::Event.dispatch ActiveAdmin::Resource::RegisterEvent, config
|
62
53
|
|
@@ -82,7 +73,7 @@ module ActiveAdmin
|
|
82
73
|
# Returns the name of the module if required. Will be nil if none
|
83
74
|
# is required.
|
84
75
|
#
|
85
|
-
# eg:
|
76
|
+
# eg:
|
86
77
|
# Namespace.new(:admin).module_name # => 'Admin'
|
87
78
|
# Namespace.new(:root).module_name # => nil
|
88
79
|
#
|
@@ -91,21 +82,15 @@ module ActiveAdmin
|
|
91
82
|
@module_name ||= name.to_s.camelize
|
92
83
|
end
|
93
84
|
|
94
|
-
# Returns the name of the dashboard controller for this namespace
|
95
|
-
def dashboard_controller_name
|
96
|
-
[module_name, "DashboardController"].compact.join("::")
|
97
|
-
end
|
98
|
-
|
99
85
|
# Unload all the registered resources for this namespace
|
100
86
|
def unload!
|
101
87
|
unload_resources!
|
102
|
-
unload_dashboard!
|
103
88
|
reset_menu!
|
104
89
|
end
|
105
90
|
|
106
91
|
# Returns the first registered ActiveAdmin::Resource instance for a given class
|
107
92
|
def resource_for(klass)
|
108
|
-
resources
|
93
|
+
resources[klass]
|
109
94
|
end
|
110
95
|
|
111
96
|
# Override from ActiveAdmin::Settings to inherit default attributes
|
@@ -161,10 +146,6 @@ module ActiveAdmin
|
|
161
146
|
@menus = MenuCollection.new
|
162
147
|
|
163
148
|
@menus.on_build do |menus|
|
164
|
-
# Support for deprecated dashboards...
|
165
|
-
Dashboards.add_to_menu(self, menus.menu(DEFAULT_MENU))
|
166
|
-
|
167
|
-
# Build the default utility navigation
|
168
149
|
build_default_utility_nav
|
169
150
|
|
170
151
|
resources.each do |resource|
|
@@ -178,10 +159,10 @@ module ActiveAdmin
|
|
178
159
|
return if @menus.exists? :utility_navigation
|
179
160
|
@menus.menu :utility_navigation do |menu|
|
180
161
|
menu.add :label => proc{ display_name current_active_admin_user },
|
181
|
-
:url => '#',
|
162
|
+
:url => proc{ url_for [active_admin_namespace.name, current_active_admin_user] rescue '#' },
|
182
163
|
:id => 'current_user',
|
183
164
|
:if => proc{ current_active_admin_user? }
|
184
|
-
|
165
|
+
|
185
166
|
add_logout_button_to_menu menu
|
186
167
|
end
|
187
168
|
end
|
@@ -217,11 +198,6 @@ module ActiveAdmin
|
|
217
198
|
@resources = ResourceCollection.new
|
218
199
|
end
|
219
200
|
|
220
|
-
def unload_dashboard!
|
221
|
-
# TODO: Only clear out my sections
|
222
|
-
Dashboards.clear_all_sections!
|
223
|
-
end
|
224
|
-
|
225
201
|
# Creates a ruby module to namespace all the classes in if required
|
226
202
|
def register_module
|
227
203
|
eval "module ::#{module_name}; end"
|
@@ -241,13 +217,5 @@ module ActiveAdmin
|
|
241
217
|
PageDSL.new(config).run_registration_block(&block)
|
242
218
|
end
|
243
219
|
|
244
|
-
# Creates a dashboard controller for this config
|
245
|
-
def generate_dashboard_controller
|
246
|
-
return unless ActiveAdmin::Dashboards.built?
|
247
|
-
|
248
|
-
eval "class ::#{dashboard_controller_name} < ActiveAdmin::PageController
|
249
|
-
include ActiveAdmin::Dashboards::DashboardController
|
250
|
-
end"
|
251
|
-
end
|
252
220
|
end
|
253
221
|
end
|
data/lib/active_admin/page.rb
CHANGED
@@ -17,7 +17,7 @@ module ActiveAdmin
|
|
17
17
|
|
18
18
|
# An array of custom actions defined for this page
|
19
19
|
attr_reader :page_actions
|
20
|
-
|
20
|
+
|
21
21
|
# Set breadcrumb builder
|
22
22
|
attr_accessor :breadcrumb
|
23
23
|
|
@@ -78,7 +78,7 @@ module ActiveAdmin
|
|
78
78
|
|
79
79
|
def add_default_sidebar_sections
|
80
80
|
end
|
81
|
-
|
81
|
+
|
82
82
|
# Clears all the custom actions this page knows about
|
83
83
|
def clear_page_actions!
|
84
84
|
@page_actions = []
|
@@ -17,7 +17,7 @@ module ActiveAdmin
|
|
17
17
|
def content(options = {}, &block)
|
18
18
|
config.set_page_presenter :index, ActiveAdmin::PagePresenter.new(options, &block)
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
def page_action(name, options = {}, &block)
|
22
22
|
config.page_actions << ControllerAction.new(name, options)
|
23
23
|
controller do
|
@@ -7,11 +7,11 @@ module ActiveAdmin
|
|
7
7
|
#
|
8
8
|
# @param [Rails::Application] rails_app The current rails application
|
9
9
|
# @param [ActiveAdmin::Application] active_admin_app The current Active Admin app
|
10
|
-
# @param [String] rails_version The version of Rails we're using.
|
10
|
+
# @param [String] rails_version The version of Rails we're using.
|
11
11
|
#
|
12
12
|
# @returns A concrete subclass of AbstractReloader
|
13
13
|
def self.build(rails_app, active_admin_app, rails_version)
|
14
|
-
reloader_class = rails_version
|
14
|
+
reloader_class = rails_version.to_f >= 3.2 ? Rails32Reloader : RailsLessThan31Reloader
|
15
15
|
reloader_class.new(rails_app, active_admin_app, rails_version)
|
16
16
|
end
|
17
17
|
|
@@ -64,7 +64,7 @@ module ActiveAdmin
|
|
64
64
|
|
65
65
|
end
|
66
66
|
|
67
|
-
# Deals with reloading Active Admin on each request in
|
67
|
+
# Deals with reloading Active Admin on each request in
|
68
68
|
# development and once in production in Rails < 3.2.
|
69
69
|
class RailsLessThan31Reloader < AbstractReloader
|
70
70
|
|
@@ -6,6 +6,7 @@ require 'active_admin/resource/pagination'
|
|
6
6
|
require 'active_admin/resource/routes'
|
7
7
|
require 'active_admin/resource/naming'
|
8
8
|
require 'active_admin/resource/scopes'
|
9
|
+
require 'active_admin/resource/scope_to'
|
9
10
|
require 'active_admin/resource/sidebars'
|
10
11
|
require 'active_admin/resource/belongs_to'
|
11
12
|
|
@@ -39,15 +40,9 @@ module ActiveAdmin
|
|
39
40
|
# The default sort order to use in the controller
|
40
41
|
attr_accessor :sort_order
|
41
42
|
|
42
|
-
# Scope this resource to an association in the controller
|
43
|
-
attr_accessor :scope_to
|
44
|
-
|
45
|
-
# If we're scoping resources, use this method on the parent to return the collection
|
46
|
-
attr_accessor :scope_to_association_method
|
47
|
-
|
48
43
|
# Set the configuration for the CSV
|
49
44
|
attr_writer :csv_builder
|
50
|
-
|
45
|
+
|
51
46
|
# Set breadcrumb builder
|
52
47
|
attr_accessor :breadcrumb
|
53
48
|
|
@@ -68,6 +63,8 @@ module ActiveAdmin
|
|
68
63
|
end
|
69
64
|
end
|
70
65
|
|
66
|
+
include MethodOrProcHelper
|
67
|
+
|
71
68
|
include Base
|
72
69
|
include ActionItems
|
73
70
|
include Authorization
|
@@ -77,6 +74,7 @@ module ActiveAdmin
|
|
77
74
|
include PagePresenters
|
78
75
|
include Pagination
|
79
76
|
include Scopes
|
77
|
+
include ScopeTo
|
80
78
|
include Sidebars
|
81
79
|
include Menu
|
82
80
|
include Routes
|
@@ -103,11 +101,6 @@ module ActiveAdmin
|
|
103
101
|
resource_class.connection.quote_column_name(column)
|
104
102
|
end
|
105
103
|
|
106
|
-
# Returns the named route for an instance of this resource
|
107
|
-
def route_instance_path
|
108
|
-
[route_prefix, controller.resources_configuration[:self][:route_instance_name], 'path'].compact.join('_').to_sym
|
109
|
-
end
|
110
|
-
|
111
104
|
# Clears all the member actions this resource knows about
|
112
105
|
def clear_member_actions!
|
113
106
|
@member_actions = []
|
@@ -119,27 +112,22 @@ module ActiveAdmin
|
|
119
112
|
|
120
113
|
# Return only defined resource actions
|
121
114
|
def defined_actions
|
122
|
-
controller.instance_methods.map
|
123
|
-
end
|
124
|
-
|
125
|
-
# Are admin notes turned on for this resource
|
126
|
-
def admin_notes?
|
127
|
-
admin_notes.nil? ? ActiveAdmin.admin_notes : admin_notes
|
115
|
+
controller.instance_methods.map(&:to_sym) & ResourceController::ACTIVE_ADMIN_ACTIONS
|
128
116
|
end
|
129
117
|
|
130
118
|
def belongs_to(target, options = {})
|
131
119
|
@belongs_to = Resource::BelongsTo.new(self, target, options)
|
132
|
-
self.
|
133
|
-
controller.belongs_to
|
120
|
+
self.navigation_menu_name = target unless @belongs_to.optional?
|
121
|
+
controller.send :belongs_to, target, options.dup
|
134
122
|
end
|
135
123
|
|
136
124
|
def belongs_to_config
|
137
125
|
@belongs_to
|
138
126
|
end
|
139
127
|
|
140
|
-
# Do we belong to another resource
|
128
|
+
# Do we belong to another resource?
|
141
129
|
def belongs_to?
|
142
|
-
|
130
|
+
!!belongs_to_config
|
143
131
|
end
|
144
132
|
|
145
133
|
# The csv builder for this resource
|
@@ -147,6 +135,11 @@ module ActiveAdmin
|
|
147
135
|
@csv_builder || default_csv_builder
|
148
136
|
end
|
149
137
|
|
138
|
+
def find_resource(id)
|
139
|
+
resource = resource_class.where(resource_class.primary_key => id).first
|
140
|
+
decorator_class ? decorator_class.new(resource) : resource
|
141
|
+
end
|
142
|
+
|
150
143
|
# @deprecated
|
151
144
|
def resource
|
152
145
|
resource_class
|
@@ -158,7 +151,7 @@ module ActiveAdmin
|
|
158
151
|
|
159
152
|
def default_options
|
160
153
|
{
|
161
|
-
:sort_order =>
|
154
|
+
:sort_order => (resource_class.respond_to?(:primary_key) ? resource_class.primary_key.to_s : 'id') + '_desc'
|
162
155
|
}
|
163
156
|
end
|
164
157
|
|