activeadmin 3.2.5 → 4.0.0.beta1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2 -86
- data/CONTRIBUTING.md +25 -108
- data/README.md +19 -32
- data/app/assets/config/active_admin_manifest.js +2 -0
- data/app/controllers/active_admin/base_controller/menu.rb +39 -0
- data/{lib → app/controllers}/active_admin/base_controller.rb +46 -18
- data/{lib → app/controllers}/active_admin/page_controller.rb +0 -4
- data/{lib → app/controllers}/active_admin/resource_controller/action_builder.rb +1 -1
- data/{lib → app/controllers}/active_admin/resource_controller/data_access.rb +2 -2
- data/{lib → app/controllers}/active_admin/resource_controller/decorators.rb +1 -1
- data/{lib → app/controllers}/active_admin/resource_controller/scoping.rb +1 -1
- data/{lib → app/controllers}/active_admin/resource_controller/streaming.rb +2 -2
- data/app/controllers/active_admin/resource_controller.rb +102 -0
- data/app/helpers/active_admin/auto_link_helper.rb +66 -0
- data/app/helpers/active_admin/breadcrumb_helper.rb +41 -0
- data/app/helpers/active_admin/display_helper.rb +117 -0
- data/app/helpers/active_admin/form_helper.rb +95 -0
- data/app/helpers/active_admin/index_helper.rb +40 -0
- data/app/helpers/active_admin/layout_helper.rb +63 -0
- data/app/javascript/active_admin/features/batch_actions.js +89 -0
- data/app/javascript/active_admin/features/dark_mode_toggle.js +37 -0
- data/app/javascript/active_admin/features/filters.js +34 -0
- data/app/javascript/active_admin/features/has_many.js +28 -0
- data/app/javascript/active_admin/features/main_menu.js +12 -0
- data/app/javascript/active_admin/features/per_page.js +9 -0
- data/app/javascript/active_admin/utils/dom.js +17 -0
- data/app/javascript/active_admin.js +10 -0
- data/app/views/active_admin/_flash_messages.html.erb +22 -0
- data/app/views/active_admin/_html_head.html.erb +13 -0
- data/app/views/active_admin/_main_navigation.html.erb +28 -0
- data/app/views/active_admin/_page_header.html.erb +27 -0
- data/app/views/active_admin/_sidebar.html.erb +5 -0
- data/app/views/active_admin/_site_footer.html.erb +7 -0
- data/app/views/active_admin/_site_header.html.erb +30 -0
- data/app/views/active_admin/devise/confirmations/new.html.erb +5 -3
- data/app/views/active_admin/devise/passwords/edit.html.erb +5 -3
- data/app/views/active_admin/devise/passwords/new.html.erb +5 -4
- data/app/views/active_admin/devise/registrations/new.html.erb +6 -4
- data/app/views/active_admin/devise/sessions/new.html.erb +6 -4
- data/app/views/active_admin/devise/shared/_links.erb +3 -1
- data/app/views/active_admin/devise/unlocks/new.html.erb +6 -4
- data/app/views/{kaminari/active_admin_countless → active_admin/kaminari}/_gap.html.erb +3 -1
- data/app/views/active_admin/kaminari/_next_page.html.erb +16 -0
- data/app/views/active_admin/kaminari/_page.html.erb +14 -0
- data/app/views/{kaminari/active_admin_countless → active_admin/kaminari}/_paginator.html.erb +1 -2
- data/app/views/active_admin/kaminari/_prev_page.html.erb +16 -0
- data/app/views/active_admin/page/index.html.arb +5 -1
- data/app/views/active_admin/resource/_active_filters.html.erb +32 -0
- data/app/views/active_admin/resource/_batch_actions_dropdown.html.erb +19 -0
- data/app/views/active_admin/resource/_form.html.arb +16 -0
- data/app/views/active_admin/resource/_form_default.html.arb +12 -0
- data/app/views/active_admin/resource/_index_as_table_default.html.arb +9 -0
- data/app/views/active_admin/resource/_index_blank_slate.html.erb +14 -0
- data/app/views/active_admin/resource/_index_empty_results.html.erb +5 -0
- data/app/views/active_admin/resource/_index_table_actions_default.html.erb +9 -0
- data/app/views/active_admin/resource/_show_default.html.arb +3 -0
- data/app/views/active_admin/resource/edit.html.arb +1 -1
- data/app/views/active_admin/resource/index.html.arb +94 -1
- data/app/views/active_admin/resource/new.html.arb +1 -1
- data/app/views/active_admin/resource/show.html.arb +12 -1
- data/app/views/active_admin/shared/_action_items.html.erb +3 -0
- data/app/views/active_admin/shared/_download_format_links.html.erb +7 -0
- data/app/views/active_admin/shared/_resource_comments.html.erb +51 -0
- data/app/views/active_admin/shared/_sidebar_section.html.arb +7 -0
- data/app/views/active_admin/shared/_sidebar_sections.html.erb +5 -0
- data/app/views/layouts/active_admin.html.erb +20 -0
- data/app/views/layouts/active_admin_logged_out.html.erb +8 -45
- data/config/locales/ar.yml +0 -16
- data/config/locales/az.yml +0 -16
- data/config/locales/bg.yml +0 -9
- data/config/locales/bs.yml +0 -7
- data/config/locales/ca.yml +0 -9
- data/config/locales/cs.yml +0 -9
- data/config/locales/da.yml +0 -16
- data/config/locales/de-CH.yml +0 -10
- data/config/locales/de.yml +0 -16
- data/config/locales/el.yml +0 -13
- data/config/locales/en-CA.yml +0 -16
- data/config/locales/en-GB.yml +0 -16
- data/config/locales/en.yml +18 -28
- data/config/locales/eo.yml +0 -17
- data/config/locales/es-MX.yml +0 -9
- data/config/locales/es.yml +0 -16
- data/config/locales/fa.yml +0 -9
- data/config/locales/fi.yml +0 -9
- data/config/locales/fr.yml +32 -26
- data/config/locales/he.yml +0 -16
- data/config/locales/hr.yml +0 -9
- data/config/locales/hu.yml +0 -6
- data/config/locales/id.yml +0 -16
- data/config/locales/it.yml +0 -16
- data/config/locales/ja.yml +0 -16
- data/config/locales/ko.yml +0 -9
- data/config/locales/lt.yml +0 -16
- data/config/locales/lv.yml +0 -6
- data/config/locales/mk.yml +0 -15
- data/config/locales/nb.yml +0 -12
- data/config/locales/nl.yml +21 -29
- data/config/locales/pl.yml +0 -16
- data/config/locales/pt-BR.yml +0 -16
- data/config/locales/pt-PT.yml +0 -6
- data/config/locales/ro.yml +0 -6
- data/config/locales/ru.yml +0 -16
- data/config/locales/sk.yml +0 -16
- data/config/locales/sv-SE.yml +0 -16
- data/config/locales/tr.yml +0 -16
- data/config/locales/uk.yml +0 -16
- data/config/locales/vi.yml +0 -16
- data/config/locales/zh-CN.yml +0 -16
- data/config/locales/zh-TW.yml +0 -16
- data/lib/active_admin/application.rb +1 -9
- data/lib/active_admin/batch_actions/controller.rb +1 -4
- data/lib/active_admin/batch_actions/resource_extension.rb +6 -13
- data/lib/active_admin/batch_actions/views/batch_action_form.rb +0 -6
- data/lib/active_admin/batch_actions/views/selection_cells.rb +2 -2
- data/lib/active_admin/batch_actions.rb +0 -5
- data/lib/active_admin/callbacks.rb +6 -4
- data/lib/active_admin/component.rb +0 -1
- data/lib/active_admin/csv_builder.rb +1 -1
- data/lib/active_admin/devise.rb +3 -3
- data/lib/active_admin/dsl.rb +2 -2
- data/lib/active_admin/dynamic_settings_node.rb +4 -4
- data/lib/active_admin/engine.rb +19 -6
- data/lib/active_admin/filters/active.rb +6 -4
- data/lib/active_admin/filters/active_filter.rb +1 -3
- data/lib/active_admin/filters/forms.rb +1 -42
- data/lib/active_admin/filters/resource_extension.rb +17 -9
- data/lib/active_admin/filters.rb +0 -2
- data/lib/active_admin/form_builder.rb +15 -14
- data/lib/active_admin/inputs/filters/base/search_method_select.rb +8 -10
- data/lib/active_admin/inputs/filters/base.rb +1 -1
- data/lib/active_admin/inputs/filters/check_boxes_input.rb +1 -6
- data/lib/active_admin/inputs/filters/date_range_input.rb +4 -2
- data/lib/active_admin/inputs.rb +0 -3
- data/lib/active_admin/menu.rb +10 -7
- data/lib/active_admin/menu_collection.rb +1 -1
- data/lib/active_admin/menu_item.rb +24 -3
- data/lib/active_admin/namespace.rb +2 -44
- data/lib/active_admin/namespace_settings.rb +2 -35
- data/lib/active_admin/order_clause.rb +4 -1
- data/lib/active_admin/orm/active_record/comments/views/active_admin_comments.rb +3 -75
- data/lib/active_admin/orm/active_record/comments.rb +10 -5
- data/lib/active_admin/pundit_adapter.rb +1 -1
- data/lib/active_admin/resource/action_items.rb +15 -20
- data/lib/active_admin/resource/attributes.rb +1 -8
- data/lib/active_admin/resource/naming.rb +1 -2
- data/lib/active_admin/resource.rb +1 -0
- data/lib/active_admin/resource_dsl.rb +1 -1
- data/lib/active_admin/scope.rb +1 -1
- data/lib/active_admin/settings_node.rb +1 -1
- data/lib/active_admin/sidebar_section.rb +0 -5
- data/lib/active_admin/version.rb +1 -1
- data/lib/active_admin/view_helpers.rb +0 -12
- data/lib/active_admin/views/components/active_admin_form.rb +21 -29
- data/lib/active_admin/views/components/attributes_table.rb +4 -12
- data/lib/active_admin/views/components/index_list.rb +10 -23
- data/lib/active_admin/views/components/paginated_collection.rb +34 -42
- data/lib/active_admin/views/components/panel.rb +2 -10
- data/lib/active_admin/views/components/scopes.rb +12 -21
- data/lib/active_admin/views/components/status_tag.rb +22 -19
- data/lib/active_admin/views/components/table_for.rb +19 -24
- data/lib/active_admin/views/components/tabs.rb +10 -11
- data/lib/active_admin/views/index_as_table.rb +24 -97
- data/lib/active_admin.rb +7 -11
- data/lib/generators/active_admin/assets/assets_generator.rb +4 -4
- data/lib/generators/active_admin/assets/templates/active_admin.css +3 -0
- data/lib/generators/active_admin/assets/templates/tailwind.config.js +18 -0
- data/lib/generators/active_admin/install/install_generator.rb +2 -8
- data/lib/generators/active_admin/install/templates/active_admin.rb.erb +10 -87
- data/lib/generators/active_admin/install/templates/dashboard.rb +8 -25
- data/lib/generators/active_admin/page/page_generator.rb +0 -1
- data/lib/generators/active_admin/resource/resource_generator.rb +46 -7
- data/lib/generators/active_admin/resource/templates/resource.rb.erb +42 -0
- data/lib/generators/active_admin/views_generator.rb +18 -0
- metadata +67 -214
- data/app/assets/javascripts/active_admin/base.js +0 -521
- data/app/assets/stylesheets/active_admin/_base.scss +0 -57
- data/app/assets/stylesheets/active_admin/_forms.scss +0 -315
- data/app/assets/stylesheets/active_admin/_header.scss +0 -188
- data/app/assets/stylesheets/active_admin/_mixins.scss +0 -1
- data/app/assets/stylesheets/active_admin/_normalize.scss +0 -349
- data/app/assets/stylesheets/active_admin/_print.scss +0 -287
- data/app/assets/stylesheets/active_admin/_typography.scss +0 -100
- data/app/assets/stylesheets/active_admin/components/_batch_actions.scss +0 -6
- data/app/assets/stylesheets/active_admin/components/_blank_slates.scss +0 -30
- data/app/assets/stylesheets/active_admin/components/_breadcrumbs.scss +0 -20
- data/app/assets/stylesheets/active_admin/components/_buttons.scss +0 -6
- data/app/assets/stylesheets/active_admin/components/_columns.scss +0 -3
- data/app/assets/stylesheets/active_admin/components/_comments.scss +0 -41
- data/app/assets/stylesheets/active_admin/components/_date_picker.scss +0 -148
- data/app/assets/stylesheets/active_admin/components/_dropdown_menu.scss +0 -154
- data/app/assets/stylesheets/active_admin/components/_flash_messages.scss +0 -37
- data/app/assets/stylesheets/active_admin/components/_grid.scss +0 -9
- data/app/assets/stylesheets/active_admin/components/_index_list.scss +0 -12
- data/app/assets/stylesheets/active_admin/components/_links.scss +0 -5
- data/app/assets/stylesheets/active_admin/components/_modal_dialog.scss +0 -34
- data/app/assets/stylesheets/active_admin/components/_pagination.scss +0 -58
- data/app/assets/stylesheets/active_admin/components/_panels.scss +0 -6
- data/app/assets/stylesheets/active_admin/components/_scopes.scss +0 -13
- data/app/assets/stylesheets/active_admin/components/_status_tags.scss +0 -12
- data/app/assets/stylesheets/active_admin/components/_table_tools.scss +0 -70
- data/app/assets/stylesheets/active_admin/components/_tables.scss +0 -112
- data/app/assets/stylesheets/active_admin/components/_tabs.scss +0 -68
- data/app/assets/stylesheets/active_admin/components/_unsupported_browser.scss +0 -16
- data/app/assets/stylesheets/active_admin/mixins/_all.scss +0 -8
- data/app/assets/stylesheets/active_admin/mixins/_buttons.scss +0 -65
- data/app/assets/stylesheets/active_admin/mixins/_gradients.scss +0 -28
- data/app/assets/stylesheets/active_admin/mixins/_rounded.scss +0 -22
- data/app/assets/stylesheets/active_admin/mixins/_sections.scss +0 -41
- data/app/assets/stylesheets/active_admin/mixins/_shadows.scss +0 -15
- data/app/assets/stylesheets/active_admin/mixins/_typography.scss +0 -3
- data/app/assets/stylesheets/active_admin/mixins/_utilities.scss +0 -17
- data/app/assets/stylesheets/active_admin/mixins/_variables.scss +0 -51
- data/app/assets/stylesheets/active_admin/pages/_logged_out.scss +0 -44
- data/app/assets/stylesheets/active_admin/structure/_footer.scss +0 -19
- data/app/assets/stylesheets/active_admin/structure/_main_structure.scss +0 -29
- data/app/assets/stylesheets/active_admin/structure/_title_bar.scss +0 -43
- data/app/javascript/active_admin/base.js +0 -28
- data/app/javascript/active_admin/ext/jquery-ui.js +0 -7
- data/app/javascript/active_admin/ext/jquery.js +0 -9
- data/app/javascript/active_admin/initializers/batch-actions.js +0 -61
- data/app/javascript/active_admin/initializers/checkbox-toggler.js +0 -3
- data/app/javascript/active_admin/initializers/datepicker.js +0 -16
- data/app/javascript/active_admin/initializers/dropdown-menu.js +0 -9
- data/app/javascript/active_admin/initializers/filters.js +0 -10
- data/app/javascript/active_admin/initializers/has-many.js +0 -98
- data/app/javascript/active_admin/initializers/per-page.js +0 -13
- data/app/javascript/active_admin/initializers/table-checkbox-toggler.js +0 -3
- data/app/javascript/active_admin/initializers/tabs.js +0 -6
- data/app/javascript/active_admin/lib/checkbox-toggler.js +0 -49
- data/app/javascript/active_admin/lib/dropdown-menu.js +0 -116
- data/app/javascript/active_admin/lib/filters.js +0 -39
- data/app/javascript/active_admin/lib/modal-dialog.js +0 -63
- data/app/javascript/active_admin/lib/per-page.js +0 -38
- data/app/javascript/active_admin/lib/table-checkbox-toggler.js +0 -38
- data/app/javascript/active_admin/lib/utils.js +0 -40
- data/app/views/kaminari/active_admin/_first_page.html.erb +0 -11
- data/app/views/kaminari/active_admin/_gap.html.erb +0 -8
- data/app/views/kaminari/active_admin/_last_page.html.erb +0 -11
- data/app/views/kaminari/active_admin/_next_page.html.erb +0 -11
- data/app/views/kaminari/active_admin/_page.html.erb +0 -12
- data/app/views/kaminari/active_admin/_paginator.html.erb +0 -25
- data/app/views/kaminari/active_admin/_prev_page.html.erb +0 -11
- data/app/views/kaminari/active_admin_countless/_first_page.html.erb +0 -11
- data/app/views/kaminari/active_admin_countless/_next_page.html.erb +0 -11
- data/app/views/kaminari/active_admin_countless/_page.html.erb +0 -12
- data/app/views/kaminari/active_admin_countless/_prev_page.html.erb +0 -11
- data/app/views/layouts/active_admin.html.arb +0 -2
- data/lib/active_admin/abstract_view_factory.rb +0 -48
- data/lib/active_admin/asset_registration.rb +0 -30
- data/lib/active_admin/base_controller/menu.rb +0 -35
- data/lib/active_admin/batch_actions/views/batch_action_selector.rb +0 -59
- data/lib/active_admin/filters/active_sidebar.rb +0 -28
- data/lib/active_admin/generators/boilerplate.rb +0 -54
- data/lib/active_admin/helpers/collection.rb +0 -21
- data/lib/active_admin/helpers/i18n.rb +0 -8
- data/lib/active_admin/inputs/datepicker_input.rb +0 -28
- data/lib/active_admin/inputs/filters/date_picker_input.rb +0 -14
- data/lib/active_admin/orm/active_record/comments/show_page_helper.rb +0 -24
- data/lib/active_admin/orm/mongoid.rb +0 -2
- data/lib/active_admin/resource_controller/sidebars.rb +0 -19
- data/lib/active_admin/resource_controller.rb +0 -68
- data/lib/active_admin/view_factory.rb +0 -28
- data/lib/active_admin/view_helpers/active_admin_application_helper.rb +0 -13
- data/lib/active_admin/view_helpers/auto_link_helper.rb +0 -46
- data/lib/active_admin/view_helpers/breadcrumb_helper.rb +0 -34
- data/lib/active_admin/view_helpers/display_helper.rb +0 -119
- data/lib/active_admin/view_helpers/download_format_links_helper.rb +0 -60
- data/lib/active_admin/view_helpers/fields_for.rb +0 -51
- data/lib/active_admin/view_helpers/flash_helper.rb +0 -15
- data/lib/active_admin/view_helpers/form_helper.rb +0 -21
- data/lib/active_admin/view_helpers/scope_name_helper.rb +0 -17
- data/lib/active_admin/view_helpers/sidebar_helper.rb +0 -16
- data/lib/active_admin/view_helpers/title_helper.rb +0 -12
- data/lib/active_admin/view_helpers/view_factory_helper.rb +0 -12
- data/lib/active_admin/views/action_items.rb +0 -18
- data/lib/active_admin/views/components/active_filters_sidebar_content.rb +0 -59
- data/lib/active_admin/views/components/blank_slate.rb +0 -18
- data/lib/active_admin/views/components/columns.rb +0 -162
- data/lib/active_admin/views/components/dropdown_menu.rb +0 -69
- data/lib/active_admin/views/components/menu.rb +0 -33
- data/lib/active_admin/views/components/menu_item.rb +0 -59
- data/lib/active_admin/views/components/sidebar.rb +0 -14
- data/lib/active_admin/views/components/sidebar_section.rb +0 -35
- data/lib/active_admin/views/components/site_title.rb +0 -55
- data/lib/active_admin/views/components/unsupported_browser.rb +0 -12
- data/lib/active_admin/views/footer.rb +0 -32
- data/lib/active_admin/views/header.rb +0 -20
- data/lib/active_admin/views/index_as_block.rb +0 -37
- data/lib/active_admin/views/index_as_blog.rb +0 -156
- data/lib/active_admin/views/index_as_grid.rb +0 -81
- data/lib/active_admin/views/pages/base.rb +0 -134
- data/lib/active_admin/views/pages/form.rb +0 -65
- data/lib/active_admin/views/pages/index.rb +0 -166
- data/lib/active_admin/views/pages/layout.rb +0 -27
- data/lib/active_admin/views/pages/page.rb +0 -31
- data/lib/active_admin/views/pages/show.rb +0 -60
- data/lib/active_admin/views/tabbed_navigation.rb +0 -12
- data/lib/active_admin/views/title_bar.rb +0 -56
- data/lib/generators/active_admin/assets/templates/active_admin.js +0 -1
- data/lib/generators/active_admin/assets/templates/active_admin.scss +0 -17
- data/lib/generators/active_admin/resource/templates/admin.rb.erb +0 -46
- data/lib/generators/active_admin/webpacker/plugins/jquery.js +0 -7
- data/lib/generators/active_admin/webpacker/templates/active_admin.js +0 -5
- data/lib/generators/active_admin/webpacker/templates/active_admin.scss +0 -17
- data/lib/generators/active_admin/webpacker/templates/print.scss +0 -2
- data/lib/generators/active_admin/webpacker/webpacker_generator.rb +0 -27
- data/vendor/assets/javascripts/jquery-ui/data.js +0 -45
- data/vendor/assets/javascripts/jquery-ui/disable-selection.js +0 -51
- data/vendor/assets/javascripts/jquery-ui/focusable.js +0 -89
- data/vendor/assets/javascripts/jquery-ui/form-reset-mixin.js +0 -83
- data/vendor/assets/javascripts/jquery-ui/form.js +0 -25
- data/vendor/assets/javascripts/jquery-ui/ie.js +0 -20
- data/vendor/assets/javascripts/jquery-ui/keycode.js +0 -51
- data/vendor/assets/javascripts/jquery-ui/labels.js +0 -71
- data/vendor/assets/javascripts/jquery-ui/plugin.js +0 -49
- data/vendor/assets/javascripts/jquery-ui/position.js +0 -513
- data/vendor/assets/javascripts/jquery-ui/safe-active-element.js +0 -46
- data/vendor/assets/javascripts/jquery-ui/safe-blur.js +0 -27
- data/vendor/assets/javascripts/jquery-ui/scroll-parent.js +0 -50
- data/vendor/assets/javascripts/jquery-ui/tabbable.js +0 -41
- data/vendor/assets/javascripts/jquery-ui/unique-id.js +0 -54
- data/vendor/assets/javascripts/jquery-ui/version.js +0 -20
- data/vendor/assets/javascripts/jquery-ui/widget.js +0 -758
- data/vendor/assets/javascripts/jquery-ui/widgets/button.js +0 -454
- data/vendor/assets/javascripts/jquery-ui/widgets/checkboxradio.js +0 -294
- data/vendor/assets/javascripts/jquery-ui/widgets/controlgroup.js +0 -304
- data/vendor/assets/javascripts/jquery-ui/widgets/datepicker.js +0 -2243
- data/vendor/assets/javascripts/jquery-ui/widgets/dialog.js +0 -971
- data/vendor/assets/javascripts/jquery-ui/widgets/draggable.js +0 -1268
- data/vendor/assets/javascripts/jquery-ui/widgets/mouse.js +0 -241
- data/vendor/assets/javascripts/jquery-ui/widgets/resizable.js +0 -1228
- data/vendor/assets/javascripts/jquery-ui/widgets/sortable.js +0 -1622
- data/vendor/assets/javascripts/jquery-ui/widgets/tabs.js +0 -931
- /data/{lib → app/controllers}/active_admin/base_controller/authorization.rb +0 -0
- /data/{lib → app/controllers}/active_admin/resource_controller/polymorphic_routes.rb +0 -0
- /data/{lib → app/controllers}/active_admin/resource_controller/resource_class_methods.rb +0 -0
- /data/lib/{active_admin/orm/mongoid/.gitkeep → generators/active_admin/assets/templates/builds/.keep} +0 -0
data/lib/active_admin/dsl.rb
CHANGED
@@ -13,7 +13,7 @@ module ActiveAdmin
|
|
13
13
|
|
14
14
|
# Runs the registration block inside this object
|
15
15
|
def run_registration_block(&block)
|
16
|
-
instance_exec &block if
|
16
|
+
instance_exec &block if block
|
17
17
|
end
|
18
18
|
|
19
19
|
# The instance of ActiveAdmin::Resource that's being registered
|
@@ -72,7 +72,7 @@ module ActiveAdmin
|
|
72
72
|
# end
|
73
73
|
#
|
74
74
|
def controller(&block)
|
75
|
-
@config.controller.class_exec(&block) if
|
75
|
+
@config.controller.class_exec(&block) if block
|
76
76
|
@config.controller
|
77
77
|
end
|
78
78
|
|
@@ -10,18 +10,18 @@ module ActiveAdmin
|
|
10
10
|
class_attribute "#{name}_setting"
|
11
11
|
add_reader(name)
|
12
12
|
add_writer(name, type)
|
13
|
-
send "#{name}=", value
|
13
|
+
send :"#{name}=", value
|
14
14
|
end
|
15
15
|
|
16
16
|
def add_reader(name)
|
17
17
|
define_singleton_method(name) do |*args|
|
18
|
-
send("#{name}_setting").value(*args)
|
18
|
+
send(:"#{name}_setting").value(*args)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
22
|
def add_writer(name, type)
|
23
|
-
define_singleton_method("#{name}=") do |value|
|
24
|
-
send("#{name}_setting=", DynamicSetting.build(value, type))
|
23
|
+
define_singleton_method(:"#{name}=") do |value|
|
24
|
+
send(:"#{name}_setting=", DynamicSetting.build(value, type))
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
data/lib/active_admin/engine.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module ActiveAdmin
|
3
3
|
class Engine < ::Rails::Engine
|
4
|
+
isolate_namespace ActiveAdmin
|
5
|
+
|
4
6
|
# Set default values for app_path and load_paths before running initializers
|
5
7
|
initializer "active_admin.load_app_path", before: :load_config_initializers do |app|
|
6
8
|
ActiveAdmin::Application.setting :app_path, app.root
|
@@ -8,12 +10,23 @@ module ActiveAdmin
|
|
8
10
|
end
|
9
11
|
|
10
12
|
initializer "active_admin.precompile", group: :all do |app|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
if app.config.respond_to?(:assets)
|
14
|
+
app.config.assets.precompile += %w(active_admin.js active_admin.css active_admin_manifest.js)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
initializer "active_admin.importmap", before: "importmap" do |app|
|
19
|
+
ActiveAdmin.importmap.draw(Engine.root.join("config", "importmap.rb"))
|
20
|
+
package_path = Engine.root.join("app/javascript")
|
21
|
+
if app.config.respond_to?(:assets)
|
22
|
+
app.config.assets.paths << package_path
|
23
|
+
app.config.assets.paths << Engine.root.join("vendor/javascript")
|
24
|
+
end
|
25
|
+
|
26
|
+
if app.config.importmap.sweep_cache
|
27
|
+
ActiveAdmin.importmap.cache_sweeper(watches: package_path)
|
28
|
+
ActiveSupport.on_load(:action_controller_base) do
|
29
|
+
before_action { ActiveAdmin.importmap.cache_sweeper.execute_if_updated }
|
17
30
|
end
|
18
31
|
end
|
19
32
|
end
|
@@ -3,9 +3,8 @@ require "active_admin/filters/active_filter"
|
|
3
3
|
|
4
4
|
module ActiveAdmin
|
5
5
|
module Filters
|
6
|
-
|
7
6
|
class Active
|
8
|
-
|
7
|
+
attr_reader :filters, :resource, :scopes
|
9
8
|
|
10
9
|
# Instantiate a `Active` object containing collection of current active filters
|
11
10
|
|
@@ -16,6 +15,11 @@ module ActiveAdmin
|
|
16
15
|
def initialize(resource, search)
|
17
16
|
@resource = resource
|
18
17
|
@filters = build_filters(search.conditions)
|
18
|
+
@scopes = search.instance_variable_get(:@scope_args)
|
19
|
+
end
|
20
|
+
|
21
|
+
def all_blank?
|
22
|
+
filters.blank? && scopes.blank?
|
19
23
|
end
|
20
24
|
|
21
25
|
private
|
@@ -23,8 +27,6 @@ module ActiveAdmin
|
|
23
27
|
def build_filters(conditions)
|
24
28
|
conditions.map { |condition| ActiveFilter.new(resource, condition.dup) }
|
25
29
|
end
|
26
|
-
|
27
30
|
end
|
28
|
-
|
29
31
|
end
|
30
32
|
end
|
@@ -3,8 +3,6 @@ module ActiveAdmin
|
|
3
3
|
module Filters
|
4
4
|
|
5
5
|
class ActiveFilter
|
6
|
-
include ActiveAdmin::ViewHelpers
|
7
|
-
|
8
6
|
attr_reader :resource, :condition, :related_class
|
9
7
|
|
10
8
|
# Instantiate a `ActiveFilter`
|
@@ -46,7 +44,7 @@ module ActiveAdmin
|
|
46
44
|
end
|
47
45
|
|
48
46
|
def html_options
|
49
|
-
{
|
47
|
+
{ "data-filter": condition.key }
|
50
48
|
end
|
51
49
|
|
52
50
|
private
|
@@ -21,7 +21,7 @@ module ActiveAdmin
|
|
21
21
|
# Returns the default filter type for a given attribute. If you want
|
22
22
|
# to use a custom search method, you have to specify the type yourself.
|
23
23
|
def default_input_type(method, options = {})
|
24
|
-
if
|
24
|
+
if /_(eq|cont|start|end)\z/.match?(method)
|
25
25
|
:string
|
26
26
|
elsif klass._ransackers.key?(method.to_s)
|
27
27
|
klass._ransackers[method.to_s].type
|
@@ -41,46 +41,5 @@ module ActiveAdmin
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
44
|
-
|
45
|
-
# This module is included into the view
|
46
|
-
module ViewHelper
|
47
|
-
|
48
|
-
# Helper method to render a filter form
|
49
|
-
def active_admin_filters_form_for(search, filters, options = {})
|
50
|
-
defaults = { builder: ActiveAdmin::Filters::FormBuilder,
|
51
|
-
url: collection_path,
|
52
|
-
html: { class: "filter_form" } }
|
53
|
-
required = { html: { method: :get },
|
54
|
-
as: :q }
|
55
|
-
options = defaults.deep_merge(options).deep_merge(required)
|
56
|
-
|
57
|
-
form_for search, options do |f|
|
58
|
-
filters.each do |attribute, opts|
|
59
|
-
next if opts.key?(:if) && !call_method_or_proc_on(self, opts[:if])
|
60
|
-
next if opts.key?(:unless) && call_method_or_proc_on(self, opts[:unless])
|
61
|
-
|
62
|
-
filter_opts = opts.except(:if, :unless)
|
63
|
-
filter_opts[:input_html] = instance_exec(&filter_opts[:input_html]) if filter_opts[:input_html].is_a?(Proc)
|
64
|
-
|
65
|
-
f.filter attribute, filter_opts
|
66
|
-
end
|
67
|
-
|
68
|
-
buttons = content_tag :div, class: "buttons" do
|
69
|
-
f.submit(I18n.t("active_admin.filters.buttons.filter")) +
|
70
|
-
link_to(I18n.t("active_admin.filters.buttons.clear"), "#", class: "clear_filters_btn") +
|
71
|
-
hidden_field_tags_for(params, except: except_hidden_fields)
|
72
|
-
end
|
73
|
-
|
74
|
-
f.template.concat buttons
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
private
|
79
|
-
|
80
|
-
def except_hidden_fields
|
81
|
-
[:q, :page]
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
44
|
end
|
86
45
|
end
|
@@ -1,7 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
require "active_admin/filters/active"
|
3
|
+
|
2
4
|
module ActiveAdmin
|
3
5
|
module Filters
|
4
|
-
|
5
6
|
class Disabled < RuntimeError
|
6
7
|
def initialize(action)
|
7
8
|
super "Cannot #{action} a filter when filters are disabled. Enable filters with 'config.filters = true'"
|
@@ -9,11 +10,10 @@ module ActiveAdmin
|
|
9
10
|
end
|
10
11
|
|
11
12
|
module ResourceExtension
|
12
|
-
|
13
13
|
def initialize(*)
|
14
14
|
super
|
15
15
|
add_filters_sidebar_section
|
16
|
-
|
16
|
+
add_active_search_sidebar_section
|
17
17
|
end
|
18
18
|
|
19
19
|
# Returns the filters for this resource. If filters are not enabled,
|
@@ -98,7 +98,7 @@ module ActiveAdmin
|
|
98
98
|
end
|
99
99
|
|
100
100
|
if @filters_to_remove
|
101
|
-
@filters_to_remove.each
|
101
|
+
@filters_to_remove.each { |filter| filters.delete(filter) }
|
102
102
|
end
|
103
103
|
|
104
104
|
filters
|
@@ -139,7 +139,7 @@ module ActiveAdmin
|
|
139
139
|
end
|
140
140
|
|
141
141
|
# Remove high-arity associations with no searchable column
|
142
|
-
high_arity = high_arity.select(
|
142
|
+
high_arity = high_arity.select { |r| searchable_column_for(r) }
|
143
143
|
|
144
144
|
high_arity = high_arity.map { |r| r.name.to_s + "_" + searchable_column_for(r) + namespace.filter_method_for_large_association }
|
145
145
|
|
@@ -165,16 +165,24 @@ module ActiveAdmin
|
|
165
165
|
end
|
166
166
|
|
167
167
|
def filters_sidebar_section
|
168
|
-
|
168
|
+
name = :filters
|
169
|
+
ActiveAdmin::SidebarSection.new name, only: :index, if: -> { active_admin_config.filters.any? } do
|
170
|
+
h3 I18n.t("active_admin.sidebars.#{name}", default: name.to_s.titlecase), class: "filters-form-title"
|
169
171
|
active_admin_filters_form_for assigns[:search], **active_admin_config.filters
|
170
172
|
end
|
171
173
|
end
|
172
174
|
|
173
|
-
def
|
174
|
-
self.sidebar_sections <<
|
175
|
+
def add_active_search_sidebar_section
|
176
|
+
self.sidebar_sections << active_search_sidebar_section
|
175
177
|
end
|
176
178
|
|
179
|
+
def active_search_sidebar_section
|
180
|
+
name = :active_search
|
181
|
+
ActiveAdmin::SidebarSection.new name, only: :index, if: -> { active_admin_config.current_filters_enabled? && (params[:q] || params[:scope]) } do
|
182
|
+
filters = ActiveAdmin::Filters::Active.new(active_admin_config, assigns[:search])
|
183
|
+
render "active_filters", active_filters: filters
|
184
|
+
end
|
185
|
+
end
|
177
186
|
end
|
178
|
-
|
179
187
|
end
|
180
188
|
end
|
data/lib/active_admin/filters.rb
CHANGED
@@ -4,9 +4,7 @@ require "active_admin/filters/resource_extension"
|
|
4
4
|
require "active_admin/filters/formtastic_addons"
|
5
5
|
require "active_admin/filters/forms"
|
6
6
|
require "active_admin/helpers/optional_display"
|
7
|
-
require "active_admin/filters/active_sidebar"
|
8
7
|
|
9
8
|
# Add our Extensions
|
10
9
|
ActiveAdmin::ResourceDSL.send :include, ActiveAdmin::Filters::DSL
|
11
10
|
ActiveAdmin::Resource.send :include, ActiveAdmin::Filters::ResourceExtension
|
12
|
-
ActiveAdmin::ViewHelpers.send :include, ActiveAdmin::Filters::ViewHelper
|
@@ -22,7 +22,8 @@ module ActiveAdmin
|
|
22
22
|
self.action_class_finder = ::Formtastic::ActionClassFinder
|
23
23
|
|
24
24
|
def cancel_link(url = { action: "index" }, html_options = {}, li_attrs = {})
|
25
|
-
li_attrs[:class] ||= "cancel"
|
25
|
+
li_attrs[:class] ||= "action cancel"
|
26
|
+
html_options[:class] ||= "cancel-link"
|
26
27
|
li_content = template.link_to I18n.t("active_admin.cancel"), url, html_options
|
27
28
|
template.content_tag(:li, li_content, li_attrs)
|
28
29
|
end
|
@@ -48,7 +49,7 @@ module ActiveAdmin
|
|
48
49
|
@assoc = assoc
|
49
50
|
@options = extract_custom_settings!(options.dup)
|
50
51
|
@options.reverse_merge!(for: assoc)
|
51
|
-
@options[:class] = [options[:class], "inputs
|
52
|
+
@options[:class] = [options[:class], "inputs has-many-fields"].compact.join(" ")
|
52
53
|
|
53
54
|
if sortable_column
|
54
55
|
@options[:for] = [assoc, sorted_children(sortable_column)]
|
@@ -57,7 +58,7 @@ module ActiveAdmin
|
|
57
58
|
|
58
59
|
def render(&block)
|
59
60
|
html = "".html_safe
|
60
|
-
html << template.content_tag(:h3) { heading } if heading.present?
|
61
|
+
html << template.content_tag(:h3, class: "has-many-fields-title") { heading } if heading.present?
|
61
62
|
html << template.capture { content_has_many(&block) }
|
62
63
|
html = wrap_div_or_li(html)
|
63
64
|
template.concat(html) if template.output_buffer
|
@@ -78,8 +79,7 @@ module ActiveAdmin
|
|
78
79
|
end
|
79
80
|
|
80
81
|
def default_heading
|
81
|
-
assoc_klass.model_name.
|
82
|
-
human(count: ::ActiveAdmin::Helpers::I18n::PLURAL_MANY_COUNT)
|
82
|
+
assoc_klass.model_name.human(count: 2.1)
|
83
83
|
end
|
84
84
|
|
85
85
|
def assoc_klass
|
@@ -108,23 +108,23 @@ module ActiveAdmin
|
|
108
108
|
|
109
109
|
def has_many_actions(form_builder, contents)
|
110
110
|
if form_builder.object.new_record?
|
111
|
-
contents << template.content_tag(:li) do
|
111
|
+
contents << template.content_tag(:li, class: "input") do
|
112
112
|
remove_text = remove_record.is_a?(String) ? remove_record : I18n.t("active_admin.has_many_remove")
|
113
|
-
template.link_to remove_text, "#", class: "
|
113
|
+
template.link_to remove_text, "#", class: "has-many-remove"
|
114
114
|
end
|
115
115
|
elsif allow_destroy?(form_builder.object)
|
116
116
|
form_builder.input(
|
117
117
|
:_destroy, as: :boolean,
|
118
|
-
wrapper_html: { class: "
|
118
|
+
wrapper_html: { class: "has-many-delete" },
|
119
119
|
label: I18n.t("active_admin.has_many_delete"))
|
120
120
|
end
|
121
121
|
|
122
122
|
if sortable_column
|
123
123
|
form_builder.input sortable_column, as: :hidden
|
124
124
|
|
125
|
-
contents << template.content_tag(:li, class: "handle") do
|
126
|
-
|
127
|
-
end
|
125
|
+
# contents << template.content_tag(:li, class: "handle") do
|
126
|
+
# I18n.t("active_admin.move")
|
127
|
+
# end
|
128
128
|
end
|
129
129
|
|
130
130
|
contents
|
@@ -161,7 +161,7 @@ module ActiveAdmin
|
|
161
161
|
# Capture the ADD JS
|
162
162
|
def js_for_has_many(class_string, &form_block)
|
163
163
|
assoc_name = assoc_klass.model_name
|
164
|
-
placeholder = "NEW_#{assoc_name.to_s.underscore.upcase.
|
164
|
+
placeholder = "NEW_#{assoc_name.to_s.underscore.upcase.tr('/', '_')}_RECORD"
|
165
165
|
opts = {
|
166
166
|
for: [assoc, assoc_klass.new],
|
167
167
|
class: class_string,
|
@@ -170,7 +170,7 @@ module ActiveAdmin
|
|
170
170
|
html = template.capture { __getobj__.send(:inputs_for_nested_attributes, opts, &form_block) }
|
171
171
|
text = new_record.is_a?(String) ? new_record : I18n.t("active_admin.has_many_new", model: assoc_name.human)
|
172
172
|
|
173
|
-
template.link_to text, "#", class: "
|
173
|
+
template.link_to text, "#", class: "has-many-add", data: {
|
174
174
|
html: CGI.escapeHTML(html).html_safe, placeholder: placeholder
|
175
175
|
}
|
176
176
|
end
|
@@ -179,7 +179,8 @@ module ActiveAdmin
|
|
179
179
|
template.content_tag(
|
180
180
|
already_in_an_inputs_block ? :li : :div,
|
181
181
|
html,
|
182
|
-
class: "
|
182
|
+
class: "has-many-container",
|
183
|
+
"data-has-many-association" => assoc,
|
183
184
|
"data-sortable" => sortable_column,
|
184
185
|
"data-sortable-start" => sortable_start)
|
185
186
|
end
|
@@ -30,17 +30,15 @@ module ActiveAdmin
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
def wrapper_html_options
|
34
|
-
opts = super
|
35
|
-
(opts[:class] ||= "") << " select_and_search" unless seems_searchable?
|
36
|
-
opts
|
37
|
-
end
|
38
|
-
|
39
33
|
def to_html
|
40
34
|
input_wrapping do
|
41
|
-
|
42
|
-
|
43
|
-
|
35
|
+
[
|
36
|
+
label_html, # your label
|
37
|
+
'<div class="filters-form-input-group">',
|
38
|
+
select_html, # the dropdown that holds the available search methods
|
39
|
+
input_html, # your input field
|
40
|
+
'</div>'
|
41
|
+
].join("\n").html_safe
|
44
42
|
end
|
45
43
|
end
|
46
44
|
|
@@ -49,7 +47,7 @@ module ActiveAdmin
|
|
49
47
|
end
|
50
48
|
|
51
49
|
def select_html
|
52
|
-
template.select_tag "", template.options_for_select(filter_options, current_filter)
|
50
|
+
template.select_tag "", template.options_for_select(filter_options, current_filter), "data-search-methods": ""
|
53
51
|
end
|
54
52
|
|
55
53
|
def filters
|
@@ -10,7 +10,7 @@ module ActiveAdmin
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def selected_values
|
13
|
-
@object.public_send("#{searchable_method_name}_in") || []
|
13
|
+
@object.public_send(:"#{searchable_method_name}_in") || []
|
14
14
|
end
|
15
15
|
|
16
16
|
def searchable_method_name
|
@@ -21,11 +21,6 @@ module ActiveAdmin
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
# Add whitespace before label
|
25
|
-
def choice_label(choice)
|
26
|
-
" " + super
|
27
|
-
end
|
28
|
-
|
29
24
|
# Don't wrap in UL tag
|
30
25
|
def choices_group_wrapping(&block)
|
31
26
|
template.capture(&block)
|
@@ -8,8 +8,10 @@ module ActiveAdmin
|
|
8
8
|
def to_html
|
9
9
|
input_wrapping do
|
10
10
|
[ label_html,
|
11
|
-
|
12
|
-
builder.
|
11
|
+
'<div class="filters-form-input-group">',
|
12
|
+
builder.date_field(gt_input_name, input_html_options_for(gt_input_name, gt_input_placeholder)),
|
13
|
+
builder.date_field(lt_input_name, input_html_options_for(lt_input_name, lt_input_placeholder)),
|
14
|
+
'</div>'
|
13
15
|
].join("\n").html_safe
|
14
16
|
end
|
15
17
|
end
|
data/lib/active_admin/inputs.rb
CHANGED
@@ -3,15 +3,12 @@ module ActiveAdmin
|
|
3
3
|
module Inputs
|
4
4
|
extend ActiveSupport::Autoload
|
5
5
|
|
6
|
-
autoload :DatepickerInput
|
7
|
-
|
8
6
|
module Filters
|
9
7
|
extend ActiveSupport::Autoload
|
10
8
|
|
11
9
|
autoload :Base
|
12
10
|
autoload :StringInput
|
13
11
|
autoload :TextInput
|
14
|
-
autoload :DatePickerInput
|
15
12
|
autoload :DateRangeInput
|
16
13
|
autoload :NumericInput
|
17
14
|
autoload :SelectInput
|
data/lib/active_admin/menu.rb
CHANGED
@@ -49,10 +49,7 @@ module ActiveAdmin
|
|
49
49
|
#
|
50
50
|
def add(options)
|
51
51
|
options = options.dup # Make sure parameter is not modified
|
52
|
-
|
53
|
-
|
54
|
-
item = if parent = parent_chain.shift
|
55
|
-
options[:parent] = parent_chain if parent_chain.any?
|
52
|
+
item = if parent = options.delete(:parent)
|
56
53
|
(self[parent] || add(label: parent)).add options
|
57
54
|
else
|
58
55
|
_add options.merge parent: self
|
@@ -65,7 +62,7 @@ module ActiveAdmin
|
|
65
62
|
|
66
63
|
# Whether any children match the given item.
|
67
64
|
def include?(item)
|
68
|
-
@children.
|
65
|
+
@children.value?(item)
|
69
66
|
end
|
70
67
|
|
71
68
|
# Used in the UI to visually distinguish which menu item is selected.
|
@@ -73,8 +70,14 @@ module ActiveAdmin
|
|
73
70
|
self == item || include?(item)
|
74
71
|
end
|
75
72
|
|
76
|
-
|
77
|
-
|
73
|
+
# Returns sorted array of menu items that should be displayed in this context.
|
74
|
+
# Sorts by priority first, then alphabetically by label if needed.
|
75
|
+
def items(context = nil)
|
76
|
+
@children.values.select { |i| i.display?(context) }.sort do |a, b|
|
77
|
+
result = a.priority <=> b.priority
|
78
|
+
result = a.label(context) <=> b.label(context) if result == 0
|
79
|
+
result
|
80
|
+
end
|
78
81
|
end
|
79
82
|
|
80
83
|
attr_reader :children
|
@@ -1,7 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
require 'active_admin/view_helpers/method_or_proc_helper'
|
3
|
+
|
2
4
|
module ActiveAdmin
|
3
5
|
class MenuItem
|
4
6
|
include Menu::MenuNode
|
7
|
+
include MethodOrProcHelper
|
5
8
|
|
6
9
|
attr_reader :html_options, :parent, :priority
|
7
10
|
|
@@ -61,10 +64,28 @@ module ActiveAdmin
|
|
61
64
|
@id ||= normalize_id @dirty_id
|
62
65
|
end
|
63
66
|
|
64
|
-
|
65
|
-
|
67
|
+
def label(context = nil)
|
68
|
+
render_in_context(context, @label)
|
69
|
+
end
|
70
|
+
|
71
|
+
def url(context = nil)
|
72
|
+
render_in_context(context, @url)
|
73
|
+
end
|
66
74
|
|
67
75
|
# Don't display if the :if option passed says so
|
68
|
-
|
76
|
+
# Don't display if the link isn't real, we have children, and none of the children are being displayed.
|
77
|
+
def display?(context = nil)
|
78
|
+
return false unless render_in_context(context, @should_display)
|
79
|
+
return false if !real_url?(context) && @children.any? && !items(context).any?
|
80
|
+
true
|
81
|
+
end
|
82
|
+
|
83
|
+
private
|
84
|
+
|
85
|
+
# URL is not nil, empty, or '#'
|
86
|
+
def real_url?(context = nil)
|
87
|
+
url = url context
|
88
|
+
url.present? && url != '#'
|
89
|
+
end
|
69
90
|
end
|
70
91
|
end
|
@@ -68,7 +68,7 @@ module ActiveAdmin
|
|
68
68
|
|
69
69
|
# Register the resource
|
70
70
|
register_resource_controller(config)
|
71
|
-
parse_registration_block(config, &block) if
|
71
|
+
parse_registration_block(config, &block) if block
|
72
72
|
reset_menu!
|
73
73
|
|
74
74
|
# Dispatch a registration event
|
@@ -83,7 +83,7 @@ module ActiveAdmin
|
|
83
83
|
|
84
84
|
# Register the resource
|
85
85
|
register_page_controller(config)
|
86
|
-
parse_page_registration_block(config, &block) if
|
86
|
+
parse_page_registration_block(config, &block) if block
|
87
87
|
reset_menu!
|
88
88
|
|
89
89
|
config
|
@@ -141,60 +141,18 @@ module ActiveAdmin
|
|
141
141
|
end
|
142
142
|
end
|
143
143
|
|
144
|
-
# The default logout menu item
|
145
|
-
#
|
146
|
-
# @param [ActiveAdmin::MenuItem] menu The menu to add the logout link to
|
147
|
-
# @param [Fixnum] priority The numeric priority for the order in which it appears
|
148
|
-
# @param [Hash] html_options An options hash to pass along to link_to
|
149
|
-
#
|
150
|
-
def add_logout_button_to_menu(menu, priority = 20, html_options = {})
|
151
|
-
if logout_link_path
|
152
|
-
html_options = html_options.reverse_merge(method: logout_link_method || :get)
|
153
|
-
menu.add id: "logout", priority: priority, html_options: html_options,
|
154
|
-
label: -> { I18n.t "active_admin.logout" },
|
155
|
-
url: -> { render_or_call_method_or_proc_on self, active_admin_namespace.logout_link_path },
|
156
|
-
if: :current_active_admin_user?
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
# The default user session menu item
|
161
|
-
#
|
162
|
-
# @param [ActiveAdmin::MenuItem] menu The menu to add the logout link to
|
163
|
-
# @param [Fixnum] priority The numeric priority for the order in which it appears
|
164
|
-
# @param [Hash] html_options An options hash to pass along to link_to
|
165
|
-
#
|
166
|
-
def add_current_user_to_menu(menu, priority = 10, html_options = {})
|
167
|
-
if current_user_method
|
168
|
-
menu.add id: "current_user", priority: priority, html_options: html_options,
|
169
|
-
label: -> { display_name current_active_admin_user },
|
170
|
-
url: -> { auto_url_for(current_active_admin_user) },
|
171
|
-
if: :current_active_admin_user?
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
144
|
protected
|
176
145
|
|
177
146
|
def build_menu_collection
|
178
147
|
@menus = MenuCollection.new
|
179
148
|
|
180
149
|
@menus.on_build do
|
181
|
-
build_default_utility_nav
|
182
|
-
|
183
150
|
resources.each do |resource|
|
184
151
|
resource.add_to_menu(@menus)
|
185
152
|
end
|
186
153
|
end
|
187
154
|
end
|
188
155
|
|
189
|
-
# Builds the default utility navigation in top right header with current user & logout button
|
190
|
-
def build_default_utility_nav
|
191
|
-
return if @menus.exists? :utility_navigation
|
192
|
-
@menus.menu :utility_navigation do |menu|
|
193
|
-
add_current_user_to_menu menu
|
194
|
-
add_logout_button_to_menu menu
|
195
|
-
end
|
196
|
-
end
|
197
|
-
|
198
156
|
# Either returns an existing Resource instance or builds a new one.
|
199
157
|
def find_or_build_resource(resource_class, options)
|
200
158
|
resources.add Resource.new(self, resource_class, options)
|