rails_admin 0.8.1 → 2.2.1

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 (313) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile +17 -34
  3. data/LICENSE.md +1 -1
  4. data/README.md +34 -26
  5. data/app/assets/images/rails_admin/aristo/images/bg_fallback.png +0 -0
  6. data/app/assets/images/rails_admin/aristo/images/slider_handles.png +0 -0
  7. data/app/assets/images/rails_admin/aristo/images/ui-icons_222222_256x240.png +0 -0
  8. data/app/assets/images/rails_admin/aristo/images/ui-icons_454545_256x240.png +0 -0
  9. data/app/assets/images/rails_admin/bullet_black.png +0 -0
  10. data/app/assets/images/rails_admin/bullet_white.png +0 -0
  11. data/app/assets/images/rails_admin/calendar.png +0 -0
  12. data/app/assets/images/rails_admin/clock.png +0 -0
  13. data/app/assets/images/rails_admin/magnifier.png +0 -0
  14. data/app/assets/images/rails_admin/multiselect/ui-icon-circle-triangle-n-dark.png +0 -0
  15. data/app/assets/images/rails_admin/multiselect/ui-icon-circle-triangle-s-dark.png +0 -0
  16. data/app/assets/images/rails_admin/multiselect/ui-icon-circle-triangle-s-light.png +0 -0
  17. data/app/assets/javascripts/rails_admin/custom/ui.js +1 -0
  18. data/app/assets/javascripts/rails_admin/jquery-ui.js.erb +8 -0
  19. data/app/assets/javascripts/rails_admin/jquery.migrate.js +3 -0
  20. data/app/assets/javascripts/rails_admin/ra.filter-box.js +148 -60
  21. data/app/assets/javascripts/rails_admin/ra.filtering-multiselect.js +31 -26
  22. data/app/assets/javascripts/rails_admin/ra.filtering-select.js +211 -110
  23. data/app/assets/javascripts/rails_admin/ra.i18n.js +28 -0
  24. data/app/assets/javascripts/rails_admin/ra.nested-form-hooks.js +59 -0
  25. data/app/assets/javascripts/rails_admin/ra.sidescroll.js +31 -0
  26. data/app/assets/javascripts/rails_admin/ra.widgets.js +379 -0
  27. data/app/assets/javascripts/rails_admin/rails_admin.js +5 -5
  28. data/app/assets/javascripts/rails_admin/ui.js +135 -0
  29. data/app/assets/stylesheets/rails_admin/aristo/images/bg_fallback.png +0 -0
  30. data/app/assets/stylesheets/rails_admin/aristo/images/slider_handles.png +0 -0
  31. data/app/assets/stylesheets/rails_admin/aristo/images/ui-icons_222222_256x240.png +0 -0
  32. data/app/assets/stylesheets/rails_admin/aristo/images/ui-icons_454545_256x240.png +0 -0
  33. data/app/assets/stylesheets/rails_admin/aristo/jquery-ui-1.8.7.custom.scss +5 -5
  34. data/app/assets/stylesheets/rails_admin/ra.sidescroll.scss +29 -0
  35. data/app/assets/stylesheets/rails_admin/ra.widgets.scss +9 -1
  36. data/app/assets/stylesheets/rails_admin/rails_admin.scss.erb +2 -1
  37. data/app/controllers/rails_admin/application_controller.rb +14 -8
  38. data/app/controllers/rails_admin/main_controller.rb +9 -9
  39. data/app/helpers/rails_admin/application_helper.rb +26 -11
  40. data/app/helpers/rails_admin/form_builder.rb +20 -12
  41. data/app/helpers/rails_admin/main_helper.rb +8 -7
  42. data/app/views/kaminari/{twitter-bootstrap → ra-twitter-bootstrap}/_gap.html.haml +0 -0
  43. data/app/views/kaminari/{twitter-bootstrap → ra-twitter-bootstrap}/_next_page.html.haml +0 -0
  44. data/app/views/kaminari/{twitter-bootstrap → ra-twitter-bootstrap}/_page.html.haml +0 -0
  45. data/app/views/kaminari/{twitter-bootstrap → ra-twitter-bootstrap}/_paginator.html.haml +0 -0
  46. data/app/views/kaminari/{twitter-bootstrap → ra-twitter-bootstrap}/_prev_page.html.haml +0 -0
  47. data/app/views/kaminari/ra-twitter-bootstrap/without_count/_next_page.html.haml +4 -0
  48. data/app/views/kaminari/ra-twitter-bootstrap/without_count/_paginator.html.haml +4 -0
  49. data/app/views/kaminari/ra-twitter-bootstrap/without_count/_prev_page.html.haml +4 -0
  50. data/app/views/layouts/rails_admin/_head.html.haml +7 -0
  51. data/app/views/layouts/rails_admin/_secondary_navigation.html.haml +2 -2
  52. data/app/views/layouts/rails_admin/_sidebar_navigation.html.haml +2 -1
  53. data/app/views/layouts/rails_admin/application.html.haml +4 -10
  54. data/app/views/layouts/rails_admin/pjax.html.haml +1 -5
  55. data/app/views/rails_admin/main/_delete_notice.html.haml +14 -9
  56. data/app/views/rails_admin/main/_form_action_text.html.haml +7 -0
  57. data/app/views/rails_admin/main/_form_colorpicker.html.haml +1 -1
  58. data/app/views/rails_admin/main/_form_enumeration.html.haml +4 -3
  59. data/app/views/rails_admin/main/_form_file_upload.html.haml +5 -5
  60. data/app/views/rails_admin/main/_form_filtering_multiselect.html.haml +7 -6
  61. data/app/views/rails_admin/main/_form_filtering_select.html.haml +1 -1
  62. data/app/views/rails_admin/main/_form_multiple_file_upload.html.haml +16 -0
  63. data/app/views/rails_admin/main/_form_polymorphic_association.html.haml +18 -3
  64. data/app/views/rails_admin/main/_form_simple_mde.haml +8 -0
  65. data/app/views/rails_admin/main/dashboard.html.haml +5 -6
  66. data/app/views/rails_admin/main/export.html.haml +45 -36
  67. data/app/views/rails_admin/main/history.html.haml +3 -3
  68. data/app/views/rails_admin/main/index.html.haml +37 -26
  69. data/app/views/rails_admin/main/show.html.haml +6 -7
  70. data/config/initializers/active_record_extensions.rb +3 -3
  71. data/config/initializers/haml.rb +4 -1
  72. data/config/locales/rails_admin.en.yml +5 -2
  73. data/lib/generators/rails_admin/templates/initializer.erb +6 -2
  74. data/lib/rails_admin/abstract_model.rb +9 -10
  75. data/lib/rails_admin/adapters/active_record/abstract_object.rb +9 -3
  76. data/lib/rails_admin/adapters/active_record/property.rb +1 -5
  77. data/lib/rails_admin/adapters/active_record.rb +83 -28
  78. data/lib/rails_admin/adapters/mongoid/abstract_object.rb +3 -3
  79. data/lib/rails_admin/adapters/mongoid/association.rb +18 -6
  80. data/lib/rails_admin/adapters/mongoid/bson.rb +29 -0
  81. data/lib/rails_admin/adapters/mongoid/extension.rb +4 -2
  82. data/lib/rails_admin/adapters/mongoid/property.rb +3 -3
  83. data/lib/rails_admin/adapters/mongoid.rb +40 -26
  84. data/lib/rails_admin/bootstrap-sass/compass_functions.rb +1 -1
  85. data/lib/rails_admin/bootstrap-sass/sass_functions.rb +1 -3
  86. data/lib/rails_admin/bootstrap-sass.rb +8 -6
  87. data/lib/rails_admin/config/actions/base.rb +20 -5
  88. data/lib/rails_admin/config/actions/bulk_delete.rb +2 -4
  89. data/lib/rails_admin/config/actions/dashboard.rb +9 -5
  90. data/lib/rails_admin/config/actions/edit.rb +1 -3
  91. data/lib/rails_admin/config/actions/export.rb +1 -1
  92. data/lib/rails_admin/config/actions/index.rb +5 -3
  93. data/lib/rails_admin/config/actions/new.rb +4 -5
  94. data/lib/rails_admin/config/actions.rb +1 -1
  95. data/lib/rails_admin/config/configurable.rb +25 -18
  96. data/lib/rails_admin/config/fields/association.rb +11 -3
  97. data/lib/rails_admin/config/fields/base.rb +20 -27
  98. data/lib/rails_admin/config/fields/factories/action_text.rb +12 -0
  99. data/lib/rails_admin/config/fields/factories/active_storage.rb +30 -0
  100. data/lib/rails_admin/config/fields/factories/carrierwave.rb +4 -2
  101. data/lib/rails_admin/config/fields/factories/dragonfly.rb +1 -1
  102. data/lib/rails_admin/config/fields/factories/shrine.rb +27 -0
  103. data/lib/rails_admin/config/fields/types/action_text.rb +30 -0
  104. data/lib/rails_admin/config/fields/types/active_record_enum.rb +19 -2
  105. data/lib/rails_admin/config/fields/types/active_storage.rb +49 -0
  106. data/lib/rails_admin/config/fields/types/all.rb +7 -1
  107. data/lib/rails_admin/config/fields/types/belongs_to_association.rb +8 -0
  108. data/lib/rails_admin/config/fields/types/bson_object_id.rb +1 -15
  109. data/lib/rails_admin/config/fields/types/ck_editor.rb +7 -7
  110. data/lib/rails_admin/config/fields/types/code_mirror.rb +10 -12
  111. data/lib/rails_admin/config/fields/types/color.rb +2 -2
  112. data/lib/rails_admin/config/fields/types/datetime.rb +6 -3
  113. data/lib/rails_admin/config/fields/types/file_upload.rb +12 -4
  114. data/lib/rails_admin/config/fields/types/froala.rb +9 -11
  115. data/lib/rails_admin/config/fields/types/has_many_association.rb +1 -1
  116. data/lib/rails_admin/config/fields/types/hidden.rb +2 -2
  117. data/lib/rails_admin/config/fields/types/json.rb +9 -1
  118. data/lib/rails_admin/config/fields/types/multiple_active_storage.rb +53 -0
  119. data/lib/rails_admin/config/fields/types/multiple_carrierwave.rb +56 -0
  120. data/lib/rails_admin/config/fields/types/multiple_file_upload.rb +125 -0
  121. data/lib/rails_admin/config/fields/types/password.rb +5 -1
  122. data/lib/rails_admin/config/fields/types/polymorphic_association.rb +12 -1
  123. data/lib/rails_admin/config/fields/types/serialized.rb +2 -2
  124. data/lib/rails_admin/config/fields/types/shrine.rb +54 -0
  125. data/lib/rails_admin/config/fields/types/simple_mde.rb +36 -0
  126. data/lib/rails_admin/config/fields/types/string.rb +8 -7
  127. data/lib/rails_admin/config/fields/types/string_like.rb +19 -0
  128. data/lib/rails_admin/config/fields/types/text.rb +2 -20
  129. data/lib/rails_admin/config/fields/types/wysihtml5.rb +14 -10
  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 +1 -1
  133. data/lib/rails_admin/config/has_groups.rb +1 -1
  134. data/lib/rails_admin/config/hideable.rb +1 -1
  135. data/lib/rails_admin/config/inspectable.rb +39 -0
  136. data/lib/rails_admin/config/lazy_model.rb +48 -8
  137. data/lib/rails_admin/config/model.rb +10 -22
  138. data/lib/rails_admin/config/proxyable/proxy.rb +7 -9
  139. data/lib/rails_admin/config/proxyable.rb +13 -1
  140. data/lib/rails_admin/config/sections/base.rb +4 -17
  141. data/lib/rails_admin/config/sections/list.rb +37 -0
  142. data/lib/rails_admin/config.rb +46 -25
  143. data/lib/rails_admin/engine.rb +37 -4
  144. data/lib/rails_admin/extension.rb +16 -4
  145. data/lib/rails_admin/extensions/cancancan/authorization_adapter.rb +23 -7
  146. data/lib/rails_admin/extensions/cancancan.rb +1 -1
  147. data/lib/rails_admin/extensions/controller_extension.rb +6 -0
  148. data/lib/rails_admin/extensions/history/auditing_adapter.rb +2 -2
  149. data/lib/rails_admin/extensions/history/history.rb +2 -2
  150. data/lib/rails_admin/extensions/paper_trail/auditing_adapter.rb +59 -17
  151. data/lib/rails_admin/extensions/pundit/authorization_adapter.rb +11 -3
  152. data/lib/rails_admin/support/csv_converter.rb +20 -14
  153. data/lib/rails_admin/support/datetime.rb +7 -6
  154. data/lib/rails_admin/support/i18n.rb +7 -5
  155. data/lib/rails_admin/version.rb +2 -2
  156. data/lib/rails_admin.rb +23 -1
  157. data/lib/tasks/rails_admin.rake +16 -7
  158. data/vendor/assets/fonts/rails_admin/FontAwesome.otf +0 -0
  159. data/vendor/assets/fonts/rails_admin/fontawesome-webfont.eot +0 -0
  160. data/vendor/assets/fonts/rails_admin/fontawesome-webfont.svg +2671 -0
  161. data/vendor/assets/fonts/rails_admin/fontawesome-webfont.ttf +0 -0
  162. data/vendor/assets/fonts/rails_admin/fontawesome-webfont.woff +0 -0
  163. data/vendor/assets/fonts/rails_admin/fontawesome-webfont.woff2 +0 -0
  164. data/vendor/assets/images/rails_admin/bootstrap/glyphicons-halflings-white.png +0 -0
  165. data/vendor/assets/images/rails_admin/bootstrap/glyphicons-halflings.png +0 -0
  166. data/vendor/assets/images/rails_admin/colorpicker/colorpicker_background.png +0 -0
  167. data/vendor/assets/images/rails_admin/colorpicker/colorpicker_hex.png +0 -0
  168. data/vendor/assets/images/rails_admin/colorpicker/colorpicker_hsb_b.png +0 -0
  169. data/vendor/assets/images/rails_admin/colorpicker/colorpicker_hsb_h.png +0 -0
  170. data/vendor/assets/images/rails_admin/colorpicker/colorpicker_hsb_s.png +0 -0
  171. data/vendor/assets/images/rails_admin/colorpicker/colorpicker_indic.gif +0 -0
  172. data/vendor/assets/images/rails_admin/colorpicker/colorpicker_overlay.png +0 -0
  173. data/vendor/assets/images/rails_admin/colorpicker/colorpicker_rgb_b.png +0 -0
  174. data/vendor/assets/images/rails_admin/colorpicker/colorpicker_rgb_g.png +0 -0
  175. data/{app → vendor}/assets/images/rails_admin/colorpicker/colorpicker_rgb_r.png +0 -0
  176. data/{app → vendor}/assets/images/rails_admin/colorpicker/colorpicker_select.gif +0 -0
  177. data/vendor/assets/images/rails_admin/colorpicker/colorpicker_submit.png +0 -0
  178. data/vendor/assets/images/rails_admin/colorpicker/custom_background.png +0 -0
  179. data/vendor/assets/images/rails_admin/colorpicker/custom_hex.png +0 -0
  180. data/vendor/assets/images/rails_admin/colorpicker/custom_hsb_b.png +0 -0
  181. data/vendor/assets/images/rails_admin/colorpicker/custom_hsb_h.png +0 -0
  182. data/vendor/assets/images/rails_admin/colorpicker/custom_hsb_s.png +0 -0
  183. data/vendor/assets/images/rails_admin/colorpicker/custom_indic.gif +0 -0
  184. data/{app → vendor}/assets/images/rails_admin/colorpicker/custom_rgb_b.png +0 -0
  185. data/{app → vendor}/assets/images/rails_admin/colorpicker/custom_rgb_g.png +0 -0
  186. data/{app → vendor}/assets/images/rails_admin/colorpicker/custom_rgb_r.png +0 -0
  187. data/vendor/assets/images/rails_admin/colorpicker/custom_submit.png +0 -0
  188. data/vendor/assets/images/rails_admin/colorpicker/select.png +0 -0
  189. data/{app → vendor}/assets/images/rails_admin/colorpicker/select2.png +0 -0
  190. data/vendor/assets/images/rails_admin/colorpicker/slider.png +0 -0
  191. data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-affix.js +50 -28
  192. data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-alert.js +10 -7
  193. data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-button.js +35 -20
  194. data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-carousel.js +48 -25
  195. data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-collapse.js +70 -28
  196. data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-dropdown.js +56 -42
  197. data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-modal.js +118 -40
  198. data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-popover.js +26 -16
  199. data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-scrollspy.js +29 -27
  200. data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-tab.js +46 -19
  201. data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-tooltip.js +280 -60
  202. data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-transition.js +5 -5
  203. data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-typeahead.js +0 -0
  204. data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap.js +0 -0
  205. data/vendor/assets/javascripts/rails_admin/bootstrap-datetimepicker.js +317 -150
  206. data/{app → vendor}/assets/javascripts/rails_admin/jquery.colorpicker.js +0 -0
  207. data/{app → vendor}/assets/javascripts/rails_admin/jquery.pjax.js +316 -161
  208. data/vendor/assets/javascripts/rails_admin/moment-with-locales.js +16528 -8420
  209. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_alerts.scss +0 -0
  210. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_badges.scss +0 -0
  211. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_breadcrumbs.scss +0 -0
  212. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_button-groups.scss +0 -0
  213. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_buttons.scss +0 -0
  214. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_carousel.scss +0 -0
  215. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_close.scss +0 -0
  216. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_code.scss +0 -0
  217. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_component-animations.scss +0 -0
  218. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_dropdowns.scss +0 -0
  219. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_forms.scss +0 -0
  220. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_glyphicons.scss +0 -0
  221. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_grid.scss +0 -0
  222. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_input-groups.scss +0 -0
  223. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_jumbotron.scss +0 -0
  224. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_labels.scss +0 -0
  225. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_list-group.scss +0 -0
  226. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_media.scss +0 -0
  227. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_mixins.scss +0 -0
  228. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_modals.scss +0 -0
  229. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_navbar.scss +0 -0
  230. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_navs.scss +0 -0
  231. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_normalize.scss +0 -0
  232. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_pager.scss +0 -0
  233. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_pagination.scss +0 -0
  234. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_panels.scss +0 -0
  235. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_popovers.scss +0 -0
  236. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_print.scss +0 -0
  237. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_progress-bars.scss +0 -0
  238. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_responsive-embed.scss +0 -0
  239. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_responsive-utilities.scss +0 -0
  240. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_scaffolding.scss +0 -0
  241. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_tables.scss +0 -0
  242. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_theme.scss +0 -0
  243. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_thumbnails.scss +0 -0
  244. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_tooltip.scss +0 -0
  245. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_type.scss +0 -0
  246. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_utilities.scss +0 -0
  247. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_variables.scss +0 -0
  248. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_wells.scss +0 -0
  249. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/bootstrap.scss +0 -0
  250. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_alerts.scss +0 -0
  251. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_background-variant.scss +0 -0
  252. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_border-radius.scss +0 -0
  253. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_buttons.scss +0 -0
  254. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_center-block.scss +0 -0
  255. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_clearfix.scss +0 -0
  256. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_forms.scss +0 -0
  257. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_gradients.scss +0 -0
  258. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_grid-framework.scss +0 -0
  259. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_grid.scss +0 -0
  260. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_hide-text.scss +0 -0
  261. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_image.scss +0 -0
  262. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_labels.scss +0 -0
  263. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_list-group.scss +0 -0
  264. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_nav-divider.scss +0 -0
  265. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_nav-vertical-align.scss +0 -0
  266. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_opacity.scss +0 -0
  267. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_pagination.scss +0 -0
  268. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_panels.scss +0 -0
  269. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_progress-bar.scss +0 -0
  270. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_reset-filter.scss +0 -0
  271. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_resize.scss +0 -0
  272. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_responsive-visibility.scss +0 -0
  273. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_size.scss +0 -0
  274. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_tab-focus.scss +0 -0
  275. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_table-row.scss +0 -0
  276. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_text-emphasis.scss +0 -0
  277. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_text-overflow.scss +0 -0
  278. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_vendor-prefixes.scss +0 -0
  279. data/vendor/assets/stylesheets/rails_admin/font-awesome.scss +2342 -0
  280. data/{app → vendor}/assets/stylesheets/rails_admin/jquery.colorpicker.scss +0 -0
  281. metadata +214 -199
  282. data/app/assets/images/rails_admin/bootstrap/glyphicons-halflings-white.png +0 -0
  283. data/app/assets/images/rails_admin/bootstrap/glyphicons-halflings.png +0 -0
  284. data/app/assets/images/rails_admin/colorpicker/colorpicker_background.png +0 -0
  285. data/app/assets/images/rails_admin/colorpicker/colorpicker_hex.png +0 -0
  286. data/app/assets/images/rails_admin/colorpicker/colorpicker_hsb_b.png +0 -0
  287. data/app/assets/images/rails_admin/colorpicker/colorpicker_hsb_h.png +0 -0
  288. data/app/assets/images/rails_admin/colorpicker/colorpicker_hsb_s.png +0 -0
  289. data/app/assets/images/rails_admin/colorpicker/colorpicker_indic.gif +0 -0
  290. data/app/assets/images/rails_admin/colorpicker/colorpicker_overlay.png +0 -0
  291. data/app/assets/images/rails_admin/colorpicker/colorpicker_rgb_b.png +0 -0
  292. data/app/assets/images/rails_admin/colorpicker/colorpicker_rgb_g.png +0 -0
  293. data/app/assets/images/rails_admin/colorpicker/colorpicker_submit.png +0 -0
  294. data/app/assets/images/rails_admin/colorpicker/custom_background.png +0 -0
  295. data/app/assets/images/rails_admin/colorpicker/custom_hex.png +0 -0
  296. data/app/assets/images/rails_admin/colorpicker/custom_hsb_b.png +0 -0
  297. data/app/assets/images/rails_admin/colorpicker/custom_hsb_h.png +0 -0
  298. data/app/assets/images/rails_admin/colorpicker/custom_hsb_s.png +0 -0
  299. data/app/assets/images/rails_admin/colorpicker/custom_indic.gif +0 -0
  300. data/app/assets/images/rails_admin/colorpicker/custom_submit.png +0 -0
  301. data/app/assets/images/rails_admin/colorpicker/select.png +0 -0
  302. data/app/assets/images/rails_admin/colorpicker/slider.png +0 -0
  303. data/app/assets/javascripts/rails_admin/custom/ui.coffee +0 -1
  304. data/app/assets/javascripts/rails_admin/jquery.remotipart.fixed.js +0 -72
  305. data/app/assets/javascripts/rails_admin/ra.i18n.coffee +0 -8
  306. data/app/assets/javascripts/rails_admin/ra.nested-form-hooks.coffee +0 -52
  307. data/app/assets/javascripts/rails_admin/ra.widgets.coffee +0 -308
  308. data/app/assets/javascripts/rails_admin/ui.coffee +0 -102
  309. data/config/initializers/devise_patch.rb +0 -9
  310. data/lib/rails_admin/config/fields/factories/refile.rb +0 -25
  311. data/lib/rails_admin/config/fields/types/refile.rb +0 -27
  312. data/lib/rails_admin/extensions/cancan/authorization_adapter.rb +0 -57
  313. data/lib/rails_admin/extensions/cancan.rb +0 -3
