activeadmin 3.4.0 → 4.0.0.beta18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -102
- data/CONTRIBUTING.md +32 -117
- data/README.md +17 -30
- data/UPGRADING.md +241 -0
- data/app/assets/config/active_admin_manifest.js +2 -0
- data/{lib → app/controllers}/active_admin/base_controller/authorization.rb +1 -1
- 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 +11 -6
- data/{lib → app/controllers}/active_admin/resource_controller/scoping.rb +1 -1
- data/{lib → app/controllers}/active_admin/resource_controller/streaming.rb +4 -4
- 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 +95 -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 -2
- 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 +15 -0
- data/app/views/active_admin/resource/_form_default.html.arb +11 -0
- data/app/views/active_admin/resource/_index_as_table_default.html.arb +8 -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 +2 -0
- data/app/views/active_admin/resource/edit.html.arb +1 -2
- data/app/views/active_admin/resource/index.html.arb +94 -2
- data/app/views/active_admin/resource/new.html.arb +1 -2
- data/app/views/active_admin/resource/show.html.arb +12 -2
- 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 +6 -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/importmap.rb +5 -0
- data/config/locales/ar.yml +136 -116
- data/config/locales/az.yml +103 -118
- data/config/locales/bg.yml +91 -99
- data/config/locales/bs.yml +95 -101
- data/config/locales/ca.yml +131 -86
- data/config/locales/cs.yml +82 -90
- data/config/locales/da.yml +102 -117
- data/config/locales/de.yml +130 -141
- data/config/locales/el.yml +94 -106
- data/config/locales/en-CA.yml +104 -119
- data/config/locales/en-GB.yml +104 -119
- data/config/locales/en.yml +134 -140
- data/config/locales/eo.yml +107 -123
- data/config/locales/es-MX.yml +70 -78
- data/config/locales/es.yml +129 -138
- data/config/locales/fa.yml +91 -99
- data/config/locales/fi.yml +84 -92
- data/config/locales/fr.yml +135 -120
- data/config/locales/he.yml +103 -118
- data/config/locales/hr.yml +95 -103
- data/config/locales/hu.yml +76 -81
- data/config/locales/id.yml +97 -112
- data/config/locales/it.yml +134 -140
- data/config/locales/ja.yml +109 -120
- data/config/locales/ko.yml +136 -101
- data/config/locales/lt.yml +106 -121
- data/config/locales/lv.yml +70 -75
- data/config/locales/mk.yml +100 -114
- data/config/locales/nb.yml +98 -109
- data/config/locales/nl.yml +113 -122
- data/config/locales/pl.yml +137 -146
- data/config/locales/pt-BR.yml +134 -121
- data/config/locales/pt-PT.yml +71 -76
- data/config/locales/ro.yml +74 -79
- data/config/locales/ru.yml +142 -122
- data/config/locales/sk.yml +131 -146
- data/config/locales/sv-SE.yml +126 -141
- data/config/locales/tr.yml +105 -120
- data/config/locales/uk.yml +140 -119
- data/config/locales/vi.yml +125 -140
- data/config/locales/zh-CN.yml +135 -141
- data/config/locales/zh-TW.yml +136 -116
- data/lib/active_admin/application.rb +6 -14
- data/lib/active_admin/application_settings.rb +1 -1
- data/lib/active_admin/async_count.rb +23 -0
- data/lib/active_admin/batch_actions/controller.rb +1 -4
- data/lib/active_admin/batch_actions/resource_extension.rb +8 -15
- data/lib/active_admin/batch_actions/views/batch_action_form.rb +1 -7
- data/lib/active_admin/batch_actions/views/selection_cells.rb +3 -3
- data/lib/active_admin/batch_actions.rb +4 -9
- data/lib/active_admin/callbacks.rb +6 -4
- data/lib/active_admin/collection_decorator.rb +1 -1
- data/lib/active_admin/component.rb +0 -1
- data/lib/active_admin/csv_builder.rb +2 -2
- data/lib/active_admin/devise.rb +3 -3
- data/lib/active_admin/dsl.rb +3 -3
- data/lib/active_admin/dynamic_settings_node.rb +6 -6
- data/lib/active_admin/engine.rb +23 -7
- data/lib/active_admin/filters/active.rb +8 -6
- data/lib/active_admin/filters/active_filter.rb +2 -10
- data/lib/active_admin/filters/forms.rb +1 -45
- data/lib/active_admin/filters/resource_extension.rb +18 -10
- data/lib/active_admin/filters.rb +5 -7
- data/lib/active_admin/form_builder.rb +14 -17
- data/lib/active_admin/helpers/optional_display.rb +1 -1
- data/lib/active_admin/inputs/filters/base/search_method_select.rb +10 -12
- 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/localizers.rb +1 -1
- 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 +3 -45
- data/lib/active_admin/namespace_settings.rb +3 -36
- data/lib/active_admin/order_clause.rb +4 -1
- data/lib/active_admin/orm/active_record/comments/views/active_admin_comments.rb +4 -76
- data/lib/active_admin/orm/active_record/comments/views.rb +2 -2
- data/lib/active_admin/orm/active_record/comments.rb +13 -8
- data/lib/active_admin/orm/active_record.rb +1 -1
- data/lib/active_admin/pundit_adapter.rb +3 -3
- data/lib/active_admin/resource/action_items.rb +18 -23
- data/lib/active_admin/resource/naming.rb +2 -3
- data/lib/active_admin/resource/page_presenters.rb +2 -2
- data/lib/active_admin/resource/sidebars.rb +1 -1
- data/lib/active_admin/resource.rb +17 -16
- data/lib/active_admin/resource_collection.rb +1 -1
- data/lib/active_admin/resource_dsl.rb +3 -3
- data/lib/active_admin/scope.rb +11 -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/method_or_proc_helper.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 +14 -16
- data/lib/active_admin/views/components/index_list.rb +10 -23
- data/lib/active_admin/views/components/paginated_collection.rb +34 -39
- data/lib/active_admin/views/components/panel.rb +3 -11
- data/lib/active_admin/views/components/scopes.rb +39 -26
- data/lib/active_admin/views/components/status_tag.rb +22 -19
- data/lib/active_admin/views/components/table_for.rb +25 -25
- data/lib/active_admin/views/index_as_table.rb +39 -101
- data/lib/active_admin.rb +16 -15
- data/lib/activeadmin.rb +1 -1
- 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 +21 -0
- data/lib/generators/active_admin/devise/devise_generator.rb +2 -2
- 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 +50 -7
- data/lib/generators/active_admin/resource/templates/resource.rb.erb +42 -0
- data/lib/generators/active_admin/views_generator.rb +18 -0
- data/plugin.js +414 -0
- data/vendor/bundle/offense.rb +1 -0
- data/vendor/javascript/flowbite.js +1 -0
- data/vendor/javascript/rails_ujs_esm.js +1 -0
- metadata +80 -207
- data/app/assets/javascripts/active_admin/base.js +0 -517
- 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/config/locales/de-CH.yml +0 -94
- 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/tabs.rb +0 -41
- 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/resource_controller/decorators.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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
require_relative "dynamic_setting"
|
|
3
|
+
require_relative "settings_node"
|
|
4
4
|
|
|
5
5
|
module ActiveAdmin
|
|
6
6
|
|
|
@@ -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,18 +10,32 @@ 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", after: "importmap" do |app|
|
|
19
|
+
# Skip if importmap-rails is not installed
|
|
20
|
+
next unless app.config.respond_to?(:importmap)
|
|
21
|
+
|
|
22
|
+
ActiveAdmin.importmap.draw(Engine.root.join("config", "importmap.rb"))
|
|
23
|
+
package_path = Engine.root.join("app/javascript")
|
|
24
|
+
if app.config.respond_to?(:assets)
|
|
25
|
+
app.config.assets.paths << package_path
|
|
26
|
+
app.config.assets.paths << Engine.root.join("vendor/javascript")
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
if app.config.importmap.sweep_cache
|
|
30
|
+
ActiveAdmin.importmap.cache_sweeper(watches: package_path)
|
|
31
|
+
ActiveSupport.on_load(:action_controller_base) do
|
|
32
|
+
before_action { ActiveAdmin.importmap.cache_sweeper.execute_if_updated }
|
|
17
33
|
end
|
|
18
34
|
end
|
|
19
35
|
end
|
|
20
36
|
|
|
21
37
|
initializer "active_admin.routes" do
|
|
22
|
-
|
|
38
|
+
require_relative "helpers/routes/url_helpers"
|
|
23
39
|
end
|
|
24
40
|
|
|
25
41
|
initializer "active_admin.deprecator" do |app|
|
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
|
|
2
|
+
require_relative "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
|
|
|
12
11
|
# @param resource [ActiveAdmin::Resource] current resource
|
|
13
12
|
# @param search [Ransack::Search] search object
|
|
14
13
|
#
|
|
15
|
-
# @see ActiveAdmin::ResourceController::
|
|
14
|
+
# @see ActiveAdmin::ResourceController::DataAccess#apply_filtering
|
|
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`
|
|
@@ -40,13 +38,11 @@ module ActiveAdmin
|
|
|
40
38
|
end
|
|
41
39
|
|
|
42
40
|
def predicate_name
|
|
43
|
-
|
|
44
|
-
"ransack.predicates.#{condition.predicate.name}",
|
|
45
|
-
default: ransack_predicate_name)
|
|
41
|
+
Ransack::Translate.predicate(condition.predicate.name)
|
|
46
42
|
end
|
|
47
43
|
|
|
48
44
|
def html_options
|
|
49
|
-
{
|
|
45
|
+
{ "data-filter": condition.key }
|
|
50
46
|
end
|
|
51
47
|
|
|
52
48
|
private
|
|
@@ -80,10 +76,6 @@ module ActiveAdmin
|
|
|
80
76
|
condition_attribute.attr_name
|
|
81
77
|
end
|
|
82
78
|
|
|
83
|
-
def ransack_predicate_name
|
|
84
|
-
Ransack::Translate.predicate(condition.predicate.name)
|
|
85
|
-
end
|
|
86
|
-
|
|
87
79
|
def find_class?
|
|
88
80
|
["eq", "in"].include? condition.predicate.arel_predicate
|
|
89
81
|
end
|
|
@@ -7,9 +7,6 @@ module ActiveAdmin
|
|
|
7
7
|
include ::ActiveAdmin::Filters::FormtasticAddons
|
|
8
8
|
self.input_namespaces = [::Object, ::ActiveAdmin::Inputs::Filters, ::ActiveAdmin::Inputs, ::Formtastic::Inputs]
|
|
9
9
|
|
|
10
|
-
# TODO: remove input class finders after formtastic 4 (where it will be default)
|
|
11
|
-
self.input_class_finder = ::Formtastic::InputClassFinder
|
|
12
|
-
|
|
13
10
|
def filter(method, options = {})
|
|
14
11
|
if method.present? && options[:as] ||= default_input_type(method)
|
|
15
12
|
template.concat input(method, options)
|
|
@@ -21,7 +18,7 @@ module ActiveAdmin
|
|
|
21
18
|
# Returns the default filter type for a given attribute. If you want
|
|
22
19
|
# to use a custom search method, you have to specify the type yourself.
|
|
23
20
|
def default_input_type(method, options = {})
|
|
24
|
-
if
|
|
21
|
+
if /_(eq|cont|start|end)\z/.match?(method)
|
|
25
22
|
:string
|
|
26
23
|
elsif klass._ransackers.key?(method.to_s)
|
|
27
24
|
klass._ransackers[method.to_s].type
|
|
@@ -41,46 +38,5 @@ module ActiveAdmin
|
|
|
41
38
|
end
|
|
42
39
|
end
|
|
43
40
|
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
41
|
end
|
|
86
42
|
end
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
require_relative "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,14 +139,14 @@ 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
|
|
|
146
146
|
filters = poly.map(&:foreign_type) + low_arity.map(&:name) + high_arity
|
|
147
147
|
end
|
|
148
148
|
|
|
149
|
-
filters.map
|
|
149
|
+
filters.map(&:to_sym)
|
|
150
150
|
else
|
|
151
151
|
[]
|
|
152
152
|
end
|
|
@@ -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
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
require "active_admin/filters/active_sidebar"
|
|
2
|
+
require_relative "filters/dsl"
|
|
3
|
+
require_relative "filters/resource_extension"
|
|
4
|
+
require_relative "filters/formtastic_addons"
|
|
5
|
+
require_relative "filters/forms"
|
|
6
|
+
require_relative "helpers/optional_display"
|
|
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
|
|
@@ -17,12 +17,9 @@ module ActiveAdmin
|
|
|
17
17
|
|
|
18
18
|
self.input_namespaces = [::Object, ::ActiveAdmin::Inputs, ::Formtastic::Inputs]
|
|
19
19
|
|
|
20
|
-
# TODO: remove both class finders after formtastic 4 (where it will be default)
|
|
21
|
-
self.input_class_finder = ::Formtastic::InputClassFinder
|
|
22
|
-
self.action_class_finder = ::Formtastic::ActionClassFinder
|
|
23
|
-
|
|
24
20
|
def cancel_link(url = { action: "index" }, html_options = {}, li_attrs = {})
|
|
25
|
-
li_attrs[:class] ||= "cancel"
|
|
21
|
+
li_attrs[:class] ||= "action cancel"
|
|
22
|
+
html_options[:class] ||= "cancel-link"
|
|
26
23
|
li_content = template.link_to I18n.t("active_admin.cancel"), url, html_options
|
|
27
24
|
template.content_tag(:li, li_content, li_attrs)
|
|
28
25
|
end
|
|
@@ -48,7 +45,7 @@ module ActiveAdmin
|
|
|
48
45
|
@assoc = assoc
|
|
49
46
|
@options = extract_custom_settings!(options.dup)
|
|
50
47
|
@options.reverse_merge!(for: assoc)
|
|
51
|
-
@options[:class] = [options[:class], "inputs
|
|
48
|
+
@options[:class] = [options[:class], "inputs has-many-fields"].compact.join(" ")
|
|
52
49
|
|
|
53
50
|
if sortable_column
|
|
54
51
|
@options[:for] = [assoc, sorted_children(sortable_column)]
|
|
@@ -57,7 +54,7 @@ module ActiveAdmin
|
|
|
57
54
|
|
|
58
55
|
def render(&block)
|
|
59
56
|
html = "".html_safe
|
|
60
|
-
html << template.content_tag(:h3) { heading } if heading.present?
|
|
57
|
+
html << template.content_tag(:h3, class: "has-many-fields-title") { heading } if heading.present?
|
|
61
58
|
html << template.capture { content_has_many(&block) }
|
|
62
59
|
html = wrap_div_or_li(html)
|
|
63
60
|
template.concat(html) if template.output_buffer
|
|
@@ -78,8 +75,7 @@ module ActiveAdmin
|
|
|
78
75
|
end
|
|
79
76
|
|
|
80
77
|
def default_heading
|
|
81
|
-
assoc_klass.model_name.
|
|
82
|
-
human(count: ::ActiveAdmin::Helpers::I18n::PLURAL_MANY_COUNT)
|
|
78
|
+
assoc_klass.model_name.human(count: 2.1)
|
|
83
79
|
end
|
|
84
80
|
|
|
85
81
|
def assoc_klass
|
|
@@ -108,23 +104,23 @@ module ActiveAdmin
|
|
|
108
104
|
|
|
109
105
|
def has_many_actions(form_builder, contents)
|
|
110
106
|
if form_builder.object.new_record?
|
|
111
|
-
contents << template.content_tag(:li) do
|
|
107
|
+
contents << template.content_tag(:li, class: "input") do
|
|
112
108
|
remove_text = remove_record.is_a?(String) ? remove_record : I18n.t("active_admin.has_many_remove")
|
|
113
|
-
template.link_to remove_text, "#", class: "
|
|
109
|
+
template.link_to remove_text, "#", class: "has-many-remove"
|
|
114
110
|
end
|
|
115
111
|
elsif allow_destroy?(form_builder.object)
|
|
116
112
|
form_builder.input(
|
|
117
113
|
:_destroy, as: :boolean,
|
|
118
|
-
wrapper_html: { class: "
|
|
114
|
+
wrapper_html: { class: "has-many-delete" },
|
|
119
115
|
label: I18n.t("active_admin.has_many_delete"))
|
|
120
116
|
end
|
|
121
117
|
|
|
122
118
|
if sortable_column
|
|
123
119
|
form_builder.input sortable_column, as: :hidden
|
|
124
120
|
|
|
125
|
-
contents << template.content_tag(:li, class: "handle") do
|
|
126
|
-
|
|
127
|
-
end
|
|
121
|
+
# contents << template.content_tag(:li, class: "handle") do
|
|
122
|
+
# I18n.t("active_admin.move")
|
|
123
|
+
# end
|
|
128
124
|
end
|
|
129
125
|
|
|
130
126
|
contents
|
|
@@ -169,7 +165,7 @@ module ActiveAdmin
|
|
|
169
165
|
html = template.capture { __getobj__.send(:inputs_for_nested_attributes, opts, &form_block) }
|
|
170
166
|
text = new_record.is_a?(String) ? new_record : I18n.t("active_admin.has_many_new", model: assoc_name.human)
|
|
171
167
|
|
|
172
|
-
template.link_to text, "#", class: "
|
|
168
|
+
template.link_to text, "#", class: "has-many-add", data: {
|
|
173
169
|
html: CGI.escapeHTML(html).html_safe, placeholder: placeholder
|
|
174
170
|
}
|
|
175
171
|
end
|
|
@@ -178,7 +174,8 @@ module ActiveAdmin
|
|
|
178
174
|
template.content_tag(
|
|
179
175
|
already_in_an_inputs_block ? :li : :div,
|
|
180
176
|
html,
|
|
181
|
-
class: "
|
|
177
|
+
class: "has-many-container",
|
|
178
|
+
"data-has-many-association" => assoc,
|
|
182
179
|
"data-sortable" => sortable_column,
|
|
183
180
|
"data-sortable-start" => sortable_start)
|
|
184
181
|
end
|
|
@@ -26,21 +26,19 @@ module ActiveAdmin
|
|
|
26
26
|
attr_reader :filters
|
|
27
27
|
|
|
28
28
|
def filter(*filters)
|
|
29
|
-
(@filters ||= []).push
|
|
29
|
+
(@filters ||= []).push(*filters)
|
|
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
|
|
@@ -65,7 +63,7 @@ module ActiveAdmin
|
|
|
65
63
|
|
|
66
64
|
def filter_options
|
|
67
65
|
filters.collect do |filter|
|
|
68
|
-
[
|
|
66
|
+
[Ransack::Translate.predicate(filter).capitalize, "#{method}_#{filter}"]
|
|
69
67
|
end
|
|
70
68
|
end
|
|
71
69
|
|
|
@@ -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_relative "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
|