rails_admin 2.1.0 → 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 +7 -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 +6 -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 +27 -23
- 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 +27 -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 +13 -8
- 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 +7 -3
- 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/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/theming.scss +93 -34
- data/{app/assets/stylesheets/rails_admin → src/rails_admin/styles}/base/variables.scss +0 -0
- 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/mixins.scss +0 -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/theming.scss +0 -0
- 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/bootstrap/bootstrap-affix.js +50 -28
- data/vendor/assets/javascripts/rails_admin/bootstrap/bootstrap-alert.js +10 -7
- data/vendor/assets/javascripts/rails_admin/bootstrap/bootstrap-button.js +35 -20
- data/vendor/assets/javascripts/rails_admin/bootstrap/bootstrap-carousel.js +48 -25
- data/vendor/assets/javascripts/rails_admin/bootstrap/bootstrap-collapse.js +70 -28
- data/vendor/assets/javascripts/rails_admin/bootstrap/bootstrap-dropdown.js +56 -42
- data/vendor/assets/javascripts/rails_admin/bootstrap/bootstrap-modal.js +118 -40
- data/vendor/assets/javascripts/rails_admin/bootstrap/bootstrap-popover.js +26 -16
- data/vendor/assets/javascripts/rails_admin/bootstrap/bootstrap-scrollspy.js +29 -27
- data/vendor/assets/javascripts/rails_admin/bootstrap/bootstrap-tab.js +46 -19
- data/vendor/assets/javascripts/rails_admin/bootstrap/bootstrap-tooltip.js +280 -60
- data/vendor/assets/javascripts/rails_admin/bootstrap/bootstrap-transition.js +5 -5
- data/vendor/assets/javascripts/rails_admin/bootstrap-datetimepicker.js +317 -150
- 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/jquery.pjax.js +317 -160
- data/vendor/assets/javascripts/rails_admin/jquery3.js +10872 -0
- data/vendor/assets/javascripts/rails_admin/moment-with-locales.js +11210 -9290
- data/vendor/assets/stylesheets/rails_admin/font-awesome.scss +4476 -2216
- metadata +118 -262
- 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/ra.filter-box.js +0 -248
- 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 -20
- 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/devise_patch.rb +0 -9
- data/config/initializers/haml.rb +0 -5
- data/lib/rails_admin/adapters/active_record/abstract_object.rb +0 -32
- 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
@@ -19,7 +19,7 @@ module RailsAdmin
|
|
19
19
|
def new(m)
|
20
20
|
m = m.constantize unless m.is_a?(Class)
|
21
21
|
(am = old_new(m)).model && am.adapter ? am : nil
|
22
|
-
rescue LoadError, NameError
|
22
|
+
rescue *([LoadError, NameError] + (defined?(ActiveRecord) ? ['ActiveRecord::NoDatabaseError'.constantize] : []))
|
23
23
|
puts "[RailsAdmin] Could not load model #{m}, assuming model is non existing. (#{$ERROR_INFO})" unless Rails.env.test?
|
24
24
|
nil
|
25
25
|
end
|
@@ -124,6 +124,7 @@ module RailsAdmin
|
|
124
124
|
|
125
125
|
def to_statement
|
126
126
|
return if [@operator, @value].any? { |v| v == '_discard' }
|
127
|
+
|
127
128
|
unary_operators[@operator] || unary_operators[@value] ||
|
128
129
|
build_statement_for_type_generic
|
129
130
|
end
|
@@ -139,21 +140,22 @@ module RailsAdmin
|
|
139
140
|
case @type
|
140
141
|
when :date
|
141
142
|
build_statement_for_date
|
142
|
-
when :datetime, :timestamp
|
143
|
+
when :datetime, :timestamp, :time
|
143
144
|
build_statement_for_datetime_or_timestamp
|
144
145
|
end
|
145
146
|
end
|
146
147
|
end
|
147
148
|
|
148
149
|
def build_statement_for_type
|
149
|
-
raise
|
150
|
+
raise 'You must override build_statement_for_type in your StatementBuilder'
|
150
151
|
end
|
151
152
|
|
152
153
|
def build_statement_for_integer_decimal_or_float
|
153
154
|
case @value
|
154
|
-
when Array
|
155
|
+
when Array
|
155
156
|
val, range_begin, range_end = *@value.collect do |v|
|
156
157
|
next unless v.to_i.to_s == v || v.to_f.to_s == v
|
158
|
+
|
157
159
|
@type == :integer ? v.to_i : v.to_f
|
158
160
|
end
|
159
161
|
case @operator
|
@@ -171,24 +173,36 @@ module RailsAdmin
|
|
171
173
|
|
172
174
|
def build_statement_for_date
|
173
175
|
start_date, end_date = get_filtering_duration
|
174
|
-
|
175
|
-
|
176
|
+
if start_date
|
177
|
+
start_date = begin
|
178
|
+
start_date.to_date
|
179
|
+
rescue StandardError
|
180
|
+
nil
|
181
|
+
end
|
182
|
+
end
|
183
|
+
if end_date
|
184
|
+
end_date = begin
|
185
|
+
end_date.to_date
|
186
|
+
rescue StandardError
|
187
|
+
nil
|
188
|
+
end
|
189
|
+
end
|
176
190
|
range_filter(start_date, end_date)
|
177
191
|
end
|
178
192
|
|
179
193
|
def build_statement_for_datetime_or_timestamp
|
180
194
|
start_date, end_date = get_filtering_duration
|
181
|
-
start_date = start_date.
|
182
|
-
end_date = end_date.
|
195
|
+
start_date = start_date.beginning_of_day if start_date.is_a?(Date)
|
196
|
+
end_date = end_date.end_of_day if end_date.is_a?(Date)
|
183
197
|
range_filter(start_date, end_date)
|
184
198
|
end
|
185
199
|
|
186
200
|
def unary_operators
|
187
|
-
raise
|
201
|
+
raise 'You must override unary_operators in your StatementBuilder'
|
188
202
|
end
|
189
203
|
|
190
204
|
def range_filter(_min, _max)
|
191
|
-
raise
|
205
|
+
raise 'You must override range_filter in your StatementBuilder'
|
192
206
|
end
|
193
207
|
|
194
208
|
class FilteringDuration
|
@@ -30,7 +30,14 @@ module RailsAdmin
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def primary_key
|
33
|
-
|
33
|
+
return nil if polymorphic?
|
34
|
+
|
35
|
+
case type
|
36
|
+
when :has_one
|
37
|
+
association.klass.primary_key
|
38
|
+
else
|
39
|
+
association.association_primary_key
|
40
|
+
end.try(:to_sym)
|
34
41
|
end
|
35
42
|
|
36
43
|
def foreign_key
|
@@ -39,6 +46,7 @@ module RailsAdmin
|
|
39
46
|
|
40
47
|
def foreign_key_nullable?
|
41
48
|
return true if foreign_key.nil? || type != :has_many
|
49
|
+
|
42
50
|
(column = klass.columns_hash[foreign_key.to_s]).nil? || column.null
|
43
51
|
end
|
44
52
|
|
@@ -50,6 +58,17 @@ module RailsAdmin
|
|
50
58
|
nil
|
51
59
|
end
|
52
60
|
|
61
|
+
def key_accessor
|
62
|
+
case type
|
63
|
+
when :has_many, :has_and_belongs_to_many
|
64
|
+
"#{name.to_s.singularize}_ids".to_sym
|
65
|
+
when :has_one
|
66
|
+
"#{name}_id".to_sym
|
67
|
+
else
|
68
|
+
foreign_key
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
53
72
|
def as
|
54
73
|
options[:as].try :to_sym
|
55
74
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module RailsAdmin
|
2
|
+
module Adapters
|
3
|
+
module ActiveRecord
|
4
|
+
module ObjectExtension
|
5
|
+
def self.extended(object)
|
6
|
+
object.class.reflect_on_all_associations.each do |association|
|
7
|
+
association = Association.new(association, object.class)
|
8
|
+
case association.type
|
9
|
+
when :has_one
|
10
|
+
object.instance_eval <<-RUBY, __FILE__, __LINE__ + 1
|
11
|
+
def #{association.name}_id
|
12
|
+
self.#{association.name}&.id
|
13
|
+
end
|
14
|
+
|
15
|
+
def #{association.name}_id=(item_id)
|
16
|
+
self.#{association.name} = #{association.klass}.find_by_id(item_id)
|
17
|
+
end
|
18
|
+
RUBY
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def assign_attributes(attributes)
|
24
|
+
super if attributes
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -1,20 +1,21 @@
|
|
1
1
|
require 'active_record'
|
2
|
-
require 'rails_admin/adapters/active_record/abstract_object'
|
3
2
|
require 'rails_admin/adapters/active_record/association'
|
3
|
+
require 'rails_admin/adapters/active_record/object_extension'
|
4
4
|
require 'rails_admin/adapters/active_record/property'
|
5
5
|
|
6
6
|
module RailsAdmin
|
7
7
|
module Adapters
|
8
8
|
module ActiveRecord
|
9
|
-
DISABLED_COLUMN_TYPES = [
|
9
|
+
DISABLED_COLUMN_TYPES = %i[tsvector blob binary spatial hstore geometry].freeze
|
10
10
|
|
11
11
|
def new(params = {})
|
12
|
-
|
12
|
+
model.new(params).extend(ObjectExtension)
|
13
13
|
end
|
14
14
|
|
15
15
|
def get(id)
|
16
16
|
return unless object = model.where(primary_key => id).first
|
17
|
-
|
17
|
+
|
18
|
+
object.extend(ObjectExtension)
|
18
19
|
end
|
19
20
|
|
20
21
|
def scoped
|
@@ -32,9 +33,7 @@ module RailsAdmin
|
|
32
33
|
scope = scope.where(primary_key => options[:bulk_ids]) if options[:bulk_ids]
|
33
34
|
scope = query_scope(scope, options[:query]) if options[:query]
|
34
35
|
scope = filter_scope(scope, options[:filters]) if options[:filters]
|
35
|
-
if options[:page] && options[:per]
|
36
|
-
scope = scope.send(Kaminari.config.page_method_name, options[:page]).per(options[:per])
|
37
|
-
end
|
36
|
+
scope = scope.send(Kaminari.config.page_method_name, options[:page]).per(options[:per]) if options[:page] && options[:per]
|
38
37
|
scope = scope.reorder("#{options[:sort]} #{options[:sort_reverse] ? 'asc' : 'desc'}") if options[:sort]
|
39
38
|
scope
|
40
39
|
end
|
@@ -83,7 +82,7 @@ module RailsAdmin
|
|
83
82
|
when 'mysql2'
|
84
83
|
::ActiveRecord::Base.connection.raw_connection.encoding
|
85
84
|
when 'oracle_enhanced'
|
86
|
-
::ActiveRecord::Base.connection.select_one(
|
85
|
+
::ActiveRecord::Base.connection.select_one('SELECT dummy FROM DUAL').values.first.encoding
|
87
86
|
else
|
88
87
|
::ActiveRecord::Base.connection.select_one("SELECT '' AS str;").values.first.encoding
|
89
88
|
end
|
@@ -205,7 +204,9 @@ module RailsAdmin
|
|
205
204
|
alias_method :numeric_unary_operators, :boolean_unary_operators
|
206
205
|
|
207
206
|
def range_filter(min, max)
|
208
|
-
if min && max
|
207
|
+
if min && max && min == max
|
208
|
+
["(#{@column} = ?)", min]
|
209
|
+
elsif min && max
|
209
210
|
["(#{@column} BETWEEN ? AND ?)", min, max]
|
210
211
|
elsif min
|
211
212
|
["(#{@column} >= ?)", min]
|
@@ -218,7 +219,7 @@ module RailsAdmin
|
|
218
219
|
case @type
|
219
220
|
when :boolean then build_statement_for_boolean
|
220
221
|
when :integer, :decimal, :float then build_statement_for_integer_decimal_or_float
|
221
|
-
when :string, :text
|
222
|
+
when :string, :text, :citext then build_statement_for_string_or_text
|
222
223
|
when :enum then build_statement_for_enum
|
223
224
|
when :belongs_to_association then build_statement_for_belongs_to_association
|
224
225
|
when :uuid then build_statement_for_uuid
|
@@ -226,8 +227,8 @@ module RailsAdmin
|
|
226
227
|
end
|
227
228
|
|
228
229
|
def build_statement_for_boolean
|
229
|
-
return ["(#{@column} IS NULL OR #{@column} = ?)", false] if %w
|
230
|
-
return ["(#{@column} = ?)", true] if %w
|
230
|
+
return ["(#{@column} IS NULL OR #{@column} = ?)", false] if %w[false f 0].include?(@value)
|
231
|
+
return ["(#{@column} = ?)", true] if %w[true t 1].include?(@value)
|
231
232
|
end
|
232
233
|
|
233
234
|
def column_for_value(value)
|
@@ -236,6 +237,7 @@ module RailsAdmin
|
|
236
237
|
|
237
238
|
def build_statement_for_belongs_to_association
|
238
239
|
return if @value.blank?
|
240
|
+
|
239
241
|
["(#{@column} = ?)", @value.to_i] if @value.to_i.to_s == @value
|
240
242
|
end
|
241
243
|
|
@@ -244,13 +246,11 @@ module RailsAdmin
|
|
244
246
|
|
245
247
|
return ["(#{@column} = ?)", @value] if ['is', '='].include?(@operator)
|
246
248
|
|
247
|
-
unless [
|
248
|
-
@value = @value.mb_chars.downcase
|
249
|
-
end
|
249
|
+
@value = @value.mb_chars.downcase unless %w[postgresql postgis].include? ar_adapter
|
250
250
|
|
251
|
-
@value =
|
251
|
+
@value =
|
252
252
|
case @operator
|
253
|
-
when 'default', 'like'
|
253
|
+
when 'default', 'like', 'not_like'
|
254
254
|
"%#{@value}%"
|
255
255
|
when 'starts_with'
|
256
256
|
"#{@value}%"
|
@@ -259,10 +259,15 @@ module RailsAdmin
|
|
259
259
|
else
|
260
260
|
return
|
261
261
|
end
|
262
|
-
end
|
263
262
|
|
264
|
-
if [
|
265
|
-
|
263
|
+
if %w[postgresql postgis].include? ar_adapter
|
264
|
+
if @operator == 'not_like'
|
265
|
+
["(#{@column} NOT ILIKE ?)", @value]
|
266
|
+
else
|
267
|
+
["(#{@column} ILIKE ?)", @value]
|
268
|
+
end
|
269
|
+
elsif @operator == 'not_like'
|
270
|
+
["(LOWER(#{@column}) NOT LIKE ?)", @value]
|
266
271
|
else
|
267
272
|
["(LOWER(#{@column}) LIKE ?)", @value]
|
268
273
|
end
|
@@ -270,13 +275,12 @@ module RailsAdmin
|
|
270
275
|
|
271
276
|
def build_statement_for_enum
|
272
277
|
return if @value.blank?
|
278
|
+
|
273
279
|
["(#{@column} IN (?))", Array.wrap(@value)]
|
274
280
|
end
|
275
281
|
|
276
282
|
def build_statement_for_uuid
|
277
|
-
|
278
|
-
column_for_value(@value)
|
279
|
-
end
|
283
|
+
column_for_value(@value) if /\A[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}\z/.match?(@value.to_s)
|
280
284
|
end
|
281
285
|
|
282
286
|
def ar_adapter
|
@@ -4,6 +4,8 @@ module RailsAdmin
|
|
4
4
|
class Association
|
5
5
|
attr_reader :association, :model
|
6
6
|
|
7
|
+
delegate :autosave?, to: :association
|
8
|
+
|
7
9
|
def initialize(association, model)
|
8
10
|
@association = association
|
9
11
|
@model = model
|
@@ -28,12 +30,12 @@ module RailsAdmin
|
|
28
30
|
when :has_and_belongs_to_many, :references_and_referenced_in_many
|
29
31
|
:has_and_belongs_to_many
|
30
32
|
else
|
31
|
-
raise
|
33
|
+
raise "Unknown association type: #{macro.inspect}"
|
32
34
|
end
|
33
35
|
end
|
34
36
|
|
35
37
|
def klass
|
36
|
-
if polymorphic? && [
|
38
|
+
if polymorphic? && %i[referenced_in belongs_to].include?(macro)
|
37
39
|
polymorphic_parents(:mongoid, model.name, name) || []
|
38
40
|
else
|
39
41
|
association.klass
|
@@ -41,35 +43,61 @@ module RailsAdmin
|
|
41
43
|
end
|
42
44
|
|
43
45
|
def primary_key
|
44
|
-
|
46
|
+
case type
|
47
|
+
when :belongs_to, :has_and_belongs_to_many
|
48
|
+
association.primary_key.to_sym
|
49
|
+
else
|
50
|
+
:_id
|
51
|
+
end
|
45
52
|
end
|
46
53
|
|
47
54
|
def foreign_key
|
48
55
|
return if embeds?
|
49
|
-
|
56
|
+
|
57
|
+
begin
|
58
|
+
association.foreign_key.to_sym
|
59
|
+
rescue StandardError
|
60
|
+
nil
|
61
|
+
end
|
50
62
|
end
|
51
63
|
|
52
64
|
def foreign_key_nullable?
|
53
65
|
return if foreign_key.nil?
|
66
|
+
|
54
67
|
true
|
55
68
|
end
|
56
69
|
|
57
70
|
def foreign_type
|
58
|
-
return unless polymorphic? && [
|
71
|
+
return unless polymorphic? && %i[referenced_in belongs_to].include?(macro)
|
72
|
+
|
59
73
|
association.inverse_type.try(:to_sym) || :"#{name}_type"
|
60
74
|
end
|
61
75
|
|
62
76
|
def foreign_inverse_of
|
63
|
-
return unless polymorphic? && [
|
77
|
+
return unless polymorphic? && %i[referenced_in belongs_to].include?(macro)
|
78
|
+
|
64
79
|
inverse_of_field.try(:to_sym)
|
65
80
|
end
|
66
81
|
|
82
|
+
def key_accessor
|
83
|
+
case macro.to_sym
|
84
|
+
when :has_many
|
85
|
+
"#{name.to_s.singularize}_ids".to_sym
|
86
|
+
when :has_one
|
87
|
+
"#{name}_id".to_sym
|
88
|
+
when :embedded_in, :embeds_one, :embeds_many
|
89
|
+
nil
|
90
|
+
else
|
91
|
+
foreign_key
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
67
95
|
def as
|
68
96
|
association.as.try :to_sym
|
69
97
|
end
|
70
98
|
|
71
99
|
def polymorphic?
|
72
|
-
association.polymorphic? && [
|
100
|
+
association.polymorphic? && %i[referenced_in belongs_to].include?(macro)
|
73
101
|
end
|
74
102
|
|
75
103
|
def inverse_of
|
@@ -82,13 +110,14 @@ module RailsAdmin
|
|
82
110
|
|
83
111
|
def nested_options
|
84
112
|
nested = nested_attributes_options.try { |o| o[name] }
|
85
|
-
if !nested && [
|
113
|
+
if !nested && %i[embeds_one embeds_many].include?(macro.to_sym) && !cyclic?
|
86
114
|
raise <<-MSG.gsub(/^\s+/, '')
|
87
115
|
Embbeded association without accepts_nested_attributes_for can't be handled by RailsAdmin,
|
88
116
|
because embedded model doesn't have top-level access.
|
89
117
|
Please add `accepts_nested_attributes_for :#{association.name}' line to `#{model}' model.
|
90
118
|
MSG
|
91
119
|
end
|
120
|
+
|
92
121
|
nested
|
93
122
|
end
|
94
123
|
|
@@ -101,7 +130,7 @@ module RailsAdmin
|
|
101
130
|
end
|
102
131
|
|
103
132
|
def embeds?
|
104
|
-
[
|
133
|
+
%i[embeds_one embeds_many].include?(macro)
|
105
134
|
end
|
106
135
|
|
107
136
|
private
|
@@ -4,23 +4,22 @@ module RailsAdmin
|
|
4
4
|
module Adapters
|
5
5
|
module Mongoid
|
6
6
|
class Bson
|
7
|
-
OBJECT_ID =
|
7
|
+
OBJECT_ID =
|
8
8
|
if defined?(Moped::BSON)
|
9
9
|
Moped::BSON::ObjectId
|
10
10
|
elsif defined?(BSON::ObjectId)
|
11
11
|
BSON::ObjectId
|
12
12
|
end
|
13
|
-
end
|
14
13
|
|
15
14
|
class << self
|
16
15
|
def parse_object_id(value)
|
17
16
|
OBJECT_ID.from_string(value)
|
18
|
-
rescue => e
|
19
|
-
raise e if %w
|
17
|
+
rescue StandardError => e
|
18
|
+
raise e if %w[
|
20
19
|
Moped::Errors::InvalidObjectId
|
21
20
|
BSON::ObjectId::Invalid
|
22
21
|
BSON::InvalidObjectId
|
23
|
-
|
22
|
+
].exclude?(e.class.to_s)
|
24
23
|
end
|
25
24
|
end
|
26
25
|
end
|
@@ -9,7 +9,9 @@ module RailsAdmin
|
|
9
9
|
self.nested_attributes_options = {}
|
10
10
|
class << self
|
11
11
|
def rails_admin(&block)
|
12
|
-
RailsAdmin.config
|
12
|
+
RailsAdmin.config do |config|
|
13
|
+
config.model(self, &block)
|
14
|
+
end
|
13
15
|
end
|
14
16
|
|
15
17
|
alias_method :accepts_nested_attributes_for_without_rails_admin, :accepts_nested_attributes_for
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module RailsAdmin
|
2
|
+
module Adapters
|
3
|
+
module Mongoid
|
4
|
+
module ObjectExtension
|
5
|
+
def self.extended(object)
|
6
|
+
object.associations.each do |name, association|
|
7
|
+
association = Association.new(association, object.class)
|
8
|
+
case association.macro
|
9
|
+
when :has_many
|
10
|
+
unless association.autosave?
|
11
|
+
object.singleton_class.after_create do
|
12
|
+
send(name).each(&:save)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
when :has_one
|
16
|
+
unless association.autosave?
|
17
|
+
object.singleton_class.after_create do
|
18
|
+
send(name)&.save
|
19
|
+
end
|
20
|
+
end
|
21
|
+
object.instance_eval <<-RUBY, __FILE__, __LINE__ + 1
|
22
|
+
def #{name}_id=(item_id)
|
23
|
+
self.#{name} = (#{association.klass}.find(item_id) rescue nil)
|
24
|
+
end
|
25
|
+
RUBY
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -2,7 +2,7 @@ module RailsAdmin
|
|
2
2
|
module Adapters
|
3
3
|
module Mongoid
|
4
4
|
class Property
|
5
|
-
STRING_TYPE_COLUMN_NAMES = [
|
5
|
+
STRING_TYPE_COLUMN_NAMES = %i[name title subject].freeze
|
6
6
|
attr_reader :property, :model
|
7
7
|
|
8
8
|
def initialize(property, model)
|
@@ -71,7 +71,7 @@ module RailsAdmin
|
|
71
71
|
|
72
72
|
def object_field_type
|
73
73
|
association = Association.new model.relations.values.detect { |r| r.try(:foreign_key).try(:to_sym) == name }, model
|
74
|
-
if [
|
74
|
+
if %i[belongs_to referenced_in embedded_in].include?(association.macro)
|
75
75
|
:bson_object_id
|
76
76
|
else
|
77
77
|
:string
|
@@ -1,32 +1,35 @@
|
|
1
1
|
require 'mongoid'
|
2
2
|
require 'rails_admin/config/sections/list'
|
3
|
-
require 'rails_admin/adapters/mongoid/abstract_object'
|
4
3
|
require 'rails_admin/adapters/mongoid/association'
|
4
|
+
require 'rails_admin/adapters/mongoid/object_extension'
|
5
5
|
require 'rails_admin/adapters/mongoid/property'
|
6
6
|
require 'rails_admin/adapters/mongoid/bson'
|
7
7
|
|
8
8
|
module RailsAdmin
|
9
9
|
module Adapters
|
10
10
|
module Mongoid
|
11
|
-
DISABLED_COLUMN_TYPES = %w
|
11
|
+
DISABLED_COLUMN_TYPES = %w[Range Moped::BSON::Binary BSON::Binary Mongoid::Geospatial::Point].freeze
|
12
12
|
|
13
13
|
def parse_object_id(value)
|
14
14
|
Bson.parse_object_id(value)
|
15
15
|
end
|
16
16
|
|
17
17
|
def new(params = {})
|
18
|
-
|
18
|
+
model.new(params).extend(ObjectExtension)
|
19
19
|
end
|
20
20
|
|
21
21
|
def get(id)
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
object = model.find(id)
|
23
|
+
return nil unless object
|
24
|
+
|
25
|
+
object.extend(ObjectExtension)
|
26
|
+
rescue StandardError => e
|
27
|
+
raise e if %w[
|
25
28
|
Mongoid::Errors::DocumentNotFound
|
26
29
|
Mongoid::Errors::InvalidFind
|
27
30
|
Moped::Errors::InvalidObjectId
|
28
31
|
BSON::InvalidObjectId
|
29
|
-
|
32
|
+
].exclude?(e.class.to_s)
|
30
33
|
end
|
31
34
|
|
32
35
|
def scoped
|
@@ -44,13 +47,11 @@ module RailsAdmin
|
|
44
47
|
scope = scope.any_in(_id: options[:bulk_ids]) if options[:bulk_ids]
|
45
48
|
scope = query_scope(scope, options[:query]) if options[:query]
|
46
49
|
scope = filter_scope(scope, options[:filters]) if options[:filters]
|
47
|
-
if options[:page] && options[:per]
|
48
|
-
scope = scope.send(Kaminari.config.page_method_name, options[:page]).per(options[:per])
|
49
|
-
end
|
50
|
+
scope = scope.send(Kaminari.config.page_method_name, options[:page]).per(options[:per]) if options[:page] && options[:per]
|
50
51
|
scope = sort_by(options, scope) if options[:sort]
|
51
52
|
scope
|
52
53
|
rescue NoMethodError => e
|
53
|
-
if e.message
|
54
|
+
if /page/.match?(e.message)
|
54
55
|
e = e.exception <<-EOM.gsub(/^\s{12}/, '')
|
55
56
|
#{e.message}
|
56
57
|
If you don't have kaminari-mongoid installed, add `gem 'kaminari-mongoid'` to your Gemfile.
|
@@ -120,6 +121,7 @@ module RailsAdmin
|
|
120
121
|
collection_name, column_name = parse_collection_name(column_infos[:column])
|
121
122
|
statement = build_statement(column_name, column_infos[:type], value, operator)
|
122
123
|
next unless statement
|
124
|
+
|
123
125
|
conditions_per_collection[collection_name] ||= []
|
124
126
|
conditions_per_collection[collection_name] << statement
|
125
127
|
end
|
@@ -151,6 +153,7 @@ module RailsAdmin
|
|
151
153
|
filters_dump.each do |_, filter_dump|
|
152
154
|
field = fields.detect { |f| f.name.to_s == field_name }
|
153
155
|
next unless field
|
156
|
+
|
154
157
|
value = parse_field_value(field, filter_dump[:v])
|
155
158
|
conditions_per_collection = make_field_conditions(field, value, (filter_dump[:o] || 'default'))
|
156
159
|
field_statements = make_condition_for_current_collection(field, conditions_per_collection)
|
@@ -191,6 +194,7 @@ module RailsAdmin
|
|
191
194
|
def perform_search_on_associated_collection(field_name, conditions)
|
192
195
|
target_association = associations.detect { |a| a.name == field_name }
|
193
196
|
return [] unless target_association
|
197
|
+
|
194
198
|
model = target_association.klass
|
195
199
|
case target_association.type
|
196
200
|
when :belongs_to, :has_and_belongs_to_many
|
@@ -206,9 +210,7 @@ module RailsAdmin
|
|
206
210
|
case options[:sort]
|
207
211
|
when String
|
208
212
|
field_name, collection_name = options[:sort].split('.').reverse
|
209
|
-
if collection_name && collection_name != table_name
|
210
|
-
raise('sorting by associated model column is not supported in Non-Relational databases')
|
211
|
-
end
|
213
|
+
raise 'sorting by associated model column is not supported in Non-Relational databases' if collection_name && collection_name != table_name
|
212
214
|
when Symbol
|
213
215
|
field_name = options[:sort].to_s
|
214
216
|
end
|
@@ -246,8 +248,8 @@ module RailsAdmin
|
|
246
248
|
end
|
247
249
|
|
248
250
|
def build_statement_for_boolean
|
249
|
-
return {@column => false} if %w
|
250
|
-
return {@column => true} if %w
|
251
|
+
return {@column => false} if %w[false f 0].include?(@value)
|
252
|
+
return {@column => true} if %w[true t 1].include?(@value)
|
251
253
|
end
|
252
254
|
|
253
255
|
def column_for_value(value)
|
@@ -256,8 +258,11 @@ module RailsAdmin
|
|
256
258
|
|
257
259
|
def build_statement_for_string_or_text
|
258
260
|
return if @value.blank?
|
259
|
-
|
261
|
+
|
262
|
+
@value =
|
260
263
|
case @operator
|
264
|
+
when 'not_like'
|
265
|
+
Regexp.compile("^((?!#{Regexp.escape(@value)}).)*$", Regexp::IGNORECASE)
|
261
266
|
when 'default', 'like'
|
262
267
|
Regexp.compile(Regexp.escape(@value), Regexp::IGNORECASE)
|
263
268
|
when 'starts_with'
|
@@ -269,12 +274,13 @@ module RailsAdmin
|
|
269
274
|
else
|
270
275
|
return
|
271
276
|
end
|
272
|
-
|
277
|
+
|
273
278
|
{@column => @value}
|
274
279
|
end
|
275
280
|
|
276
281
|
def build_statement_for_enum
|
277
282
|
return if @value.blank?
|
283
|
+
|
278
284
|
{@column => {'$in' => Array.wrap(@value)}}
|
279
285
|
end
|
280
286
|
|
@@ -283,7 +289,9 @@ module RailsAdmin
|
|
283
289
|
end
|
284
290
|
|
285
291
|
def range_filter(min, max)
|
286
|
-
if min && max
|
292
|
+
if min && max && min == max
|
293
|
+
{@column => min}
|
294
|
+
elsif min && max
|
287
295
|
{@column => {'$gte' => min, '$lte' => max}}
|
288
296
|
elsif min
|
289
297
|
{@column => {'$gte' => min}}
|
@@ -36,7 +36,7 @@ module RailsAdmin
|
|
36
36
|
|
37
37
|
# http://getbootstrap.com/2.3.2/base-css.html#icons
|
38
38
|
register_instance_option :link_icon do
|
39
|
-
'
|
39
|
+
'fas fa-question'
|
40
40
|
end
|
41
41
|
|
42
42
|
# Should the action be visible
|
@@ -75,7 +75,12 @@ module RailsAdmin
|
|
75
75
|
|
76
76
|
# Render via pjax?
|
77
77
|
register_instance_option :pjax? do
|
78
|
-
|
78
|
+
link_target.blank?
|
79
|
+
end
|
80
|
+
|
81
|
+
# Target window [_self, _blank]
|
82
|
+
register_instance_option :link_target do
|
83
|
+
nil
|
79
84
|
end
|
80
85
|
|
81
86
|
# This block is evaluated in the context of the controller when action is called
|