@@ -1,4 +1,3 @@
1
- require 'font-awesome-rails'
2
1
  require 'jquery-rails'
3
2
  require 'jquery-ui-rails'
4
3
  require 'kaminari'
@@ -7,13 +6,12 @@ require 'rack-pjax'
7
6
  require 'rails'
8
7
  require 'rails_admin'
9
8
  require 'remotipart'
10
- require 'safe_yaml/load'
11
9
 
12
10
  module RailsAdmin
13
11
  class Engine < Rails::Engine
14
12
  isolate_namespace RailsAdmin
15
13
 
16
- config.action_dispatch.rescue_responses.merge!('RailsAdmin::ActionNotAllowed' => :forbidden)
14
+ config.action_dispatch.rescue_responses['RailsAdmin::ActionNotAllowed'] = :forbidden
17
15
 
18
16
  initializer 'RailsAdmin precompile hook', group: :all do |app|
19
17
  app.config.assets.precompile += %w(
@@ -24,12 +22,47 @@ module RailsAdmin
24
22
  )
25
23
  end
26
24
 
27
- initializer 'RailsAdmin pjax hook' do |app|
25
+ initializer 'RailsAdmin setup middlewares' do |app|
28
26
  app.config.middleware.use Rack::Pjax
29
27
  end
30
28
 
