rails_admin 2.3.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.

Files changed (329) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +9 -11
  3. data/README.md +37 -31
  4. data/Rakefile +2 -2
  5. data/app/assets/javascripts/rails_admin.js +21 -0
  6. data/app/assets/stylesheets/rails_admin/custom/mixins.scss +1 -1
  7. data/app/assets/stylesheets/rails_admin/custom/variables.scss +1 -1
  8. data/app/assets/stylesheets/rails_admin.scss.erb +76 -0
  9. data/app/controllers/rails_admin/application_controller.rb +4 -3
  10. data/app/controllers/rails_admin/main_controller.rb +43 -24
  11. data/app/helpers/rails_admin/application_helper.rb +69 -52
  12. data/app/helpers/rails_admin/form_builder.rb +5 -4
  13. data/app/helpers/rails_admin/main_helper.rb +27 -43
  14. data/app/views/kaminari/ra-twitter-bootstrap/_gap.html.erb +5 -0
  15. data/app/views/kaminari/ra-twitter-bootstrap/_next_page.html.erb +9 -0
  16. data/app/views/kaminari/ra-twitter-bootstrap/_page.html.erb +9 -0
  17. data/app/views/kaminari/ra-twitter-bootstrap/_paginator.html.erb +13 -0
  18. data/app/views/kaminari/ra-twitter-bootstrap/_prev_page.html.erb +9 -0
  19. data/app/views/kaminari/ra-twitter-bootstrap/without_count/_next_page.html.erb +9 -0
  20. data/app/views/kaminari/ra-twitter-bootstrap/without_count/_paginator.html.erb +6 -0
  21. data/app/views/kaminari/ra-twitter-bootstrap/without_count/_prev_page.html.erb +9 -0
  22. data/app/views/layouts/rails_admin/_head.html.erb +17 -0
  23. data/app/views/layouts/rails_admin/_navigation.html.erb +21 -0
  24. data/app/views/layouts/rails_admin/_secondary_navigation.html.erb +24 -0
  25. data/app/views/layouts/rails_admin/_sidebar_navigation.html.erb +9 -0
  26. data/app/views/layouts/rails_admin/application.html.erb +27 -0
  27. data/app/views/layouts/rails_admin/modal.js.erb +7 -0
  28. data/app/views/layouts/rails_admin/pjax.html.erb +20 -0
  29. data/app/views/rails_admin/main/_dashboard_history.html.erb +45 -0
  30. data/app/views/rails_admin/main/_delete_notice.html.erb +35 -0
  31. data/app/views/rails_admin/main/_form_action_text.html.erb +7 -0
  32. data/app/views/rails_admin/main/_form_boolean.html.erb +16 -0
  33. data/app/views/rails_admin/main/{_form_ck_editor.html.haml → _form_ck_editor.html.erb} +3 -3
  34. data/app/views/rails_admin/main/_form_code_mirror.html.erb +9 -0
  35. data/app/views/rails_admin/main/_form_colorpicker.html.erb +1 -0
  36. data/app/views/rails_admin/main/_form_datetime.html.erb +9 -0
  37. data/app/views/rails_admin/main/_form_enumeration.html.erb +21 -0
  38. data/app/views/rails_admin/main/_form_field.html.erb +1 -0
  39. data/app/views/rails_admin/main/_form_file_upload.html.erb +17 -0
  40. data/app/views/rails_admin/main/{_form_filtering_multiselect.html.haml → _form_filtering_multiselect.html.erb} +11 -11
  41. data/app/views/rails_admin/main/{_form_filtering_select.html.haml → _form_filtering_select.html.erb} +13 -12
  42. data/app/views/rails_admin/main/_form_froala.html.erb +8 -0
  43. data/app/views/rails_admin/main/_form_multiple_file_upload.html.erb +20 -0
  44. data/app/views/rails_admin/main/_form_nested_many.html.erb +21 -0
  45. data/app/views/rails_admin/main/_form_nested_one.html.erb +21 -0
  46. data/app/views/rails_admin/main/_form_polymorphic_association.html.erb +27 -0
  47. data/app/views/rails_admin/main/_form_simple_mde.html.erb +8 -0
  48. data/app/views/rails_admin/main/_form_text.html.erb +1 -0
  49. data/app/views/rails_admin/main/_form_wysihtml5.html.erb +8 -0
  50. data/app/views/rails_admin/main/_submit_buttons.html.erb +25 -0
  51. data/app/views/rails_admin/main/bulk_delete.html.erb +19 -0
  52. data/app/views/rails_admin/main/dashboard.html.erb +64 -0
  53. data/app/views/rails_admin/main/delete.html.erb +21 -0
  54. data/app/views/rails_admin/main/edit.html.erb +3 -0
  55. data/app/views/rails_admin/main/export.html.erb +146 -0
  56. data/app/views/rails_admin/main/history.html.erb +78 -0
  57. data/app/views/rails_admin/main/index.html.erb +193 -0
  58. data/app/views/rails_admin/main/new.html.erb +3 -0
  59. data/app/views/rails_admin/main/show.html.erb +28 -0
  60. data/config/initializers/active_record_extensions.rb +3 -1
  61. data/config/initializers/mongoid_extensions.rb +1 -1
  62. data/config/locales/rails_admin.en.yml +5 -1
  63. data/lib/generators/rails_admin/install_generator.rb +51 -3
  64. data/lib/generators/rails_admin/templates/environment.js +6 -0
  65. data/lib/generators/rails_admin/templates/initializer.erb +2 -1
  66. data/lib/generators/rails_admin/templates/rails_admin.js.erb +2 -0
  67. data/lib/generators/rails_admin/templates/rails_admin.scss +1 -0
  68. data/lib/generators/rails_admin/templates/webpack.config.js +32 -0
  69. data/lib/rails_admin/abstract_model.rb +24 -10
  70. data/lib/rails_admin/adapters/active_record/association.rb +20 -1
  71. data/lib/rails_admin/adapters/active_record/object_extension.rb +29 -0
  72. data/lib/rails_admin/adapters/active_record/property.rb +1 -1
  73. data/lib/rails_admin/adapters/active_record.rb +19 -21
  74. data/lib/rails_admin/adapters/mongoid/association.rb +38 -9
  75. data/lib/rails_admin/adapters/mongoid/bson.rb +4 -5
  76. data/lib/rails_admin/adapters/mongoid/extension.rb +3 -1
  77. data/lib/rails_admin/adapters/mongoid/object_extension.rb +32 -0
  78. data/lib/rails_admin/adapters/mongoid/property.rb +2 -2
  79. data/lib/rails_admin/adapters/mongoid.rb +25 -19
  80. data/lib/rails_admin/config/actions/base.rb +7 -2
  81. data/lib/rails_admin/config/actions/bulk_delete.rb +2 -2
  82. data/lib/rails_admin/config/actions/dashboard.rb +4 -3
  83. data/lib/rails_admin/config/actions/delete.rb +5 -9
  84. data/lib/rails_admin/config/actions/edit.rb +7 -7
  85. data/lib/rails_admin/config/actions/export.rb +2 -2
  86. data/lib/rails_admin/config/actions/history_index.rb +2 -2
  87. data/lib/rails_admin/config/actions/history_show.rb +2 -2
  88. data/lib/rails_admin/config/actions/index.rb +5 -7
  89. data/lib/rails_admin/config/actions/new.rb +9 -9
  90. data/lib/rails_admin/config/actions/show.rb +1 -1
  91. data/lib/rails_admin/config/actions/show_in_app.rb +6 -2
  92. data/lib/rails_admin/config/actions.rb +4 -4
  93. data/lib/rails_admin/config/configurable.rb +2 -2
  94. data/lib/rails_admin/config/fields/association.rb +15 -12
  95. data/lib/rails_admin/config/fields/base.rb +44 -24
  96. data/lib/rails_admin/config/fields/factories/active_storage.rb +1 -0
  97. data/lib/rails_admin/config/fields/factories/association.rb +6 -8
  98. data/lib/rails_admin/config/fields/factories/carrierwave.rb +2 -1
  99. data/lib/rails_admin/config/fields/factories/devise.rb +2 -1
  100. data/lib/rails_admin/config/fields/factories/dragonfly.rb +2 -1
  101. data/lib/rails_admin/config/fields/factories/paperclip.rb +2 -1
  102. data/lib/rails_admin/config/fields/factories/shrine.rb +1 -1
  103. data/lib/rails_admin/config/fields/group.rb +1 -2
  104. data/lib/rails_admin/config/fields/types/active_record_enum.rb +2 -0
  105. data/lib/rails_admin/config/fields/types/active_storage.rb +9 -7
  106. data/lib/rails_admin/config/fields/types/all.rb +1 -0
  107. data/lib/rails_admin/config/fields/types/belongs_to_association.rb +4 -12
  108. data/lib/rails_admin/config/fields/types/boolean.rb +32 -8
  109. data/lib/rails_admin/config/fields/types/carrierwave.rb +1 -0
  110. data/lib/rails_admin/config/fields/types/citext.rb +13 -0
  111. data/lib/rails_admin/config/fields/types/color.rb +6 -2
  112. data/lib/rails_admin/config/fields/types/date.rb +5 -8
  113. data/lib/rails_admin/config/fields/types/datetime.rb +18 -21
  114. data/lib/rails_admin/config/fields/types/decimal.rb +9 -2
  115. data/lib/rails_admin/config/fields/types/dragonfly.rb +3 -1
  116. data/lib/rails_admin/config/fields/types/enum.rb +1 -1
  117. data/lib/rails_admin/config/fields/types/file_upload.rb +4 -3
  118. data/lib/rails_admin/config/fields/types/float.rb +9 -2
  119. data/lib/rails_admin/config/fields/types/has_many_association.rb +1 -5
  120. data/lib/rails_admin/config/fields/types/has_one_association.rb +1 -13
  121. data/lib/rails_admin/config/fields/types/integer.rb +2 -6
  122. data/lib/rails_admin/config/fields/types/multiple_active_storage.rb +8 -6
  123. data/lib/rails_admin/config/fields/types/multiple_carrierwave.rb +1 -0
  124. data/lib/rails_admin/config/fields/types/multiple_file_upload.rb +4 -3
  125. data/lib/rails_admin/config/fields/types/numeric.rb +18 -0
  126. data/lib/rails_admin/config/fields/types/polymorphic_association.rb +3 -2
  127. data/lib/rails_admin/config/fields/types/string.rb +1 -1
  128. data/lib/rails_admin/config/fields/types/time.rb +1 -4
  129. data/lib/rails_admin/config/fields/types/timestamp.rb +0 -4
  130. data/lib/rails_admin/config/fields/types.rb +1 -1
  131. data/lib/rails_admin/config/fields.rb +3 -1
  132. data/lib/rails_admin/config/has_fields.rb +5 -6
  133. data/lib/rails_admin/config/hideable.rb +1 -1
  134. data/lib/rails_admin/config/inspectable.rb +1 -3
  135. data/lib/rails_admin/config/model.rb +10 -10
  136. data/lib/rails_admin/config/sections/base.rb +2 -3
  137. data/lib/rails_admin/config/sections/list.rb +4 -15
  138. data/lib/rails_admin/config/sections.rb +1 -1
  139. data/lib/rails_admin/config.rb +73 -38
  140. data/lib/rails_admin/engine.rb +36 -23
  141. data/lib/rails_admin/extension.rb +6 -14
  142. data/lib/rails_admin/extensions/cancancan/authorization_adapter.rb +4 -2
  143. data/lib/rails_admin/extensions/paper_trail/auditing_adapter.rb +12 -7
  144. data/lib/rails_admin/extensions/pundit/authorization_adapter.rb +6 -7
  145. data/lib/rails_admin/support/csv_converter.rb +12 -13
  146. data/lib/rails_admin/support/datetime.rb +40 -74
  147. data/lib/rails_admin/support/esmodule_preprocessor.rb +32 -0
  148. data/lib/rails_admin/support/hash_helper.rb +6 -5
  149. data/lib/rails_admin/version.rb +7 -3
  150. data/lib/rails_admin.rb +1 -4
  151. data/lib/tasks/rails_admin.rake +3 -3
  152. data/package.json +28 -0
  153. data/src/rails_admin/base.js +21 -0
  154. data/src/rails_admin/filter-box.js +405 -0
  155. data/src/rails_admin/filtering-multiselect.js +394 -0
  156. data/src/rails_admin/filtering-select.js +302 -0
  157. data/src/rails_admin/i18n.js +19 -0
  158. data/src/rails_admin/nested-form-hooks.js +100 -0
  159. data/src/rails_admin/remote-form.js +190 -0
  160. data/src/rails_admin/sidescroll.js +20 -0
  161. data/{app/assets/stylesheets/rails_admin → src/rails_admin/styles}/base/theming.scss +93 -34
  162. data/src/rails_admin/styles/base.scss +64 -0
  163. data/src/rails_admin/styles/filtering-multiselect.scss +53 -0
  164. data/src/rails_admin/styles/filtering-select.scss +70 -0
  165. data/{app/assets/stylesheets/rails_admin → src/rails_admin/styles}/themes/cerulean/theming.scss +23 -21
  166. data/src/rails_admin/styles/themes/cerulean/variables.scss +830 -0
  167. data/{app/assets/stylesheets/rails_admin → src/rails_admin/styles}/themes/default/mixins.scss +1 -1
  168. data/{app/assets/stylesheets/rails_admin → src/rails_admin/styles}/themes/default/variables.scss +1 -1
  169. data/src/rails_admin/styles/widgets.scss +35 -0
  170. data/src/rails_admin/ui.js +172 -0
  171. data/src/rails_admin/vendor/jquery.pjax.js +899 -0
  172. data/src/rails_admin/vendor/jquery_nested_form.js +122 -0
  173. data/src/rails_admin/widgets.js +512 -0
  174. data/vendor/assets/fonts/rails_admin/fa-solid-900.eot +0 -0
  175. data/vendor/assets/fonts/rails_admin/fa-solid-900.svg +5034 -0
  176. data/vendor/assets/fonts/rails_admin/fa-solid-900.ttf +0 -0
  177. data/vendor/assets/fonts/rails_admin/fa-solid-900.woff +0 -0
  178. data/vendor/assets/fonts/rails_admin/fa-solid-900.woff2 +0 -0
  179. data/vendor/assets/javascripts/rails_admin/jquery-ui/data.js +41 -0
  180. data/vendor/assets/javascripts/rails_admin/jquery-ui/effect.js +1637 -0
  181. data/vendor/assets/javascripts/rails_admin/jquery-ui/ie.js +17 -0
  182. data/vendor/assets/javascripts/rails_admin/jquery-ui/keycode.js +47 -0
  183. data/vendor/assets/javascripts/rails_admin/jquery-ui/position.js +500 -0
  184. data/vendor/assets/javascripts/rails_admin/jquery-ui/safe-active-element.js +42 -0
  185. data/vendor/assets/javascripts/rails_admin/jquery-ui/scroll-parent.js +47 -0
  186. data/vendor/assets/javascripts/rails_admin/jquery-ui/unique-id.js +51 -0
  187. data/vendor/assets/javascripts/rails_admin/jquery-ui/version.js +17 -0
  188. data/vendor/assets/javascripts/rails_admin/jquery-ui/widget.js +735 -0
  189. data/vendor/assets/javascripts/rails_admin/jquery-ui/widgets/autocomplete.js +689 -0
  190. data/vendor/assets/javascripts/rails_admin/jquery-ui/widgets/menu.js +680 -0
  191. data/vendor/assets/javascripts/rails_admin/jquery-ui/widgets/mouse.js +230 -0
  192. data/vendor/assets/javascripts/rails_admin/jquery-ui/widgets/sortable.js +1561 -0
  193. data/vendor/assets/javascripts/rails_admin/jquery3.js +10872 -0
  194. data/vendor/assets/stylesheets/rails_admin/font-awesome.scss +4476 -2216
  195. metadata +118 -263
  196. data/app/assets/images/rails_admin/aristo/images/bg_fallback.png +0 -0
  197. data/app/assets/images/rails_admin/aristo/images/icon_sprite.png +0 -0
  198. data/app/assets/images/rails_admin/aristo/images/progress_bar.gif +0 -0
  199. data/app/assets/images/rails_admin/aristo/images/slider_handles.png +0 -0
  200. data/app/assets/images/rails_admin/aristo/images/ui-icons_222222_256x240.png +0 -0
  201. data/app/assets/images/rails_admin/aristo/images/ui-icons_454545_256x240.png +0 -0
  202. data/app/assets/images/rails_admin/bullet_black.png +0 -0
  203. data/app/assets/images/rails_admin/bullet_white.png +0 -0
  204. data/app/assets/images/rails_admin/calendar.png +0 -0
  205. data/app/assets/images/rails_admin/clock.png +0 -0
  206. data/app/assets/images/rails_admin/logo.png +0 -0
  207. data/app/assets/images/rails_admin/magnifier.png +0 -0
  208. data/app/assets/images/rails_admin/multiselect/icon_sprite.png +0 -0
  209. data/app/assets/images/rails_admin/multiselect/ui-icon-circle-triangle-n-dark.png +0 -0
  210. data/app/assets/images/rails_admin/multiselect/ui-icon-circle-triangle-n-light.png +0 -0
  211. data/app/assets/images/rails_admin/multiselect/ui-icon-circle-triangle-s-dark.png +0 -0
  212. data/app/assets/images/rails_admin/multiselect/ui-icon-circle-triangle-s-light.png +0 -0
  213. data/app/assets/javascripts/rails_admin/jquery-ui.js.erb +0 -8
  214. data/app/assets/javascripts/rails_admin/jquery.migrate.js +0 -3
  215. data/app/assets/javascripts/rails_admin/ra.filter-box.js +0 -253
  216. data/app/assets/javascripts/rails_admin/ra.filtering-multiselect.js +0 -331
  217. data/app/assets/javascripts/rails_admin/ra.filtering-select.js +0 -294
  218. data/app/assets/javascripts/rails_admin/ra.i18n.js +0 -28
  219. data/app/assets/javascripts/rails_admin/ra.nested-form-hooks.js +0 -59
  220. data/app/assets/javascripts/rails_admin/ra.remote-form.js +0 -155
  221. data/app/assets/javascripts/rails_admin/ra.sidescroll.js +0 -31
  222. data/app/assets/javascripts/rails_admin/ra.widgets.js +0 -379
  223. data/app/assets/javascripts/rails_admin/rails_admin.js +0 -21
  224. data/app/assets/javascripts/rails_admin/ui.js +0 -135
  225. data/app/assets/stylesheets/rails_admin/aristo/images/bg_fallback.png +0 -0
  226. data/app/assets/stylesheets/rails_admin/aristo/images/icon_sprite.png +0 -0
  227. data/app/assets/stylesheets/rails_admin/aristo/images/progress_bar.gif +0 -0
  228. data/app/assets/stylesheets/rails_admin/aristo/images/slider_handles.png +0 -0
  229. data/app/assets/stylesheets/rails_admin/aristo/images/ui-icons_222222_256x240.png +0 -0
  230. data/app/assets/stylesheets/rails_admin/aristo/images/ui-icons_454545_256x240.png +0 -0
  231. data/app/assets/stylesheets/rails_admin/aristo/jquery-ui-1.8.7.custom.scss +0 -733
  232. data/app/assets/stylesheets/rails_admin/base/font-awesome-4-compability.scss +0 -153
  233. data/app/assets/stylesheets/rails_admin/ra.filtering-multiselect.scss +0 -88
  234. data/app/assets/stylesheets/rails_admin/ra.sidescroll.scss +0 -29
  235. data/app/assets/stylesheets/rails_admin/ra.widgets.scss +0 -17
  236. data/app/assets/stylesheets/rails_admin/rails_admin.scss.erb +0 -110
  237. data/app/assets/stylesheets/rails_admin/themes/cerulean/variables.scss +0 -857
  238. data/app/views/kaminari/ra-twitter-bootstrap/_gap.html.haml +0 -2
  239. data/app/views/kaminari/ra-twitter-bootstrap/_next_page.html.haml +0 -4
  240. data/app/views/kaminari/ra-twitter-bootstrap/_page.html.haml +0 -4
  241. data/app/views/kaminari/ra-twitter-bootstrap/_paginator.html.haml +0 -9
  242. data/app/views/kaminari/ra-twitter-bootstrap/_prev_page.html.haml +0 -4
  243. data/app/views/kaminari/ra-twitter-bootstrap/without_count/_next_page.html.haml +0 -4
  244. data/app/views/kaminari/ra-twitter-bootstrap/without_count/_paginator.html.haml +0 -4
  245. data/app/views/kaminari/ra-twitter-bootstrap/without_count/_prev_page.html.haml +0 -4
  246. data/app/views/layouts/rails_admin/_head.html.haml +0 -7
  247. data/app/views/layouts/rails_admin/_navigation.html.haml +0 -12
  248. data/app/views/layouts/rails_admin/_secondary_navigation.html.haml +0 -10
  249. data/app/views/layouts/rails_admin/_sidebar_navigation.html.haml +0 -3
  250. data/app/views/layouts/rails_admin/application.html.haml +0 -16
  251. data/app/views/layouts/rails_admin/pjax.html.haml +0 -12
  252. data/app/views/rails_admin/main/_dashboard_history.html.haml +0 -21
  253. data/app/views/rails_admin/main/_delete_notice.html.haml +0 -24
  254. data/app/views/rails_admin/main/_form_action_text.html.haml +0 -7
  255. data/app/views/rails_admin/main/_form_boolean.html.haml +0 -3
  256. data/app/views/rails_admin/main/_form_code_mirror.html.haml +0 -9
  257. data/app/views/rails_admin/main/_form_colorpicker.html.haml +0 -1
  258. data/app/views/rails_admin/main/_form_datetime.html.haml +0 -5
  259. data/app/views/rails_admin/main/_form_enumeration.html.haml +0 -19
  260. data/app/views/rails_admin/main/_form_field.html.haml +0 -1
  261. data/app/views/rails_admin/main/_form_file_upload.html.haml +0 -17
  262. data/app/views/rails_admin/main/_form_froala.html.haml +0 -8
  263. data/app/views/rails_admin/main/_form_multiple_file_upload.html.haml +0 -16
  264. data/app/views/rails_admin/main/_form_nested_many.html.haml +0 -15
  265. data/app/views/rails_admin/main/_form_nested_one.html.haml +0 -17
  266. data/app/views/rails_admin/main/_form_polymorphic_association.html.haml +0 -26
  267. data/app/views/rails_admin/main/_form_simple_mde.haml +0 -8
  268. data/app/views/rails_admin/main/_form_text.html.haml +0 -1
  269. data/app/views/rails_admin/main/_form_wysihtml5.html.haml +0 -8
  270. data/app/views/rails_admin/main/_submit_buttons.html.haml +0 -16
  271. data/app/views/rails_admin/main/bulk_delete.html.haml +0 -11
  272. data/app/views/rails_admin/main/dashboard.html.haml +0 -34
  273. data/app/views/rails_admin/main/delete.html.haml +0 -18
  274. data/app/views/rails_admin/main/edit.html.haml +0 -2
  275. data/app/views/rails_admin/main/export.html.haml +0 -92
  276. data/app/views/rails_admin/main/history.html.haml +0 -51
  277. data/app/views/rails_admin/main/index.html.haml +0 -126
  278. data/app/views/rails_admin/main/new.html.haml +0 -2
  279. data/app/views/rails_admin/main/show.html.haml +0 -15
  280. data/config/initializers/haml.rb +0 -5
  281. data/lib/rails_admin/adapters/active_record/abstract_object.rb +0 -38
  282. data/lib/rails_admin/adapters/active_record.rb.bak +0 -348
  283. data/lib/rails_admin/adapters/mongoid/abstract_object.rb +0 -42
  284. data/lib/rails_admin/bootstrap-sass/compass_functions.rb +0 -28
  285. data/lib/rails_admin/bootstrap-sass/sass_functions.rb +0 -16
  286. data/lib/rails_admin/bootstrap-sass.rb +0 -49
  287. data/lib/rails_admin/config/lazy_model.rb +0 -68
  288. data/lib/rails_admin/extensions/history/auditing_adapter.rb +0 -37
  289. data/lib/rails_admin/extensions/history/history.rb +0 -44
  290. data/lib/rails_admin/extensions/history.rb +0 -3
  291. data/lib/rails_admin/support/i18n.rb +0 -43
  292. data/vendor/assets/fonts/rails_admin/FontAwesome.otf +0 -0
  293. data/vendor/assets/fonts/rails_admin/fontawesome-webfont.eot +0 -0
  294. data/vendor/assets/fonts/rails_admin/fontawesome-webfont.svg +0 -2671
  295. data/vendor/assets/fonts/rails_admin/fontawesome-webfont.ttf +0 -0
  296. data/vendor/assets/fonts/rails_admin/fontawesome-webfont.woff +0 -0
  297. data/vendor/assets/fonts/rails_admin/fontawesome-webfont.woff2 +0 -0
  298. data/vendor/assets/images/rails_admin/colorpicker/colorpicker_background.png +0 -0
  299. data/vendor/assets/images/rails_admin/colorpicker/colorpicker_hex.png +0 -0
  300. data/vendor/assets/images/rails_admin/colorpicker/colorpicker_hsb_b.png +0 -0
  301. data/vendor/assets/images/rails_admin/colorpicker/colorpicker_hsb_h.png +0 -0
  302. data/vendor/assets/images/rails_admin/colorpicker/colorpicker_hsb_s.png +0 -0
  303. data/vendor/assets/images/rails_admin/colorpicker/colorpicker_indic.gif +0 -0
  304. data/vendor/assets/images/rails_admin/colorpicker/colorpicker_overlay.png +0 -0
  305. data/vendor/assets/images/rails_admin/colorpicker/colorpicker_rgb_b.png +0 -0
  306. data/vendor/assets/images/rails_admin/colorpicker/colorpicker_rgb_g.png +0 -0
  307. data/vendor/assets/images/rails_admin/colorpicker/colorpicker_rgb_r.png +0 -0
  308. data/vendor/assets/images/rails_admin/colorpicker/colorpicker_select.gif +0 -0
  309. data/vendor/assets/images/rails_admin/colorpicker/colorpicker_submit.png +0 -0
  310. data/vendor/assets/images/rails_admin/colorpicker/custom_background.png +0 -0
  311. data/vendor/assets/images/rails_admin/colorpicker/custom_hex.png +0 -0
  312. data/vendor/assets/images/rails_admin/colorpicker/custom_hsb_b.png +0 -0
  313. data/vendor/assets/images/rails_admin/colorpicker/custom_hsb_h.png +0 -0
  314. data/vendor/assets/images/rails_admin/colorpicker/custom_hsb_s.png +0 -0
  315. data/vendor/assets/images/rails_admin/colorpicker/custom_indic.gif +0 -0
  316. data/vendor/assets/images/rails_admin/colorpicker/custom_rgb_b.png +0 -0
  317. data/vendor/assets/images/rails_admin/colorpicker/custom_rgb_g.png +0 -0
  318. data/vendor/assets/images/rails_admin/colorpicker/custom_rgb_r.png +0 -0
  319. data/vendor/assets/images/rails_admin/colorpicker/custom_submit.png +0 -0
  320. data/vendor/assets/images/rails_admin/colorpicker/select.png +0 -0
  321. data/vendor/assets/images/rails_admin/colorpicker/select2.png +0 -0
  322. data/vendor/assets/images/rails_admin/colorpicker/slider.png +0 -0
  323. data/vendor/assets/javascripts/rails_admin/jquery.colorpicker.js +0 -484
  324. data/vendor/assets/stylesheets/rails_admin/jquery.colorpicker.scss +0 -182
  325. /data/{app/assets/stylesheets/rails_admin → src/rails_admin/styles}/base/README.txt +0 -0
  326. /data/{app/assets/stylesheets/rails_admin → src/rails_admin/styles}/base/mixins.scss +0 -0
  327. /data/{app/assets/stylesheets/rails_admin → src/rails_admin/styles}/base/variables.scss +0 -0
  328. /data/{app/assets/stylesheets/rails_admin → src/rails_admin/styles}/themes/cerulean/mixins.scss +0 -0
  329. /data/{app/assets/stylesheets/rails_admin → src/rails_admin/styles}/themes/default/theming.scss +0 -0
