rails_admin 2.3.1 → 3.0.0.beta
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rails_admin might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile +9 -11
- data/README.md +37 -31
- data/Rakefile +2 -2
- data/app/assets/javascripts/rails_admin.js +21 -0
- data/app/assets/stylesheets/rails_admin/custom/mixins.scss +1 -1
- data/app/assets/stylesheets/rails_admin/custom/variables.scss +1 -1
- data/app/assets/stylesheets/rails_admin.scss.erb +76 -0
- data/app/controllers/rails_admin/application_controller.rb +4 -3
- data/app/controllers/rails_admin/main_controller.rb +43 -24
- data/app/helpers/rails_admin/application_helper.rb +69 -52
- data/app/helpers/rails_admin/form_builder.rb +5 -4
- data/app/helpers/rails_admin/main_helper.rb +27 -43
- data/app/views/kaminari/ra-twitter-bootstrap/_gap.html.erb +5 -0
- data/app/views/kaminari/ra-twitter-bootstrap/_next_page.html.erb +9 -0
- data/app/views/kaminari/ra-twitter-bootstrap/_page.html.erb +9 -0
- data/app/views/kaminari/ra-twitter-bootstrap/_paginator.html.erb +13 -0
- data/app/views/kaminari/ra-twitter-bootstrap/_prev_page.html.erb +9 -0
- data/app/views/kaminari/ra-twitter-bootstrap/without_count/_next_page.html.erb +9 -0
- data/app/views/kaminari/ra-twitter-bootstrap/without_count/_paginator.html.erb +6 -0
- data/app/views/kaminari/ra-twitter-bootstrap/without_count/_prev_page.html.erb +9 -0
- data/app/views/layouts/rails_admin/_head.html.erb +17 -0
- data/app/views/layouts/rails_admin/_navigation.html.erb +21 -0
- data/app/views/layouts/rails_admin/_secondary_navigation.html.erb +24 -0
- data/app/views/layouts/rails_admin/_sidebar_navigation.html.erb +9 -0
- data/app/views/layouts/rails_admin/application.html.erb +27 -0
- data/app/views/layouts/rails_admin/modal.js.erb +7 -0
- data/app/views/layouts/rails_admin/pjax.html.erb +20 -0
- data/app/views/rails_admin/main/_dashboard_history.html.erb +45 -0
- data/app/views/rails_admin/main/_delete_notice.html.erb +35 -0
- data/app/views/rails_admin/main/_form_action_text.html.erb +7 -0
- data/app/views/rails_admin/main/_form_boolean.html.erb +16 -0
- data/app/views/rails_admin/main/{_form_ck_editor.html.haml → _form_ck_editor.html.erb} +3 -3
- data/app/views/rails_admin/main/_form_code_mirror.html.erb +9 -0
- data/app/views/rails_admin/main/_form_colorpicker.html.erb +1 -0
- data/app/views/rails_admin/main/_form_datetime.html.erb +9 -0
- data/app/views/rails_admin/main/_form_enumeration.html.erb +21 -0
- data/app/views/rails_admin/main/_form_field.html.erb +1 -0
- data/app/views/rails_admin/main/_form_file_upload.html.erb +17 -0
- data/app/views/rails_admin/main/{_form_filtering_multiselect.html.haml → _form_filtering_multiselect.html.erb} +11 -11
- data/app/views/rails_admin/main/{_form_filtering_select.html.haml → _form_filtering_select.html.erb} +13 -12
- data/app/views/rails_admin/main/_form_froala.html.erb +8 -0
- data/app/views/rails_admin/main/_form_multiple_file_upload.html.erb +20 -0
- data/app/views/rails_admin/main/_form_nested_many.html.erb +21 -0
- data/app/views/rails_admin/main/_form_nested_one.html.erb +21 -0
- data/app/views/rails_admin/main/_form_polymorphic_association.html.erb +27 -0
- data/app/views/rails_admin/main/_form_simple_mde.html.erb +8 -0
- data/app/views/rails_admin/main/_form_text.html.erb +1 -0
- data/app/views/rails_admin/main/_form_wysihtml5.html.erb +8 -0
- data/app/views/rails_admin/main/_submit_buttons.html.erb +25 -0
- data/app/views/rails_admin/main/bulk_delete.html.erb +19 -0
- data/app/views/rails_admin/main/dashboard.html.erb +64 -0
- data/app/views/rails_admin/main/delete.html.erb +21 -0
- data/app/views/rails_admin/main/edit.html.erb +3 -0
- data/app/views/rails_admin/main/export.html.erb +146 -0
- data/app/views/rails_admin/main/history.html.erb +78 -0
- data/app/views/rails_admin/main/index.html.erb +193 -0
- data/app/views/rails_admin/main/new.html.erb +3 -0
- data/app/views/rails_admin/main/show.html.erb +28 -0
- data/config/initializers/active_record_extensions.rb +3 -1
- data/config/initializers/mongoid_extensions.rb +1 -1
- data/config/locales/rails_admin.en.yml +5 -1
- data/lib/generators/rails_admin/install_generator.rb +51 -3
- data/lib/generators/rails_admin/templates/environment.js +6 -0
- data/lib/generators/rails_admin/templates/initializer.erb +2 -1
- data/lib/generators/rails_admin/templates/rails_admin.js.erb +2 -0
- data/lib/generators/rails_admin/templates/rails_admin.scss +1 -0
- data/lib/generators/rails_admin/templates/webpack.config.js +32 -0
- data/lib/rails_admin/abstract_model.rb +24 -10
- data/lib/rails_admin/adapters/active_record/association.rb +20 -1
- data/lib/rails_admin/adapters/active_record/object_extension.rb +29 -0
- data/lib/rails_admin/adapters/active_record/property.rb +1 -1
- data/lib/rails_admin/adapters/active_record.rb +19 -21
- data/lib/rails_admin/adapters/mongoid/association.rb +38 -9
- data/lib/rails_admin/adapters/mongoid/bson.rb +4 -5
- data/lib/rails_admin/adapters/mongoid/extension.rb +3 -1
- data/lib/rails_admin/adapters/mongoid/object_extension.rb +32 -0
- data/lib/rails_admin/adapters/mongoid/property.rb +2 -2
- data/lib/rails_admin/adapters/mongoid.rb +25 -19
- data/lib/rails_admin/config/actions/base.rb +7 -2
- data/lib/rails_admin/config/actions/bulk_delete.rb +2 -2
- data/lib/rails_admin/config/actions/dashboard.rb +4 -3
- data/lib/rails_admin/config/actions/delete.rb +5 -9
- data/lib/rails_admin/config/actions/edit.rb +7 -7
- data/lib/rails_admin/config/actions/export.rb +2 -2
- data/lib/rails_admin/config/actions/history_index.rb +2 -2
- data/lib/rails_admin/config/actions/history_show.rb +2 -2
- data/lib/rails_admin/config/actions/index.rb +5 -7
- data/lib/rails_admin/config/actions/new.rb +9 -9
- data/lib/rails_admin/config/actions/show.rb +1 -1
- data/lib/rails_admin/config/actions/show_in_app.rb +6 -2
- data/lib/rails_admin/config/actions.rb +4 -4
- data/lib/rails_admin/config/configurable.rb +2 -2
- data/lib/rails_admin/config/fields/association.rb +15 -12
- data/lib/rails_admin/config/fields/base.rb +44 -24
- data/lib/rails_admin/config/fields/factories/active_storage.rb +1 -0
- data/lib/rails_admin/config/fields/factories/association.rb +6 -8
- data/lib/rails_admin/config/fields/factories/carrierwave.rb +2 -1
- data/lib/rails_admin/config/fields/factories/devise.rb +2 -1
- data/lib/rails_admin/config/fields/factories/dragonfly.rb +2 -1
- data/lib/rails_admin/config/fields/factories/paperclip.rb +2 -1
- data/lib/rails_admin/config/fields/factories/shrine.rb +1 -1
- data/lib/rails_admin/config/fields/group.rb +1 -2
- data/lib/rails_admin/config/fields/types/active_record_enum.rb +2 -0
- data/lib/rails_admin/config/fields/types/active_storage.rb +9 -7
- data/lib/rails_admin/config/fields/types/all.rb +1 -0
- data/lib/rails_admin/config/fields/types/belongs_to_association.rb +4 -12
- data/lib/rails_admin/config/fields/types/boolean.rb +32 -8
- data/lib/rails_admin/config/fields/types/carrierwave.rb +1 -0
- data/lib/rails_admin/config/fields/types/citext.rb +13 -0
- data/lib/rails_admin/config/fields/types/color.rb +6 -2
- data/lib/rails_admin/config/fields/types/date.rb +5 -8
- data/lib/rails_admin/config/fields/types/datetime.rb +18 -21
- data/lib/rails_admin/config/fields/types/decimal.rb +9 -2
- data/lib/rails_admin/config/fields/types/dragonfly.rb +3 -1
- data/lib/rails_admin/config/fields/types/enum.rb +1 -1
- data/lib/rails_admin/config/fields/types/file_upload.rb +4 -3
- data/lib/rails_admin/config/fields/types/float.rb +9 -2
- data/lib/rails_admin/config/fields/types/has_many_association.rb +1 -5
- data/lib/rails_admin/config/fields/types/has_one_association.rb +1 -13
- data/lib/rails_admin/config/fields/types/integer.rb +2 -6
- data/lib/rails_admin/config/fields/types/multiple_active_storage.rb +8 -6
- data/lib/rails_admin/config/fields/types/multiple_carrierwave.rb +1 -0
- data/lib/rails_admin/config/fields/types/multiple_file_upload.rb +4 -3
- data/lib/rails_admin/config/fields/types/numeric.rb +18 -0
- data/lib/rails_admin/config/fields/types/polymorphic_association.rb +3 -2
- data/lib/rails_admin/config/fields/types/string.rb +1 -1
- data/lib/rails_admin/config/fields/types/time.rb +1 -4
- data/lib/rails_admin/config/fields/types/timestamp.rb +0 -4
- data/lib/rails_admin/config/fields/types.rb +1 -1
- data/lib/rails_admin/config/fields.rb +3 -1
- data/lib/rails_admin/config/has_fields.rb +5 -6
- data/lib/rails_admin/config/hideable.rb +1 -1
- data/lib/rails_admin/config/inspectable.rb +1 -3
- data/lib/rails_admin/config/model.rb +10 -10
- data/lib/rails_admin/config/sections/base.rb +2 -3
- data/lib/rails_admin/config/sections/list.rb +4 -15
- data/lib/rails_admin/config/sections.rb +1 -1
- data/lib/rails_admin/config.rb +73 -38
- data/lib/rails_admin/engine.rb +36 -23
- data/lib/rails_admin/extension.rb +6 -14
- data/lib/rails_admin/extensions/cancancan/authorization_adapter.rb +4 -2
- data/lib/rails_admin/extensions/paper_trail/auditing_adapter.rb +12 -7
- data/lib/rails_admin/extensions/pundit/authorization_adapter.rb +6 -7
- data/lib/rails_admin/support/csv_converter.rb +12 -13
- data/lib/rails_admin/support/datetime.rb +40 -74
- data/lib/rails_admin/support/esmodule_preprocessor.rb +32 -0
- data/lib/rails_admin/support/hash_helper.rb +6 -5
- data/lib/rails_admin/version.rb +8 -4
- data/lib/rails_admin.rb +1 -4
- data/lib/tasks/rails_admin.rake +3 -3
- data/package.json +28 -0
- data/src/rails_admin/base.js +21 -0
- data/src/rails_admin/filter-box.js +405 -0
- data/src/rails_admin/filtering-multiselect.js +394 -0
- data/src/rails_admin/filtering-select.js +302 -0
- data/src/rails_admin/i18n.js +19 -0
- data/src/rails_admin/nested-form-hooks.js +100 -0
- data/src/rails_admin/remote-form.js +190 -0
- data/src/rails_admin/sidescroll.js +20 -0
- data/{app/assets/stylesheets/rails_admin → src/rails_admin/styles}/base/theming.scss +93 -34
- data/src/rails_admin/styles/base.scss +64 -0
- data/src/rails_admin/styles/filtering-multiselect.scss +53 -0
- data/src/rails_admin/styles/filtering-select.scss +70 -0
- data/{app/assets/stylesheets/rails_admin → src/rails_admin/styles}/themes/cerulean/theming.scss +23 -21
- data/src/rails_admin/styles/themes/cerulean/variables.scss +830 -0
- data/{app/assets/stylesheets/rails_admin → src/rails_admin/styles}/themes/default/mixins.scss +1 -1
- data/{app/assets/stylesheets/rails_admin → src/rails_admin/styles}/themes/default/variables.scss +1 -1
- data/src/rails_admin/styles/widgets.scss +35 -0
- data/src/rails_admin/ui.js +172 -0
- data/src/rails_admin/vendor/jquery.pjax.js +899 -0
- data/src/rails_admin/vendor/jquery_nested_form.js +122 -0
- data/src/rails_admin/widgets.js +512 -0
- data/vendor/assets/fonts/rails_admin/fa-solid-900.eot +0 -0
- data/vendor/assets/fonts/rails_admin/fa-solid-900.svg +5034 -0
- data/vendor/assets/fonts/rails_admin/fa-solid-900.ttf +0 -0
- data/vendor/assets/fonts/rails_admin/fa-solid-900.woff +0 -0
- data/vendor/assets/fonts/rails_admin/fa-solid-900.woff2 +0 -0
- data/vendor/assets/javascripts/rails_admin/jquery-ui/data.js +41 -0
- data/vendor/assets/javascripts/rails_admin/jquery-ui/effect.js +1637 -0
- data/vendor/assets/javascripts/rails_admin/jquery-ui/ie.js +17 -0
- data/vendor/assets/javascripts/rails_admin/jquery-ui/keycode.js +47 -0
- data/vendor/assets/javascripts/rails_admin/jquery-ui/position.js +500 -0
- data/vendor/assets/javascripts/rails_admin/jquery-ui/safe-active-element.js +42 -0
- data/vendor/assets/javascripts/rails_admin/jquery-ui/scroll-parent.js +47 -0
- data/vendor/assets/javascripts/rails_admin/jquery-ui/unique-id.js +51 -0
- data/vendor/assets/javascripts/rails_admin/jquery-ui/version.js +17 -0
- data/vendor/assets/javascripts/rails_admin/jquery-ui/widget.js +735 -0
- data/vendor/assets/javascripts/rails_admin/jquery-ui/widgets/autocomplete.js +689 -0
- data/vendor/assets/javascripts/rails_admin/jquery-ui/widgets/menu.js +680 -0
- data/vendor/assets/javascripts/rails_admin/jquery-ui/widgets/mouse.js +230 -0
- data/vendor/assets/javascripts/rails_admin/jquery-ui/widgets/sortable.js +1561 -0
- data/vendor/assets/javascripts/rails_admin/jquery3.js +10872 -0
- data/vendor/assets/stylesheets/rails_admin/font-awesome.scss +4476 -2216
- metadata +118 -263
- data/app/assets/images/rails_admin/aristo/images/bg_fallback.png +0 -0
- data/app/assets/images/rails_admin/aristo/images/icon_sprite.png +0 -0
- data/app/assets/images/rails_admin/aristo/images/progress_bar.gif +0 -0
- data/app/assets/images/rails_admin/aristo/images/slider_handles.png +0 -0
- data/app/assets/images/rails_admin/aristo/images/ui-icons_222222_256x240.png +0 -0
- data/app/assets/images/rails_admin/aristo/images/ui-icons_454545_256x240.png +0 -0
- data/app/assets/images/rails_admin/bullet_black.png +0 -0
- data/app/assets/images/rails_admin/bullet_white.png +0 -0
- data/app/assets/images/rails_admin/calendar.png +0 -0
- data/app/assets/images/rails_admin/clock.png +0 -0
- data/app/assets/images/rails_admin/logo.png +0 -0
- data/app/assets/images/rails_admin/magnifier.png +0 -0
- data/app/assets/images/rails_admin/multiselect/icon_sprite.png +0 -0
- data/app/assets/images/rails_admin/multiselect/ui-icon-circle-triangle-n-dark.png +0 -0
- data/app/assets/images/rails_admin/multiselect/ui-icon-circle-triangle-n-light.png +0 -0
- data/app/assets/images/rails_admin/multiselect/ui-icon-circle-triangle-s-dark.png +0 -0
- data/app/assets/images/rails_admin/multiselect/ui-icon-circle-triangle-s-light.png +0 -0
- data/app/assets/javascripts/rails_admin/jquery-ui.js.erb +0 -8
- data/app/assets/javascripts/rails_admin/jquery.migrate.js +0 -3
- data/app/assets/javascripts/rails_admin/ra.filter-box.js +0 -253
- data/app/assets/javascripts/rails_admin/ra.filtering-multiselect.js +0 -331
- data/app/assets/javascripts/rails_admin/ra.filtering-select.js +0 -294
- data/app/assets/javascripts/rails_admin/ra.i18n.js +0 -28
- data/app/assets/javascripts/rails_admin/ra.nested-form-hooks.js +0 -59
- data/app/assets/javascripts/rails_admin/ra.remote-form.js +0 -155
- data/app/assets/javascripts/rails_admin/ra.sidescroll.js +0 -31
- data/app/assets/javascripts/rails_admin/ra.widgets.js +0 -379
- data/app/assets/javascripts/rails_admin/rails_admin.js +0 -21
- data/app/assets/javascripts/rails_admin/ui.js +0 -135
- data/app/assets/stylesheets/rails_admin/aristo/images/bg_fallback.png +0 -0
- data/app/assets/stylesheets/rails_admin/aristo/images/icon_sprite.png +0 -0
- data/app/assets/stylesheets/rails_admin/aristo/images/progress_bar.gif +0 -0
- data/app/assets/stylesheets/rails_admin/aristo/images/slider_handles.png +0 -0
- data/app/assets/stylesheets/rails_admin/aristo/images/ui-icons_222222_256x240.png +0 -0
- data/app/assets/stylesheets/rails_admin/aristo/images/ui-icons_454545_256x240.png +0 -0
- data/app/assets/stylesheets/rails_admin/aristo/jquery-ui-1.8.7.custom.scss +0 -733
- data/app/assets/stylesheets/rails_admin/base/font-awesome-4-compability.scss +0 -153
- data/app/assets/stylesheets/rails_admin/ra.filtering-multiselect.scss +0 -88
- data/app/assets/stylesheets/rails_admin/ra.sidescroll.scss +0 -29
- data/app/assets/stylesheets/rails_admin/ra.widgets.scss +0 -17
- data/app/assets/stylesheets/rails_admin/rails_admin.scss.erb +0 -110
- data/app/assets/stylesheets/rails_admin/themes/cerulean/variables.scss +0 -857
- data/app/views/kaminari/ra-twitter-bootstrap/_gap.html.haml +0 -2
- data/app/views/kaminari/ra-twitter-bootstrap/_next_page.html.haml +0 -4
- data/app/views/kaminari/ra-twitter-bootstrap/_page.html.haml +0 -4
- data/app/views/kaminari/ra-twitter-bootstrap/_paginator.html.haml +0 -9
- data/app/views/kaminari/ra-twitter-bootstrap/_prev_page.html.haml +0 -4
- data/app/views/kaminari/ra-twitter-bootstrap/without_count/_next_page.html.haml +0 -4
- data/app/views/kaminari/ra-twitter-bootstrap/without_count/_paginator.html.haml +0 -4
- data/app/views/kaminari/ra-twitter-bootstrap/without_count/_prev_page.html.haml +0 -4
- data/app/views/layouts/rails_admin/_head.html.haml +0 -7
- data/app/views/layouts/rails_admin/_navigation.html.haml +0 -12
- data/app/views/layouts/rails_admin/_secondary_navigation.html.haml +0 -10
- data/app/views/layouts/rails_admin/_sidebar_navigation.html.haml +0 -3
- data/app/views/layouts/rails_admin/application.html.haml +0 -16
- data/app/views/layouts/rails_admin/pjax.html.haml +0 -12
- data/app/views/rails_admin/main/_dashboard_history.html.haml +0 -21
- data/app/views/rails_admin/main/_delete_notice.html.haml +0 -24
- data/app/views/rails_admin/main/_form_action_text.html.haml +0 -7
- data/app/views/rails_admin/main/_form_boolean.html.haml +0 -3
- data/app/views/rails_admin/main/_form_code_mirror.html.haml +0 -9
- data/app/views/rails_admin/main/_form_colorpicker.html.haml +0 -1
- data/app/views/rails_admin/main/_form_datetime.html.haml +0 -5
- data/app/views/rails_admin/main/_form_enumeration.html.haml +0 -19
- data/app/views/rails_admin/main/_form_field.html.haml +0 -1
- data/app/views/rails_admin/main/_form_file_upload.html.haml +0 -17
- data/app/views/rails_admin/main/_form_froala.html.haml +0 -8
- data/app/views/rails_admin/main/_form_multiple_file_upload.html.haml +0 -16
- data/app/views/rails_admin/main/_form_nested_many.html.haml +0 -15
- data/app/views/rails_admin/main/_form_nested_one.html.haml +0 -17
- data/app/views/rails_admin/main/_form_polymorphic_association.html.haml +0 -26
- data/app/views/rails_admin/main/_form_simple_mde.haml +0 -8
- data/app/views/rails_admin/main/_form_text.html.haml +0 -1
- data/app/views/rails_admin/main/_form_wysihtml5.html.haml +0 -8
- data/app/views/rails_admin/main/_submit_buttons.html.haml +0 -16
- data/app/views/rails_admin/main/bulk_delete.html.haml +0 -11
- data/app/views/rails_admin/main/dashboard.html.haml +0 -34
- data/app/views/rails_admin/main/delete.html.haml +0 -18
- data/app/views/rails_admin/main/edit.html.haml +0 -2
- data/app/views/rails_admin/main/export.html.haml +0 -92
- data/app/views/rails_admin/main/history.html.haml +0 -51
- data/app/views/rails_admin/main/index.html.haml +0 -126
- data/app/views/rails_admin/main/new.html.haml +0 -2
- data/app/views/rails_admin/main/show.html.haml +0 -15
- data/config/initializers/haml.rb +0 -5
- data/lib/rails_admin/adapters/active_record/abstract_object.rb +0 -38
- data/lib/rails_admin/adapters/active_record.rb.bak +0 -348
- data/lib/rails_admin/adapters/mongoid/abstract_object.rb +0 -42
- data/lib/rails_admin/bootstrap-sass/compass_functions.rb +0 -28
- data/lib/rails_admin/bootstrap-sass/sass_functions.rb +0 -16
- data/lib/rails_admin/bootstrap-sass.rb +0 -49
- data/lib/rails_admin/config/lazy_model.rb +0 -68
- data/lib/rails_admin/extensions/history/auditing_adapter.rb +0 -37
- data/lib/rails_admin/extensions/history/history.rb +0 -44
- data/lib/rails_admin/extensions/history.rb +0 -3
- data/lib/rails_admin/support/i18n.rb +0 -43
- data/vendor/assets/fonts/rails_admin/FontAwesome.otf +0 -0
- data/vendor/assets/fonts/rails_admin/fontawesome-webfont.eot +0 -0
- data/vendor/assets/fonts/rails_admin/fontawesome-webfont.svg +0 -2671
- data/vendor/assets/fonts/rails_admin/fontawesome-webfont.ttf +0 -0
- data/vendor/assets/fonts/rails_admin/fontawesome-webfont.woff +0 -0
- data/vendor/assets/fonts/rails_admin/fontawesome-webfont.woff2 +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/colorpicker_background.png +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/colorpicker_hex.png +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/colorpicker_hsb_b.png +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/colorpicker_hsb_h.png +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/colorpicker_hsb_s.png +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/colorpicker_indic.gif +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/colorpicker_overlay.png +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/colorpicker_rgb_b.png +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/colorpicker_rgb_g.png +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/colorpicker_rgb_r.png +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/colorpicker_select.gif +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/colorpicker_submit.png +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/custom_background.png +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/custom_hex.png +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/custom_hsb_b.png +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/custom_hsb_h.png +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/custom_hsb_s.png +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/custom_indic.gif +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/custom_rgb_b.png +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/custom_rgb_g.png +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/custom_rgb_r.png +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/custom_submit.png +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/select.png +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/select2.png +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/slider.png +0 -0
- data/vendor/assets/javascripts/rails_admin/jquery.colorpicker.js +0 -484
- data/vendor/assets/stylesheets/rails_admin/jquery.colorpicker.scss +0 -182
- /data/{app/assets/stylesheets/rails_admin → src/rails_admin/styles}/base/README.txt +0 -0
- /data/{app/assets/stylesheets/rails_admin → src/rails_admin/styles}/base/mixins.scss +0 -0
- /data/{app/assets/stylesheets/rails_admin → src/rails_admin/styles}/base/variables.scss +0 -0
- /data/{app/assets/stylesheets/rails_admin → src/rails_admin/styles}/themes/cerulean/mixins.scss +0 -0
- /data/{app/assets/stylesheets/rails_admin → src/rails_admin/styles}/themes/default/theming.scss +0 -0
@@ -8,10 +8,7 @@ module RailsAdmin
|
|
8
8
|
RailsAdmin::Config::Fields::Types.register(self)
|
9
9
|
|
10
10
|
def parse_value(value)
|
11
|
-
|
12
|
-
return unless parent_value
|
13
|
-
value_with_tz = parent_value.in_time_zone
|
14
|
-
::DateTime.parse(value_with_tz.strftime('%Y-%m-%d %H:%M:%S'))
|
11
|
+
abstract_model.model.type_for_attribute(name.to_s).serialize(super)&.change(year: 2000, month: 1, day: 1)
|
15
12
|
end
|
16
13
|
|
17
14
|
register_instance_option :strftime_format do
|
@@ -7,10 +7,6 @@ module RailsAdmin
|
|
7
7
|
class Timestamp < RailsAdmin::Config::Fields::Types::Datetime
|
8
8
|
# Register field type for the type loader
|
9
9
|
RailsAdmin::Config::Fields::Types.register(self)
|
10
|
-
|
11
|
-
@format = :long
|
12
|
-
@i18n_scope = [:time, :formats]
|
13
|
-
@js_plugin_options = {}
|
14
10
|
end
|
15
11
|
end
|
16
12
|
end
|
@@ -9,7 +9,7 @@ module RailsAdmin
|
|
9
9
|
@@registry = {}
|
10
10
|
|
11
11
|
def self.load(type)
|
12
|
-
@@registry
|
12
|
+
@@registry.fetch(type.to_sym) { raise "Unsupported field datatype: #{type}" }
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.register(type, klass = nil)
|
@@ -50,13 +50,15 @@ module RailsAdmin
|
|
50
50
|
parent.abstract_model.properties.each do |properties|
|
51
51
|
# Unless a previous factory has already loaded current field as well
|
52
52
|
next if fields.detect { |f| f.name == properties.name }
|
53
|
+
|
53
54
|
# Loop through factories until one returns true
|
54
55
|
@@registry.detect { |factory| factory.call(parent, properties, fields) }
|
55
56
|
end
|
56
57
|
# Load fields for all associations (relations)
|
57
|
-
parent.abstract_model.associations.
|
58
|
+
parent.abstract_model.associations.reject { |a| a.type == :belongs_to }.each do |association| # :belongs_to are created by factory for belongs_to fields
|
58
59
|
# Unless a previous factory has already loaded current field as well
|
59
60
|
next if fields.detect { |f| f.name == association.name }
|
61
|
+
|
60
62
|
# Loop through factories until one returns true
|
61
63
|
@@registry.detect { |factory| factory.call(parent, association, fields) }
|
62
64
|
end
|
@@ -8,9 +8,7 @@ module RailsAdmin
|
|
8
8
|
|
9
9
|
# some fields are hidden by default (belongs_to keys, has_many associations in list views.)
|
10
10
|
# unhide them if config specifically defines them
|
11
|
-
if field
|
12
|
-
field.show unless field.instance_variable_get("@#{field.name}_registered").is_a?(Proc)
|
13
|
-
end
|
11
|
+
field.show if field && !field.instance_variable_get("@#{field.name}_registered").is_a?(Proc)
|
14
12
|
# Specify field as virtual if type is not specifically set and field was not
|
15
13
|
# found in default stack
|
16
14
|
if field.nil? && type.nil?
|
@@ -39,9 +37,9 @@ module RailsAdmin
|
|
39
37
|
field
|
40
38
|
end
|
41
39
|
|
42
|
-
# configure a
|
40
|
+
# configure field(s) from the default group in a section without changing the original order.
|
43
41
|
def configure(name, type = nil, &block)
|
44
|
-
field(
|
42
|
+
[*name].each { |field_name| field(field_name, type, false, &block) }
|
45
43
|
end
|
46
44
|
|
47
45
|
# include fields by name and apply an optionnal block to each (through a call to fields),
|
@@ -50,6 +48,7 @@ module RailsAdmin
|
|
50
48
|
if field_names.empty?
|
51
49
|
_fields.select { |f| f.instance_eval(&block) }.each do |f|
|
52
50
|
next if f.defined
|
51
|
+
|
53
52
|
f.defined = true
|
54
53
|
f.order = _fields.count(&:defined)
|
55
54
|
end
|
@@ -126,7 +125,7 @@ module RailsAdmin
|
|
126
125
|
return @_fields if @_fields
|
127
126
|
return @_ro_fields if readonly && @_ro_fields
|
128
127
|
|
129
|
-
if
|
128
|
+
if instance_of?(RailsAdmin::Config::Sections::Base)
|
130
129
|
@_ro_fields = @_fields = RailsAdmin::Config::Fields.factory(self)
|
131
130
|
else
|
132
131
|
# parent is RailsAdmin::Config::Model, recursion is on Section's classes
|
@@ -30,9 +30,7 @@ module RailsAdmin
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def set_named_instance_variables
|
33
|
-
unless defined?(self.class::NAMED_INSTANCE_VARIABLES)
|
34
|
-
self.class.const_set('NAMED_INSTANCE_VARIABLES', [])
|
35
|
-
end
|
33
|
+
self.class.const_set('NAMED_INSTANCE_VARIABLES', []) unless defined?(self.class::NAMED_INSTANCE_VARIABLES)
|
36
34
|
end
|
37
35
|
end
|
38
36
|
end
|
@@ -21,30 +21,31 @@ module RailsAdmin
|
|
21
21
|
include RailsAdmin::Config::Sections
|
22
22
|
include RailsAdmin::Config::Inspectable
|
23
23
|
|
24
|
-
attr_reader :abstract_model
|
24
|
+
attr_reader :abstract_model, :parent, :root
|
25
25
|
attr_accessor :groups
|
26
|
-
attr_reader :parent, :root
|
27
26
|
|
28
|
-
NAMED_INSTANCE_VARIABLES = [
|
27
|
+
NAMED_INSTANCE_VARIABLES = %i[@parent @root].freeze
|
29
28
|
|
30
29
|
def initialize(entity)
|
31
30
|
@parent = nil
|
32
31
|
@root = self
|
33
32
|
|
34
|
-
@abstract_model =
|
35
|
-
|
33
|
+
@abstract_model =
|
34
|
+
case entity
|
35
|
+
when RailsAdmin::AbstractModel
|
36
36
|
entity
|
37
|
-
|
37
|
+
when Class, String, Symbol
|
38
38
|
RailsAdmin::AbstractModel.new(entity)
|
39
39
|
else
|
40
40
|
RailsAdmin::AbstractModel.new(entity.class)
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
43
|
@groups = [RailsAdmin::Config::Fields::Group.new(self, :default).tap { |g| g.label { I18n.translate('admin.form.basic_info') } }]
|
44
44
|
end
|
45
45
|
|
46
46
|
def excluded?
|
47
47
|
return @excluded if defined?(@excluded)
|
48
|
+
|
48
49
|
@excluded = !RailsAdmin::AbstractModel.all.collect(&:model_name).include?(abstract_model.try(:model_name))
|
49
50
|
end
|
50
51
|
|
@@ -81,17 +82,16 @@ module RailsAdmin
|
|
81
82
|
register_instance_option :parent do
|
82
83
|
@parent_model ||= begin
|
83
84
|
klass = abstract_model.model.superclass
|
84
|
-
klass = nil if klass.to_s.in?(%w
|
85
|
+
klass = nil if klass.to_s.in?(%w[Object BasicObject ActiveRecord::Base])
|
85
86
|
klass
|
86
87
|
end
|
87
88
|
end
|
88
89
|
|
89
90
|
register_instance_option :navigation_label do
|
90
|
-
@navigation_label ||=
|
91
|
+
@navigation_label ||=
|
91
92
|
if (parent_module = abstract_model.model.try(:module_parent) || abstract_model.model.try!(:parent)) != Object
|
92
93
|
parent_module.to_s
|
93
94
|
end
|
94
|
-
end
|
95
95
|
end
|
96
96
|
|
97
97
|
register_instance_option :navigation_icon do
|
@@ -18,10 +18,9 @@ module RailsAdmin
|
|
18
18
|
include RailsAdmin::Config::HasGroups
|
19
19
|
include RailsAdmin::Config::HasDescription
|
20
20
|
|
21
|
-
attr_reader :abstract_model
|
22
|
-
attr_reader :parent, :root
|
21
|
+
attr_reader :abstract_model, :parent, :root
|
23
22
|
|
24
|
-
NAMED_INSTANCE_VARIABLES = [
|
23
|
+
NAMED_INSTANCE_VARIABLES = %i[@parent @root @abstract_model].freeze
|
25
24
|
|
26
25
|
def initialize(parent)
|
27
26
|
@parent = parent
|
@@ -44,23 +44,12 @@ module RailsAdmin
|
|
44
44
|
''
|
45
45
|
end
|
46
46
|
|
47
|
-
|
48
|
-
|
47
|
+
register_deprecated_instance_option :sidescroll do
|
48
|
+
ActiveSupport::Deprecation.warn('The sidescroll configuration option was removed, it is always enabled now.')
|
49
49
|
end
|
50
50
|
|
51
|
-
def
|
52
|
-
|
53
|
-
model_config = sidescroll
|
54
|
-
enabled = model_config.nil? ? global_config : model_config
|
55
|
-
if enabled
|
56
|
-
num_frozen = model_config[:num_frozen_columns] if model_config.is_a?(Hash)
|
57
|
-
unless num_frozen
|
58
|
-
num_frozen = global_config[:num_frozen_columns] if global_config.is_a?(Hash)
|
59
|
-
num_frozen ||= 3 # by default, freeze checkboxes, links & first property (usually primary key / id?)
|
60
|
-
num_frozen -= 1 unless checkboxes? # model config should be explicit about this, only adjust if using global config
|
61
|
-
end
|
62
|
-
num_frozen
|
63
|
-
end
|
51
|
+
def fields_for_table
|
52
|
+
visible_fields.partition(&:sticky?).flatten
|
64
53
|
end
|
65
54
|
end
|
66
55
|
end
|
@@ -25,7 +25,7 @@ module RailsAdmin
|
|
25
25
|
section = RailsAdmin::Config::Sections.const_get(name)
|
26
26
|
name = name.to_s.underscore.to_sym
|
27
27
|
klass.send(:define_method, name) do |&block|
|
28
|
-
@sections
|
28
|
+
@sections ||= {}
|
29
29
|
@sections[name] = section.new(self) unless @sections[name]
|
30
30
|
@sections[name].instance_eval(&block) if block
|
31
31
|
@sections[name]
|
data/lib/rails_admin/config.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'rails_admin/config/
|
1
|
+
require 'rails_admin/config/model'
|
2
2
|
require 'rails_admin/config/sections/list'
|
3
3
|
require 'active_support/core_ext/module/attribute_accessors'
|
4
4
|
|
@@ -20,6 +20,10 @@ module RailsAdmin
|
|
20
20
|
|
21
21
|
DEFAULT_CURRENT_USER = proc {}
|
22
22
|
|
23
|
+
# Variables to track initialization process
|
24
|
+
@initialized = false
|
25
|
+
@deferred_blocks = []
|
26
|
+
|
23
27
|
class << self
|
24
28
|
# Application title, can be an array of two elements
|
25
29
|
attr_accessor :main_app_name
|
@@ -27,8 +31,8 @@ module RailsAdmin
|
|
27
31
|
# Configuration option to specify which models you want to exclude.
|
28
32
|
attr_accessor :excluded_models
|
29
33
|
|
30
|
-
# Configuration option to specify a
|
31
|
-
# The excluded_models list applies against the
|
34
|
+
# Configuration option to specify a allowlist of models you want to RailsAdmin to work with.
|
35
|
+
# The excluded_models list applies against the allowlist as well and further reduces the models
|
32
36
|
# RailsAdmin will use.
|
33
37
|
# If included_models is left empty ([]), then RailsAdmin will automatically use all the models
|
34
38
|
# in your application (less any excluded_models you may have specified).
|
@@ -56,14 +60,8 @@ module RailsAdmin
|
|
56
60
|
# Tell browsers whether to use the native HTML5 validations (novalidate form option).
|
57
61
|
attr_accessor :browser_validations
|
58
62
|
|
59
|
-
# Set the max width of columns in list view before a new set is created
|
60
|
-
attr_accessor :total_columns_width
|
61
|
-
|
62
|
-
# Enable horizontal-scrolling table in list view, ignore total_columns_width
|
63
|
-
attr_accessor :sidescroll
|
64
|
-
|
65
63
|
# set parent controller
|
66
|
-
|
64
|
+
attr_reader :parent_controller
|
67
65
|
|
68
66
|
# set settings for `protect_from_forgery` method
|
69
67
|
# By default, it raises exception upon invalid CSRF tokens
|
@@ -82,6 +80,25 @@ module RailsAdmin
|
|
82
80
|
attr_accessor :navigation_static_links
|
83
81
|
attr_accessor :navigation_static_label
|
84
82
|
|
83
|
+
# Set where RailsAdmin fetches JS/CSS from, defaults to :sprockets
|
84
|
+
attr_accessor :asset_source
|
85
|
+
|
86
|
+
# Finish initialization by executing deferred configuration blocks
|
87
|
+
def initialize!
|
88
|
+
@deferred_blocks.each { |block| block.call(self) }
|
89
|
+
@deferred_blocks.clear
|
90
|
+
@initialized = true
|
91
|
+
end
|
92
|
+
|
93
|
+
# Evaluate the given block either immediately or lazily, based on initialization status.
|
94
|
+
def apply(&block)
|
95
|
+
if @initialized
|
96
|
+
yield(self)
|
97
|
+
else
|
98
|
+
@deferred_blocks << block
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
85
102
|
# Setup authentication to be run as a before filter
|
86
103
|
# This is run inside the controller instance so you can setup any authentication you need to
|
87
104
|
#
|
@@ -110,7 +127,7 @@ module RailsAdmin
|
|
110
127
|
@authenticate || DEFAULT_AUTHENTICATION
|
111
128
|
end
|
112
129
|
|
113
|
-
# Setup auditing/
|
130
|
+
# Setup auditing/versioning provider that observe objects lifecycle
|
114
131
|
def audit_with(*args, &block)
|
115
132
|
extension = args.shift
|
116
133
|
if extension
|
@@ -145,7 +162,7 @@ module RailsAdmin
|
|
145
162
|
# config.authorize_with :cancancan
|
146
163
|
# end
|
147
164
|
#
|
148
|
-
# See the wiki[https://github.com/
|
165
|
+
# See the wiki[https://github.com/railsadminteam/rails_admin/wiki] for more on authorization.
|
149
166
|
#
|
150
167
|
# @see RailsAdmin::Config::DEFAULT_AUTHORIZE
|
151
168
|
def authorize_with(*args, &block)
|
@@ -198,10 +215,10 @@ module RailsAdmin
|
|
198
215
|
end
|
199
216
|
|
200
217
|
def default_search_operator=(operator)
|
201
|
-
if %w
|
218
|
+
if %w[default like not_like starts_with ends_with is =].include? operator
|
202
219
|
@default_search_operator = operator
|
203
220
|
else
|
204
|
-
raise
|
221
|
+
raise ArgumentError.new("Search operator '#{operator}' not supported")
|
205
222
|
end
|
206
223
|
end
|
207
224
|
|
@@ -223,20 +240,20 @@ module RailsAdmin
|
|
223
240
|
#
|
224
241
|
# @see RailsAdmin::Config.registry
|
225
242
|
def model(entity, &block)
|
226
|
-
key =
|
227
|
-
|
243
|
+
key =
|
244
|
+
case entity
|
245
|
+
when RailsAdmin::AbstractModel
|
228
246
|
entity.model.try(:name).try :to_sym
|
229
|
-
|
247
|
+
when Class
|
230
248
|
entity.name.to_sym
|
231
|
-
|
249
|
+
when String, Symbol
|
232
250
|
entity.to_sym
|
233
251
|
else
|
234
252
|
entity.class.name.to_sym
|
235
253
|
end
|
236
|
-
end
|
237
254
|
|
238
|
-
@registry[key] ||= RailsAdmin::Config::
|
239
|
-
@registry[key].
|
255
|
+
@registry[key] ||= RailsAdmin::Config::Model.new(entity)
|
256
|
+
@registry[key].instance_eval(&block) if block && @registry[key].abstract_model
|
240
257
|
@registry[key]
|
241
258
|
end
|
242
259
|
|
@@ -250,9 +267,28 @@ module RailsAdmin
|
|
250
267
|
end
|
251
268
|
end
|
252
269
|
|
253
|
-
|
270
|
+
def parent_controller=(name)
|
271
|
+
@parent_controller = name
|
272
|
+
if defined?(RailsAdmin::ApplicationController)
|
273
|
+
RailsAdmin.send(:remove_const, :ApplicationController)
|
274
|
+
load RailsAdmin::Engine.root.join('app/controllers/rails_admin/application_controller.rb')
|
275
|
+
end
|
276
|
+
end
|
277
|
+
|
278
|
+
def total_columns_width=(_)
|
279
|
+
ActiveSupport::Deprecation.warn('The total_columns_width configuration option is deprecated and has no effect.')
|
280
|
+
end
|
281
|
+
|
282
|
+
def sidescroll=(_)
|
283
|
+
ActiveSupport::Deprecation.warn('The sidescroll configuration option was removed, it is always enabled now.')
|
284
|
+
end
|
285
|
+
|
286
|
+
# Setup actions to be used.
|
254
287
|
def actions(&block)
|
255
|
-
|
288
|
+
return unless block
|
289
|
+
|
290
|
+
RailsAdmin::Config::Actions.reset
|
291
|
+
RailsAdmin::Config::Actions.instance_eval(&block)
|
256
292
|
end
|
257
293
|
|
258
294
|
# Returns all model configurations
|
@@ -274,24 +310,24 @@ module RailsAdmin
|
|
274
310
|
@current_user = nil
|
275
311
|
@default_hidden_fields = {}
|
276
312
|
@default_hidden_fields[:base] = [:_type]
|
277
|
-
@default_hidden_fields[:edit] = [
|
278
|
-
@default_hidden_fields[:show] = [
|
313
|
+
@default_hidden_fields[:edit] = %i[id _id created_at created_on deleted_at updated_at updated_on deleted_on]
|
314
|
+
@default_hidden_fields[:show] = %i[id _id created_at created_on deleted_at updated_at updated_on deleted_on]
|
279
315
|
@default_items_per_page = 20
|
280
316
|
@default_associated_collection_limit = 100
|
281
317
|
@default_search_operator = 'default'
|
282
318
|
@excluded_models = []
|
283
319
|
@included_models = []
|
284
|
-
@
|
285
|
-
@sidescroll = nil
|
286
|
-
@label_methods = [:name, :title]
|
320
|
+
@label_methods = %i[name title]
|
287
321
|
@main_app_name = proc { [Rails.application.engine_name.titleize.chomp(' Application'), 'Admin'] }
|
288
322
|
@registry = {}
|
289
323
|
@show_gravatar = true
|
290
324
|
@navigation_static_links = {}
|
291
325
|
@navigation_static_label = nil
|
326
|
+
@asset_source = (defined?(Webpacker) ? :webpacker : :sprockets)
|
292
327
|
@parent_controller = '::ActionController::Base'
|
293
328
|
@forgery_protection_settings = {with: :exception}
|
294
329
|
RailsAdmin::Config::Actions.reset
|
330
|
+
RailsAdmin::AbstractModel.reset
|
295
331
|
end
|
296
332
|
|
297
333
|
# Reset a provided model's configuration.
|
@@ -302,22 +338,21 @@ module RailsAdmin
|
|
302
338
|
@registry.delete(key)
|
303
339
|
end
|
304
340
|
|
305
|
-
#
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
341
|
+
# Perform reset, then load RailsAdmin initializer again
|
342
|
+
def reload!
|
343
|
+
@initialized = false
|
344
|
+
reset
|
345
|
+
load RailsAdmin::Engine.config.initializer_path
|
346
|
+
initialize!
|
311
347
|
end
|
312
348
|
|
313
349
|
# Get all models that are configured as visible sorted by their weight and label.
|
314
350
|
#
|
315
351
|
# @see RailsAdmin::Config::Hideable
|
316
|
-
|
317
352
|
def visible_models(bindings)
|
318
353
|
visible_models_with_bindings(bindings).sort do |a, b|
|
319
354
|
if (weight_order = a.weight <=> b.weight) == 0
|
320
|
-
a.label.
|
355
|
+
a.label.casecmp(b.label)
|
321
356
|
else
|
322
357
|
weight_order
|
323
358
|
end
|
@@ -334,9 +369,9 @@ module RailsAdmin
|
|
334
369
|
included_models.collect(&:to_s).presence || begin
|
335
370
|
@@system_models ||= # memoization for tests
|
336
371
|
([Rails.application] + Rails::Engine.subclasses.collect(&:instance)).flat_map do |app|
|
337
|
-
(app.paths['app/models'].to_a + app.
|
372
|
+
(app.paths['app/models'].to_a + app.config.eager_load_paths).collect do |load_path|
|
338
373
|
Dir.glob(app.root.join(load_path)).collect do |load_dir|
|
339
|
-
Dir.glob(load_dir
|
374
|
+
Dir.glob("#{load_dir}/**/*.rb").collect do |filename|
|
340
375
|
# app/models/module/class.rb => module/class.rb => module/class => Module::Class
|
341
376
|
lchomp(filename, "#{app.root.join(load_dir)}/").chomp('.rb').camelize
|
342
377
|
end
|
data/lib/rails_admin/engine.rb
CHANGED
@@ -1,11 +1,8 @@
|
|
1
|
-
require 'jquery-rails'
|
2
|
-
require 'jquery-ui-rails'
|
3
1
|
require 'kaminari'
|
4
2
|
require 'nested_form'
|
5
3
|
require 'rack-pjax'
|
6
4
|
require 'rails'
|
7
5
|
require 'rails_admin'
|
8
|
-
require 'remotipart'
|
9
6
|
|
10
7
|
module RailsAdmin
|
11
8
|
class Engine < Rails::Engine
|
@@ -14,27 +11,38 @@ module RailsAdmin
|
|
14
11
|
config.action_dispatch.rescue_responses['RailsAdmin::ActionNotAllowed'] = :forbidden
|
15
12
|
|
16
13
|
initializer 'RailsAdmin precompile hook', group: :all do |app|
|
17
|
-
app.config.assets
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
14
|
+
if app.config.respond_to?(:assets)
|
15
|
+
app.config.assets.precompile += %w[
|
16
|
+
rails_admin.js
|
17
|
+
rails_admin.css
|
18
|
+
]
|
19
|
+
app.config.assets.paths << RailsAdmin::Engine.root.join('src')
|
20
|
+
require 'rails_admin/support/esmodule_preprocessor'
|
21
|
+
Sprockets.register_preprocessor 'application/javascript', RailsAdmin::ESModulePreprocessor
|
22
|
+
end
|
23
23
|
end
|
24
24
|
|
25
25
|
initializer 'RailsAdmin setup middlewares' do |app|
|
26
26
|
app.config.middleware.use Rack::Pjax
|
27
27
|
end
|
28
28
|
|
29
|
-
initializer 'RailsAdmin reload config in development' do
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
29
|
+
initializer 'RailsAdmin reload config in development' do |app|
|
30
|
+
config.initializer_path = app.root.join('config/initializers/rails_admin.rb')
|
31
|
+
|
32
|
+
unless Rails.application.config.cache_classes
|
33
|
+
ActiveSupport::Reloader.before_class_unload do
|
34
|
+
RailsAdmin::Config.reload!
|
35
|
+
end
|
36
|
+
|
37
|
+
reloader = app.config.file_watcher.new([config.initializer_path], []) do
|
38
|
+
# Do nothing, ActiveSupport::Reloader will trigger class_unload! anyway
|
37
39
|
end
|
40
|
+
|
41
|
+
app.reloaders << reloader
|
42
|
+
app.reloader.to_run do
|
43
|
+
reloader.execute_if_updated { require_unload_lock! }
|
44
|
+
end
|
45
|
+
reloader.execute
|
38
46
|
end
|
39
47
|
end
|
40
48
|
|
@@ -49,20 +57,25 @@ module RailsAdmin
|
|
49
57
|
m.klass.name =~ /^ActionDispatch::Session::/
|
50
58
|
end
|
51
59
|
loaded = app.config.middleware.to_a.map(&:name)
|
52
|
-
required = %w
|
60
|
+
required = %w[ActionDispatch::Cookies ActionDispatch::Flash Rack::MethodOverride]
|
53
61
|
missing = required - loaded
|
54
62
|
unless missing.empty? && has_session_store
|
55
63
|
configs = missing.map { |m| "config.middleware.use #{m}" }
|
56
64
|
configs << "config.middleware.use #{app.config.session_store.try(:name) || 'ActionDispatch::Session::CookieStore'}, #{app.config.session_options}" unless has_session_store
|
57
|
-
raise
|
58
|
-
Required middlewares for RailsAdmin are not added
|
59
|
-
To fix this, add
|
65
|
+
raise <<~EOM
|
66
|
+
Required middlewares for RailsAdmin are not added
|
67
|
+
To fix this, add
|
60
68
|
|
61
|
-
|
69
|
+
#{configs.join("\n ")}
|
62
70
|
|
63
|
-
to config/application.rb.
|
71
|
+
to config/application.rb.
|
64
72
|
EOM
|
65
73
|
end
|
74
|
+
|
75
|
+
RailsAdmin::Config.initialize!
|
76
|
+
|
77
|
+
# Force route reload, since it doesn't reflect RailsAdmin action configuration yet
|
78
|
+
app.reload_routes!
|
66
79
|
end
|
67
80
|
end
|
68
81
|
end
|
@@ -15,27 +15,19 @@ module RailsAdmin
|
|
15
15
|
|
16
16
|
EXTENSIONS << extension_key
|
17
17
|
|
18
|
-
if options[:authorization]
|
19
|
-
AUTHORIZATION_ADAPTERS[extension_key] = extension_definition::AuthorizationAdapter
|
20
|
-
end
|
18
|
+
AUTHORIZATION_ADAPTERS[extension_key] = extension_definition::AuthorizationAdapter if options[:authorization]
|
21
19
|
|
22
|
-
if options[:configuration]
|
23
|
-
CONFIGURATION_ADAPTERS[extension_key] = extension_definition::ConfigurationAdapter
|
24
|
-
end
|
20
|
+
CONFIGURATION_ADAPTERS[extension_key] = extension_definition::ConfigurationAdapter if options[:configuration]
|
25
21
|
|
26
|
-
if options[:auditing]
|
27
|
-
AUDITING_ADAPTERS[extension_key] = extension_definition::AuditingAdapter
|
28
|
-
end
|
22
|
+
AUDITING_ADAPTERS[extension_key] = extension_definition::AuditingAdapter if options[:auditing]
|
29
23
|
end
|
30
24
|
|
31
25
|
# Setup all extensions for testing
|
32
26
|
def self.setup_all_extensions
|
33
27
|
(AUTHORIZATION_ADAPTERS.values + AUDITING_ADAPTERS.values).each do |klass|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
# ignore errors
|
38
|
-
end
|
28
|
+
klass.setup if klass.respond_to? :setup
|
29
|
+
rescue # rubocop:disable Style/RescueStandardError
|
30
|
+
# ignore errors
|
39
31
|
end
|
40
32
|
end
|
41
33
|
end
|
@@ -26,6 +26,7 @@ module RailsAdmin
|
|
26
26
|
# instance if it is available.
|
27
27
|
def authorize(action, abstract_model = nil, model_object = nil)
|
28
28
|
return unless action
|
29
|
+
|
29
30
|
action, subject = resolve_action_and_subject(action, abstract_model, model_object)
|
30
31
|
@controller.current_ability.authorize!(action, subject)
|
31
32
|
end
|
@@ -36,6 +37,7 @@ module RailsAdmin
|
|
36
37
|
# return a boolean whereas +authorize+ will raise an exception when not authorized.
|
37
38
|
def authorized?(action, abstract_model = nil, model_object = nil)
|
38
39
|
return unless action
|
40
|
+
|
39
41
|
action, subject = resolve_action_and_subject(action, abstract_model, model_object)
|
40
42
|
@controller.current_ability.can?(action, subject)
|
41
43
|
end
|
@@ -51,13 +53,13 @@ module RailsAdmin
|
|
51
53
|
# records. It should return a hash of attributes which match what the user
|
52
54
|
# is authorized to create.
|
53
55
|
def attributes_for(action, abstract_model)
|
54
|
-
@controller.current_ability.attributes_for(action, abstract_model
|
56
|
+
@controller.current_ability.attributes_for(action, abstract_model&.model)
|
55
57
|
end
|
56
58
|
|
57
59
|
private
|
58
60
|
|
59
61
|
def resolve_action_and_subject(action, abstract_model, model_object)
|
60
|
-
subject = model_object || abstract_model
|
62
|
+
subject = model_object || abstract_model&.model
|
61
63
|
if subject
|
62
64
|
[action, subject]
|
63
65
|
else
|