29
+ initializer 'RailsAdmin reload config in development' do
30
+ if Rails.application.config.cache_classes
31
+ if defined?(ActiveSupport::Reloader)
32
+ ActiveSupport::Reloader.before_class_unload do
33
+ RailsAdmin::Config.reset_all_models
34
+ end
35
+ # else
36
+ # For Rails 4 not implemented
37
+ end
38
+ end
39
+ end
40
+
31
41
  rake_tasks do
32
42
  Dir[File.join(File.dirname(__FILE__), '../tasks/*.rake')].each { |f| load f }
33
43
  end
44
+
45
+ # Check for required middlewares, users may forget to use them in Rails API mode
46
+ config.after_initialize do |app|
47
+ has_session_store = app.config.middleware.to_a.any? do |m|
48
+ m.klass.try(:<=, ActionDispatch::Session::AbstractStore) ||
49
+ m.klass.name =~ /^ActionDispatch::Session::/
50
+ end
51
+ loaded = app.config.middleware.to_a.map(&:name)
52
+ required = %w(ActionDispatch::Cookies ActionDispatch::Flash Rack::MethodOverride)
53
+ missing = required - loaded
54
+ unless missing.empty? && has_session_store
55
+ configs = missing.map { |m| "config.middleware.use #{m}" }
56
+ configs << "config.middleware.use #{app.config.session_store.try(:name) || 'ActionDispatch::Session::CookieStore'}, #{app.config.session_options}" unless has_session_store
57
+ raise <<-EOM
58
+ Required middlewares for RailsAdmin are not added
59
+ To fix this, add
60
+
61
+ #{configs.join("\n ")}
62
+
63
+ to config/application.rb.
64
+ EOM
65
+ end
66
+ end
34
67
  end