@@ -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('You must override build_statement_for_type in your StatementBuilder')
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 then
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
- start_date = (start_date.to_date rescue nil) if start_date
175
- end_date = (end_date.to_date rescue nil) if end_date
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.try(:beginning_of_day) if start_date
182
- end_date = end_date.try(:end_of_day) if 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('You must override unary_operators in your StatementBuilder')
201
+ raise 'You must override unary_operators in your StatementBuilder'
188
202
  end
189
203
 
190
204
  def range_filter(_min, _max)
191
- raise('You must override range_filter in your StatementBuilder')
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
- (options[:primary_key] || association.klass.primary_key).try(:to_sym) unless polymorphic?
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
@@ -48,7 +48,7 @@ module RailsAdmin
48
48
  private
49
49
 
50
50
  def serialized?
51
- model.type_for_attribute(property.name).class == ::ActiveRecord::Type::Serialized
51
+ model.type_for_attribute(property.name).instance_of?(::ActiveRecord::Type::Serialized)
52
52
  end
53
53
  end
54
54
  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 = [:tsvector, :blob, :binary, :spatial, :hstore, :geometry].freeze
9
+ DISABLED_COLUMN_TYPES = %i[tsvector blob binary spatial hstore geometry].freeze
10
10
 
11
11
  def new(params = {})