35
68
  end
@@ -1,9 +1,10 @@
1
+ require 'rails_admin/extensions/controller_extension'
1
2
 
2
3
  module RailsAdmin
3
- EXTENSIONS = []
4
- AUTHORIZATION_ADAPTERS = {}
5
- AUDITING_ADAPTERS = {}
6
- CONFIGURATION_ADAPTERS = {}
4
+ EXTENSIONS = [] # rubocop:disable Style/MutableConstant
5
+ AUTHORIZATION_ADAPTERS = {} # rubocop:disable Style/MutableConstant
6
+ AUDITING_ADAPTERS = {} # rubocop:disable Style/MutableConstant
7
+ CONFIGURATION_ADAPTERS = {} # rubocop:disable Style/MutableConstant
7
8
 
8
9
  # Extend RailsAdmin
9
10
  #
@@ -26,4 +27,15 @@ module RailsAdmin
26
27
  AUDITING_ADAPTERS[extension_key] = extension_definition::AuditingAdapter
27
28
  end
28
29
  end
30
+
31
+ # Setup all extensions for testing
32
+ def self.setup_all_extensions
33
+ (AUTHORIZATION_ADAPTERS.values + AUDITING_ADAPTERS.values).each do |klass|
34
+ begin
35
+ klass.setup if klass.respond_to? :setup
36
+ rescue # rubocop:disable Lint/HandleExceptions, Style/RescueStandardError
37
+ # ignore errors
38
+ end
39
+ end
40
+ end
29
41
  end
@@ -3,6 +3,14 @@ module RailsAdmin
3
3
  module CanCanCan
4
4
  # This adapter is for the CanCanCan[https://github.com/CanCanCommunity/cancancan] authorization library.
5
5
  class AuthorizationAdapter
6
+ module ControllerExtension
7
+ def current_ability
8
+ # use _current_user instead of default current_user so it works with
9
+ # whatever current user method is defined with RailsAdmin
10
+ @current_ability ||= @ability.new(_current_user)
11
+ end
12
+ end
13
+
6
14
  # See the +authorize_with+ config method for where the initialization happens.
7
15
  def initialize(controller, ability = ::Ability)
8
16
  @controller = controller
@@ -17,7 +25,9 @@ module RailsAdmin
17
25
  # AbstractModel instance that applies. The third argument is the actual model
18
26
  # instance if it is available.
19
27
  def authorize(action, abstract_model = nil, model_object = nil)
20
- @controller.current_ability.authorize!(action, model_object || abstract_model && abstract_model.model) if action
28
+ return unless action
29
+ action, subject = resolve_action_and_subject(action, abstract_model, model_object)
30
+ @controller.current_ability.authorize!(action, subject)
21
31
  end
22
32
 
23
33
  # This method is called primarily from the view to determine whether the given user
@@ -25,7 +35,9 @@ module RailsAdmin
25
35
  # This takes the same arguments as +authorize+. The difference is that this will
26
36
  # return a boolean whereas +authorize+ will raise an exception when not authorized.
27
37
  def authorized?(action, abstract_model = nil, model_object = nil)
28
- @controller.current_ability.can?(action, model_object || abstract_model && abstract_model.model) if action
38
+ return unless action
39
+ action, subject = resolve_action_and_subject(action, abstract_model, model_object)
40
+ @controller.current_ability.can?(action, subject)
29
41
  end
30
42
 
31
43
  # This is called when needing to scope a database query. It is called within the list
@@ -42,11 +54,15 @@ module RailsAdmin
42
54
  @controller.current_ability.attributes_for(action, abstract_model && abstract_model.model)
43
55
  end
44
56
 
45
- module ControllerExtension
46
- def current_ability
47
- # use _current_user instead of default current_user so it works with
48
- # whatever current user method is defined with RailsAdmin
49
- @current_ability ||= @ability.new(_current_user)
57
+ private
58
+
59
+ def resolve_action_and_subject(action, abstract_model, model_object)
60
+ subject = model_object || abstract_model && abstract_model.model
61
+ if subject
62
+ [action, subject]
63
+ else
64
+ # For :dashboard compatibility
65
+ [:read, action]
50
66
  end
51
67
  end
52
68
  end
@@ -1,3 +1,3 @@
1
1
  require 'rails_admin/extensions/cancancan/authorization_adapter'
2
2
 
3
- RailsAdmin.add_extension(:cancan, RailsAdmin::Extensions::CanCanCan, authorization: true)
3
+ RailsAdmin.add_extension(:cancancan, RailsAdmin::Extensions::CanCanCan, authorization: true)
@@ -0,0 +1,6 @@
1
+ module RailsAdmin
2
+ module Extensions
3
+ module ControllerExtension
4
+ end
5
+ end
6
+ end
@@ -8,8 +8,8 @@ module RailsAdmin
8
8
  require 'rails_admin/extensions/history/history'
9
9
  end
10
10
 
11
- def latest
12
- ::RailsAdmin::History.latest
11
+ def latest(count = 100)
12
+ ::RailsAdmin::History.latest(count)
13
13
  end
14
14
 
15
15
  def delete_object(object, model, user)
@@ -11,8 +11,8 @@ module RailsAdmin
11
11
  default_scope { order('id DESC') }
12
12
 
13
13
  class << self
14
- def latest
15
- limit(100)
14
+ def latest(count = 100)
15
+ limit(count)
16
16
  end
17
17
 
18
18
  def create_history_item(message, object, abstract_model, user)
@@ -1,3 +1,5 @@
1
+ require 'active_support/core_ext/string/strip'
2
+
1
3
  module RailsAdmin
2
4
  module Extensions
3
5
  module PaperTrail
@@ -21,7 +23,7 @@ module RailsAdmin
21
23
  end
22
24
 
23
25
  def username
24
- @user_class.find(@version.whodunnit).try(:email) rescue nil || @version.whodunnit
26
+ (@user_class.find(@version.whodunnit).try(:email) rescue nil) || @version.whodunnit
25
27
  end
26
28
 
27
29
  def item
@@ -29,6 +31,12 @@ module RailsAdmin
29
31
  end
30
32
  end