12
- AbstractObject.new(model.new(params))
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
- AbstractObject.new object
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("SELECT dummy FROM DUAL").values.first.encoding
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 then build_statement_for_string_or_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(false f 0).include?(@value)
230
- return ["(#{@column} = ?)", true] if %w(true t 1).include?(@value)
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,11 +246,9 @@ module RailsAdmin
244
246
 
245
247
  return ["(#{@column} = ?)", @value] if ['is', '='].include?(@operator)
246
248
 
247
- unless ['postgresql', 'postgis'].include? ar_adapter
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 = begin
251
+ @value =
252
252
  case @operator
253
253
  when 'default', 'like', 'not_like'
254
254
  "%#{@value}%"
@@ -259,9 +259,8 @@ module RailsAdmin
259
259
  else
260
260
  return
261
261
  end
262
- end
263
262
 
264
- if ['postgresql', 'postgis'].include? ar_adapter
263
+ if %w[postgresql postgis].include? ar_adapter
265
264
  if @operator == 'not_like'
266
265
  ["(#{@column} NOT ILIKE ?)", @value]
267
266
  else
@@ -276,13 +275,12 @@ module RailsAdmin
276
275
 
277
276
  def build_statement_for_enum
278
277
  return if @value.blank?
278
+
279
279
  ["(#{@column} IN (?))", Array.wrap(@value)]
280
280
  end
281
281
 
282
282
  def build_statement_for_uuid
283
- if @value.to_s =~ /\A[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}\z/
284
- column_for_value(@value)
285
- 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)
286
284
  end
287
285
 
288
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("Unknown association type: #{macro.inspect}")
33
+ raise "Unknown association type: #{macro.inspect}"
32
34
  end
33
35
  end
34
36
 
35
37
  def klass
36
- if polymorphic? && [:referenced_in, :belongs_to].include?(macro)
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
- association.primary_key.to_sym rescue :_id
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
- association.foreign_key.to_sym rescue nil
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? && [:referenced_in, :belongs_to].include?(macro)
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? && [:referenced_in, :belongs_to].include?(macro)
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? && [:referenced_in, :belongs_to].include?(macro)
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 && [:embeds_one, :embeds_many].include?(macro.to_sym) && !cyclic?
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
- [:embeds_one, :embeds_many].include?(macro)
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 = begin
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
- ).exclude?(e.class.to_s)
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(self, &block)
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 = [:name, :title, :subject].freeze
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 [:belongs_to, :referenced_in, :embedded_in].include?(association.macro)
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(Range Moped::BSON::Binary BSON::Binary Mongoid::Geospatial::Point).freeze
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
- AbstractObject.new(model.new(params))
18
+ model.new(params).extend(ObjectExtension)
19
19
  end