31
33
 
34
+ module ControllerExtension
35
+ def user_for_paper_trail
36
+ _current_user.try(:id) || _current_user
37
+ end
38
+ end
39
+
32
40
  class AuditingAdapter
33
41
  COLUMN_MAPPING = {
34
42
  table: :item_type,
@@ -36,11 +44,26 @@ module RailsAdmin
36
44
  item: :item_id,
37
45
  created_at: :created_at,
38
46
  message: :event,
39
- }
47
+ }.freeze
48
+ E_VERSION_MODEL_NOT_SET = <<-EOS.strip_heredoc.freeze
49
+ Please set up PaperTrail's version model explicitly.
50
+
51
+ config.audit_with :paper_trail, 'User', 'PaperTrail::Version'
52
+
53
+ If you have configured a model to use a custom version class
54
+ (https://github.com/paper-trail-gem/paper_trail#6a-custom-version-classes)
55
+ that configuration will take precedence over what you specify in
56
+ `audit_with`.
57
+ EOS
58
+
59
+ def self.setup
60
+ raise('PaperTrail not found') unless defined?(::PaperTrail)
61
+ RailsAdmin::Extensions::ControllerExtension.send(:include, ControllerExtension)
62
+ end
40
63
 
41
64
  def initialize(controller, user_class = 'User', version_class = '::Version')
42
- fail('PaperTrail not found') unless defined?(PaperTrail)
43
65
  @controller = controller
66
+ @controller.send(:set_paper_trail_whodunnit) if @controller
44
67
  begin
45
68
  @user_class = user_class.to_s.constantize
46
69
  rescue NameError
@@ -50,12 +73,14 @@ module RailsAdmin
50
73
  begin
51
74
  @version_class = version_class.to_s.constantize
52
75
  rescue NameError
53
- raise "Please set up Papertrail's version model explicitly. Ex: config.audit_with :paper_trail, 'User', 'PaperTrail::Version'"
76
+ raise E_VERSION_MODEL_NOT_SET
54
77
  end
55
78
  end
56
79
 
57
- def latest
58
- @version_class.order('id DESC').limit(100).collect { |version| VersionProxy.new(version, @user_class) }
80
+ def latest(count = 100)
81
+ @version_class.
82
+ order(id: :desc).includes(:item).limit(count).
83
+ collect { |version| VersionProxy.new(version, @user_class) }
59
84
  end
60
85
 
61
86
  def delete_object(_object, _model, _user)
@@ -80,6 +105,7 @@ module RailsAdmin
80
105
 
81
106
  protected
82
107
 
108
+ # - model - a RailsAdmin::AbstractModel
83
109
  def listing_for_model_or_object(model, object, query, sort, sort_reverse, all, page, per_page)
84
110
  if sort.present?
85
111
  sort = COLUMN_MAPPING[sort.to_sym]
@@ -88,29 +114,45 @@ module RailsAdmin
88
114
  sort_reverse = 'true'
89
115
  end
90
116
 
91
- model_name = model.model.name
92
-
93
117
  current_page = page.presence || '1'
94
118
 
95
- versions = version_class_for(model_name).where item_type: model_name
96
- versions = versions.where item_id: object.id if object
119
+ versions = object.nil? ? versions_for_model(model) : object.public_send(model.model.versions_association_name)
97
120
  versions = versions.where('event LIKE ?', "%#{query}%") if query.present?
98
121
  versions = versions.order(sort_reverse == 'true' ? "#{sort} DESC" : sort)
99
122
  versions = all ? versions : versions.send(Kaminari.config.page_method_name, current_page).per(per_page)
100
- paginated_proxies = Kaminari.paginate_array([], total_count: versions.total_count)
101
- paginated_proxies = paginated_proxies.page(current_page).per(per_page)
123
+ paginated_proxies = Kaminari.paginate_array([], total_count: versions.try(:total_count) || versions.count)
124
+ paginated_proxies = paginated_proxies.send(
125
+ paginated_proxies.respond_to?(Kaminari.config.page_method_name) ? Kaminari.config.page_method_name : :page,
126
+ current_page,
127
+ ).per(per_page)
102
128
  versions.each do |version|
103
129
  paginated_proxies << VersionProxy.new(version, @user_class)
104
130
  end
105
131
  paginated_proxies
106
132
  end
107
133
 
108
- def version_class_for(model_name)
109
- klass = model_name.constantize.
110
- try(:version_class_name).
111
- try(:constantize)
134
+ def versions_for_model(model)
135
+ model_name = model.model.name
136
+ base_class_name = model.model.base_class.name
137
+
138
+ options =
139
+ if base_class_name == model_name
140
+ {item_type: model_name}
141
+ else
142
+ {item_type: base_class_name, item_id: model.model.all}
143
+ end
144
+
145
+ version_class_for(model.model).where(options)
146
+ end
112
147
 
113
- klass || @version_class
148
+ # PT can be configured to use [custom version
149
+ # classes](https://github.com/paper-trail-gem/paper_trail#6a-custom-version-classes)
150
+ #
151
+ # ```ruby
152
+ # has_paper_trail class_name: 'MyVersion'
153
+ # ```
154
+ def version_class_for(model)
155
+ model.paper_trail_options[:class_name].try(:constantize) || @version_class
114
156
  end
115
157
  end
116
158
  end
@@ -5,6 +5,11 @@ module RailsAdmin
5
5
  # You can create another adapter for different authorization behavior, just be certain it
6
6
  # responds to each of the public methods here.
7
7
  class AuthorizationAdapter
8
+ # This method is called first time only and used for setup
9
+ def self.setup
10
+ RailsAdmin::Extensions::ControllerExtension.send(:include, ::Pundit)
11
+ end
12
+
8
13
  # See the +authorize_with+ config method for where the initialization happens.
9
14
  def initialize(controller)
10
15
  @controller = controller
@@ -17,7 +22,10 @@ module RailsAdmin
17
22
  # instance if it is available.
18
23
  def authorize(action, abstract_model = nil, model_object = nil)
19
24
  record = model_object || abstract_model && abstract_model.model
20
- fail ::Pundit::NotAuthorizedError.new("not allowed to #{action} this #{record}") unless policy(record).send(action_for_pundit(action)) if action
25
+ if action && !policy(record).send(action_for_pundit(action))
26
+ raise ::Pundit::NotAuthorizedError.new("not allowed to #{action} this #{record}")
27
+ end
28
+ @controller.instance_variable_set(:@_pundit_policy_authorized, true)
21
29
  end
22
30
 
23
31
  # This method is called primarily from the view to determine whether the given user
@@ -33,7 +41,7 @@ module RailsAdmin
33
41
  # and bulk_delete/destroy actions and should return a scope which limits the records
34
42
  # to those which the user can perform the given action on.
35
43
  def query(_action, abstract_model)
36
- @controller.policy_scope(abstract_model.model.all)
44
+ @controller.send(:policy_scope, abstract_model.model.all)
37
45
  rescue ::Pundit::NotDefinedError
38
46
  abstract_model.model.all
39
47
  end
@@ -49,7 +57,7 @@ module RailsAdmin
49
57
  private
50
58
 
51
59
  def policy(record)
52
- @controller.policy(record)
60
+ @controller.send(:policy, record)
53
61
  rescue ::Pundit::NotDefinedError
54
62
  ::ApplicationPolicy.new(@controller.send(:pundit_user), record)
55
63
  end
@@ -3,9 +3,10 @@ require 'csv'
3
3
 
4
4
  module RailsAdmin
5
5
  class CSVConverter
6
- UTF8_ENCODINGS = [nil, '', 'utf8', 'utf-8', 'unicode', 'UTF8', 'UTF-8', 'UNICODE', 'utf8mb4']
7
- TARGET_ENCODINGS = %w(UTF-8 UTF-16LE UTF-16BE UTF-32LE UTF-32BE UTF-7 ISO-8859-1 ISO-8859-15 IBM850 MacRoman Windows-1252 ISO-8859-3 IBM852 ISO-8859-2 Windows-1250 IBM855 ISO-8859-5 KOI8-R MacCyrillic Windows-1251 IBM866 GB2312 GBK GB18030 Big5 Big5-HKSCS EUC-TW EUC-JP ISO-2022-JP Shift_JIS EUC-KR)
8
6
  def initialize(objects = [], schema = {})
7
+ @fields = []
8
+ @associations = []
9
+
9
10
  return self if (@objects = objects).blank?
10
11
 
11
12
  @model = objects.dup.first.class
@@ -34,24 +35,28 @@ module RailsAdmin
34
35
  end
35
36
 
36
37
  def to_csv(options = {})
37
- # encoding shenanigans first
38
- @encoding_from = Encoding.find(UTF8_ENCODINGS.include?(@abstract_model.encoding) ? 'UTF-8' : @abstract_model.encoding)
39
- @encoding_to = Encoding.find(options[:encoding_to].presence || @encoding_from)
38
+ if CSV::VERSION == '3.0.2'
39
+ raise <<-MSG.gsub(/^\s+/, '')
40
+ CSV library bundled with Ruby 2.6.0 has encoding issue, please upgrade Ruby to 2.6.1 or later.
41
+ https://github.com/ruby/csv/issues/62
42
+ MSG
43
+ end
44
+ options = HashWithIndifferentAccess.new(options)
45
+ encoding_to = Encoding.find(options[:encoding_to]) if options[:encoding_to].present?
40
46
 
41
47
  csv_string = generate_csv_string(options)
42
-
43
- if @encoding_to != @encoding_from
44
- csv_string = csv_string.encode(@encoding_to, @encoding_from, invalid: :replace, undef: :replace, replace: '?')
48
+ if encoding_to
49
+ csv_string = csv_string.encode(encoding_to, invalid: :replace, undef: :replace, replace: '?')
45
50
  end
51
+
46
52
  # Add a BOM for utf8 encodings, helps with utf8 auto-detect for some versions of Excel.
47
53
  # Don't add if utf8 but user don't want to touch input encoding:
48
54
  # If user chooses utf8, they will open it in utf8 and BOM will disappear at reading.
49
55
  # But that way "English" users who don't bother and chooses to let utf8 by default won't get BOM added
50
56
  # and will not see it if Excel opens the file with a different encoding.
51
- if options[:encoding_to].present? && @encoding_to == Encoding::UTF_8
52
- csv_string = "\xEF\xBB\xBF#{csv_string}"
53
- end
54
- [!options[:skip_header], @encoding_to.to_s, csv_string]
57
+ csv_string = "\xEF\xBB\xBF#{csv_string}" if encoding_to == Encoding::UTF_8
58
+
59
+ [!options[:skip_header], (encoding_to || csv_string.encoding).to_s, csv_string]
55
60
  end
56
61
 
57
62
  private
@@ -66,10 +71,11 @@ module RailsAdmin
66
71
 
67
72
  def generate_csv_string(options)
68
73
  generator_options = (options[:generator] || {}).symbolize_keys.delete_if { |_, value| value.blank? }
69
- CSV.generate(generator_options) do |csv|
74
+ method = @objects.respond_to?(:find_each) ? :find_each : :each
75
+
76
+ CSV.generate(**generator_options) do |csv|
70
77
  csv << generate_csv_header unless options[:skip_header]
71
78
 
72
- method = @objects.respond_to?(:find_each) ? :find_each : :each
73
79
  @objects.send(method) do |object|
74
80
  csv << generate_csv_row(object)
75
81
  end
@@ -10,6 +10,7 @@ module RailsAdmin
10
10
  '%b' => 'MMM', # The abbreviated month name ("Jan")
11
11
  '%B' => 'MMMM', # The full month name ("January")
12
12
  '%d' => 'DD', # Day of the month (01..31)
13
+ '%-d' => 'D', # Day of the month (1..31)
13
14
  '%D' => 'MM/DD/YY', # American date format mm/dd/yy
14
15
  '%e' => 'D', # Day of the month (1..31)
15
16
  '%F' => 'YY-MM-DD', # ISO 8601 date format
@@ -22,7 +23,7 @@ module RailsAdmin
22
23
  '%S' => 'ss', # Second of the minute (00..60)
23
24
  '%Y' => 'YYYY', # Year with century
24
25
  '%y' => 'YY', # Year without a century (00..99)
25
- }
26
+ }.freeze
26
27
 
27
28
  class << self
28
29
  include RailsAdmin::Support::I18n
@@ -32,16 +33,16 @@ module RailsAdmin
32
33
  format.to_s.scan(/%[AaBbp]/) do |match|
33
34
  case match
34
35
  when '%A'
35
- english = ::I18n.t('date.day_names', locale: :en)
36
+ english = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
36
37
  day_names.each_with_index { |d, i| date_string = date_string.gsub(/#{d}/, english[i]) }
37
38
  when '%a'
38
- english = ::I18n.t('date.abbr_day_names', locale: :en)
39
+ english = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
39
40
  abbr_day_names.each_with_index { |d, i| date_string = date_string.gsub(/#{d}/, english[i]) }
40
41
  when '%B'
41
- english = ::I18n.t('date.month_names', locale: :en)[1..-1]
42
+ english = [nil, "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"][1..-1]
42
43
  month_names.each_with_index { |m, i| date_string = date_string.gsub(/#{m}/, english[i]) }
43
44
  when '%b'
44
- english = ::I18n.t('date.abbr_month_names', locale: :en)[1..-1]
45
+ english = [nil, "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"][1..-1]
45
46
  abbr_month_names.each_with_index { |m, i| date_string = date_string.gsub(/#{m}/, english[i]) }
46
47
  when '%p'
47
48
  date_string = date_string.gsub(/#{::I18n.t('date.time.am', default: "am")}/, 'am')
@@ -88,7 +89,7 @@ module RailsAdmin
88
89
 
89
90
  begin
90
91
  # Adjust with the correct timezone and daylight savint time
91
- datetime_with_wrong_tz = ::DateTime.strptime(delocalized_value, strftime_format)
92
+ datetime_with_wrong_tz = ::DateTime.strptime(delocalized_value, strftime_format.gsub('%-d', '%d'))
92
93
  Time.zone.parse(datetime_with_wrong_tz.strftime('%Y-%m-%d %H:%M:%S'))
93
94
  rescue ArgumentError
94
95
  nil
@@ -6,33 +6,35 @@ module RailsAdmin
6
6
  def abbr_day_names
7
7
  ::I18n.t('date.abbr_day_names', raise: true)
8
8
  rescue ::I18n::ArgumentError
9
- ::I18n.t('date.abbr_day_names', locale: :en)
9
+ ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
10
10
  end
11
11
 
12
12
  def abbr_month_names
13
13
  begin
14
14
  names = ::I18n.t('date.abbr_month_names', raise: true)
15
15
  rescue ::I18n::ArgumentError
16
- names = ::I18n.t('date.abbr_month_names', locale: :en)
16
+ names = [nil, "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
17
17
  end
18
18
  names[1..-1]
19
19
  end
20
20
 
21
21
  def date_format
22
- ::I18n.t('date.formats.default', default: ::I18n.t('date.formats.default', locale: :en))
22
+ ::I18n.t('date.formats.default', raise: true)
23
+ rescue
24
+ "%Y-%m-%d"
23
25
  end
24
26
 
25
27
  def day_names
26
28
  ::I18n.t('date.day_names', raise: true)
27
29
  rescue ::I18n::ArgumentError
28
- ::I18n.t('date.day_names', locale: :en)
30
+ ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
29
31
  end
30
32
 
31
33
  def month_names
32
34
  begin
33
35
  names = ::I18n.t('date.month_names', raise: true)
34
36
  rescue ::I18n::ArgumentError
35
- names = ::I18n.t('date.month_names', locale: :en)
37
+ names = [nil, "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
36
38
  end
37
39
  names[1..-1]
38
40
  end
@@ -1,7 +1,7 @@
1
1
  module RailsAdmin
2
2
  class Version
3
- MAJOR = 0
4
- MINOR = 8
3
+ MAJOR = 2
4
+ MINOR = 2
5
5
  PATCH = 1
6
6
  PRE = nil
7
7
 
data/lib/rails_admin.rb CHANGED
@@ -2,13 +2,13 @@ require 'rails_admin/engine'
2
2
  require 'rails_admin/abstract_model'
3
3
  require 'rails_admin/config'
4
4
  require 'rails_admin/extension'
5
- require 'rails_admin/extensions/cancan'
6
5
  require 'rails_admin/extensions/cancancan'
7
6
  require 'rails_admin/extensions/pundit'
8
7
  require 'rails_admin/extensions/paper_trail'
9
8
  require 'rails_admin/extensions/history'
10
9
  require 'rails_admin/support/csv_converter'
11
10
  require 'rails_admin/support/hash_helper'
11
+ require 'yaml'
12
12
 
13
13
  module RailsAdmin
14
14
  # Setup RailsAdmin
@@ -33,6 +33,28 @@ module RailsAdmin
33
33
  RailsAdmin::Config
34
34
  end
35
35
  end
36
+
37
+ # Backwards-compatible with safe_yaml/load when SafeYAML isn't available.
38
+ # Evaluates available YAML loaders at boot and creates appropriate method,
39
+ # so no conditionals are required at runtime.
40
+ begin
41
+ require 'safe_yaml/load'
42
+ def self.yaml_load(yaml)
43
+ SafeYAML.load(yaml)
44
+ end
45
+ rescue LoadError
46
+ if YAML.respond_to?(:safe_load)
47
+ def self.yaml_load(yaml)
48
+ YAML.safe_load(yaml)
49
+ end
50
+ else
51
+ raise LoadError.new "Safe-loading of YAML is not available. Please install 'safe_yaml' or install Psych 2.0+"
52
+ end
53
+ end
54
+
55
+ def self.yaml_dump(object)
56
+ YAML.dump(object)
57
+ end
36
58
  end
37
59
 
38
60
  require 'rails_admin/bootstrap-sass' unless defined? Bootstrap
@@ -12,18 +12,27 @@ namespace :rails_admin do
12
12
  desc 'CI env for Travis'
13
13
  task :prepare_ci_env do
14
14
  adapter = ENV['CI_DB_ADAPTER'] || 'sqlite3'
15
- database = ENV['CI_DB_DATABASE'] || ('sqlite3' == adapter ? 'db/development.sqlite3' : 'ci_rails_admin')
15
+ database = ('sqlite3' == adapter ? 'db/development.sqlite3' : 'ci_rails_admin')
16
+ username =
17
+ case adapter
18
+ when 'postgresql'
19
+ 'postgres'
20
+ when 'mysql2'
21
+ 'root'
22
+ else
23
+ ''
24
+ end
16
25
 
17
26
  configuration = {
18
27
  'test' => {
19
28
  'adapter' => adapter,
20
29
  'database' => database,
21
- 'username' => ENV['CI_DB_USERNAME'],
22
- 'password' => ENV['CI_DB_PASSWORD'],
23
- 'host' => ENV['CI_DB_HOST'] || 'localhost',
24
- 'encoding' => ENV['CI_DB_ENCODING'] || 'utf8',
25
- 'pool' => (ENV['CI_DB_POOL'] || 5).to_int,
26
- 'timeout' => (ENV['CI_DB_TIMEOUT'] || 5000).to_int,
30
+ 'username' => username,
31
+ 'password' => ('postgresql' == adapter ? 'postgres' : ''),
32
+ 'host' => '127.0.0.1',
33
+ 'encoding' => 'utf8',
34
+ 'pool' => 5,
35
+ 'timeout' => 5000,
27
36
  },
28
37
  }
29
38