20
20
 
21
21
  def get(id)
22
- AbstractObject.new(model.find(id))
23
- rescue => e
24
- raise e if %w(
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
- ).exclude?(e.class.to_s)
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 =~ /page/
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(false f 0).include?(@value)
250
- return {@column => true} if %w(true t 1).include?(@value)
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,7 +258,8 @@ module RailsAdmin
256
258
 
257
259
  def build_statement_for_string_or_text
258
260
  return if @value.blank?
259
- @value = begin
261
+
262
+ @value =
260
263
  case @operator
261
264
  when 'not_like'
262
265
  Regexp.compile("^((?!#{Regexp.escape(@value)}).)*$", Regexp::IGNORECASE)
@@ -271,12 +274,13 @@ module RailsAdmin
271
274
  else
272
275
  return
273
276
  end
274
- end
277
+
275
278
  {@column => @value}
276
279
  end
277
280
 
278
281
  def build_statement_for_enum
279
282
  return if @value.blank?
283
+
280
284
  {@column => {'$in' => Array.wrap(@value)}}
281
285
  end
282
286
 
@@ -285,7 +289,9 @@ module RailsAdmin
285
289
  end
286
290
 
287
291
  def range_filter(min, max)
288
- if min && max
292
+ if min && max && min == max
293
+ {@column => min}
294
+ elsif min && max
289
295
  {@column => {'$gte' => min, '$lte' => max}}
290
296
  elsif min
291
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
- 'icon-question-sign'
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
- true
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
@@ -9,7 +9,7 @@ module RailsAdmin
9
9
  end
10
10
 
11
11
  register_instance_option :http_methods do
12
- [:post, :delete]
12
+ %i[post delete]
13
13
  end
14
14
 
15
15
  register_instance_option :controller do
@@ -36,7 +36,7 @@ module RailsAdmin
36
36
  destroyed = processed_objects.select(&:destroyed?)
37
37
  not_destroyed = processed_objects - destroyed
38
38
  destroyed.each do |object|
39
- @auditing_adapter && @auditing_adapter.delete_object(object, @abstract_model, _current_user)
39
+ @auditing_adapter&.delete_object(object, @abstract_model, _current_user)
40
40
  end
41
41
  end
42
42
  end