avo 0.5.0.beta4 → 0.5.0.beta9

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of avo might be problematic. Click here for more details.

Files changed (293) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +8 -6
  3. data/Gemfile.lock +28 -22
  4. data/app/components/avo/common/badge_viewer_component.html.erb +1 -1
  5. data/app/components/avo/common/gravatar_viewer_component.html.erb +2 -2
  6. data/app/components/avo/common/gravatar_viewer_component.rb +2 -1
  7. data/app/components/avo/edit/fields/trix_field_component.html.erb +1 -1
  8. data/app/components/avo/index/field_wrapper_component.html.erb +1 -1
  9. data/app/components/avo/index/fields/belongs_to_field_component.html.erb +1 -5
  10. data/app/components/avo/index/fields/boolean_group_field_component.html.erb +1 -1
  11. data/app/components/avo/index/fields/gravatar_field_component.html.erb +2 -1
  12. data/app/components/avo/index/fields/has_one_field_component.html.erb +1 -5
  13. data/app/components/avo/index/fields/id_field_component.html.erb +1 -1
  14. data/app/components/avo/index/grid_item_component.html.erb +8 -8
  15. data/app/components/avo/index/grid_item_component.rb +6 -12
  16. data/app/components/avo/index/resource_controls_component.html.erb +12 -4
  17. data/app/components/avo/index/resource_table_component.html.erb +1 -1
  18. data/app/components/avo/index/table_row_component.html.erb +1 -1
  19. data/app/components/avo/show/field_wrapper_component.html.erb +1 -1
  20. data/app/components/avo/show/fields/boolean_group_field_component.html.erb +1 -1
  21. data/app/components/avo/show/fields/external_image_field_component.html.erb +1 -1
  22. data/app/components/avo/views/resource_show_component.html.erb +14 -2
  23. data/app/controllers/avo/actions_controller.rb +6 -8
  24. data/app/controllers/avo/application_controller.rb +30 -6
  25. data/app/controllers/avo/base_controller.rb +5 -16
  26. data/app/controllers/avo/relations_controller.rb +2 -2
  27. data/app/controllers/avo/search_controller.rb +1 -1
  28. data/app/helpers/avo/application_helper.rb +1 -1
  29. data/app/{frontend/css → packs/entrypoints}/application.css +12 -11
  30. data/app/{frontend/packs → packs/entrypoints}/application.js +7 -3
  31. data/app/{frontend → packs}/fonts/nunito-v16-latin-700.eot +0 -0
  32. data/app/{frontend → packs}/fonts/nunito-v16-latin-700.svg +0 -0
  33. data/app/{frontend → packs}/fonts/nunito-v16-latin-700.ttf +0 -0
  34. data/app/{frontend → packs}/fonts/nunito-v16-latin-700.woff +0 -0
  35. data/app/{frontend → packs}/fonts/nunito-v16-latin-700.woff2 +0 -0
  36. data/app/{frontend → packs}/fonts/nunito-v16-latin-regular.eot +0 -0
  37. data/app/{frontend → packs}/fonts/nunito-v16-latin-regular.svg +0 -0
  38. data/app/{frontend → packs}/fonts/nunito-v16-latin-regular.ttf +0 -0
  39. data/app/{frontend → packs}/fonts/nunito-v16-latin-regular.woff +0 -0
  40. data/app/{frontend → packs}/fonts/nunito-v16-latin-regular.woff2 +0 -0
  41. data/app/{frontend → packs}/images/logo.png +0 -0
  42. data/app/{frontend → packs}/importmap.json.erb +0 -0
  43. data/app/{frontend → packs}/js/controllers/action_controller.js +0 -0
  44. data/app/{frontend → packs}/js/controllers/actions_picker_controller.js +0 -0
  45. data/app/{frontend → packs}/js/controllers/alerts_controller.js +0 -0
  46. data/app/{frontend → packs}/js/controllers/attachments_controller.js +0 -0
  47. data/app/{frontend → packs}/js/controllers/boolean_filter_controller.js +0 -0
  48. data/app/{frontend → packs}/js/controllers/fields/code_field_controller.js +0 -0
  49. data/app/{frontend → packs}/js/controllers/fields/date_field_controller.js +0 -0
  50. data/app/{frontend → packs}/js/controllers/fields/simple_mde_controller.js +0 -0
  51. data/app/{frontend → packs}/js/controllers/filter_controller.js +19 -3
  52. data/app/{frontend → packs}/js/controllers/hidden_input_controller.js +0 -0
  53. data/app/{frontend → packs}/js/controllers/item_selector_controller.js +0 -0
  54. data/app/{frontend → packs}/js/controllers/modal_controller.js +0 -0
  55. data/app/{frontend → packs}/js/controllers/per_page_controller.js +5 -1
  56. data/app/{frontend → packs}/js/controllers/select_filter_controller.js +0 -0
  57. data/app/{frontend → packs}/js/controllers/tippy_controller.js +0 -0
  58. data/app/{frontend → packs}/js/controllers/toggle_panel_controller.js +0 -0
  59. data/app/{frontend → packs}/js/helpers/cast_boolean.js +0 -0
  60. data/app/{frontend → packs}/js/toastr.js +0 -0
  61. data/app/{frontend/css → packs/stylesheets}/alerts.css +0 -0
  62. data/app/packs/stylesheets/components/code.css +11 -0
  63. data/app/{frontend/css → packs/stylesheets}/components/status.css +0 -0
  64. data/app/{frontend/css → packs/stylesheets}/fonts.css +0 -0
  65. data/app/{frontend/css → packs/stylesheets}/loader.css +0 -0
  66. data/app/{frontend/css → packs/stylesheets}/pagination.css +0 -0
  67. data/app/{frontend/css → packs/stylesheets}/tailwindcss/base.css +0 -0
  68. data/app/{frontend/css → packs/stylesheets}/tailwindcss/components.css +0 -0
  69. data/app/{frontend/css → packs/stylesheets}/tailwindcss/utilities.css +0 -0
  70. data/app/{frontend/css → packs/stylesheets}/tooltips.css +0 -0
  71. data/app/{frontend/css → packs/stylesheets}/typography.css +0 -0
  72. data/app/{frontend → packs}/svgs/arrow-circle-right.svg +0 -0
  73. data/app/{frontend → packs}/svgs/arrow-left.svg +0 -0
  74. data/app/{frontend → packs}/svgs/avocado.svg +0 -0
  75. data/app/{frontend → packs}/svgs/badge-check-sm.svg +0 -0
  76. data/app/{frontend → packs}/svgs/check-circle.svg +0 -0
  77. data/app/{frontend → packs}/svgs/chevron-down.svg +0 -0
  78. data/app/{frontend → packs}/svgs/chevron-up.svg +0 -0
  79. data/app/{frontend → packs}/svgs/code.svg +0 -0
  80. data/app/{frontend → packs}/svgs/color-swatch.svg +0 -0
  81. data/app/{frontend → packs}/svgs/document-text.svg +0 -0
  82. data/app/{frontend → packs}/svgs/download.svg +0 -0
  83. data/app/{frontend → packs}/svgs/edit.svg +0 -0
  84. data/app/{frontend → packs}/svgs/exclamation-circle-sm.svg +0 -0
  85. data/app/{frontend → packs}/svgs/exclamation-sm.svg +0 -0
  86. data/app/{frontend → packs}/svgs/exclamation.svg +0 -0
  87. data/app/{frontend → packs}/svgs/eye.svg +0 -0
  88. data/app/{frontend → packs}/svgs/filter.svg +0 -0
  89. data/app/{frontend → packs}/svgs/fire.svg +0 -0
  90. data/app/{frontend → packs}/svgs/game-board.svg +0 -0
  91. data/app/{frontend → packs}/svgs/globe.svg +0 -0
  92. data/app/{frontend → packs}/svgs/information-circle-sm.svg +0 -0
  93. data/app/{frontend → packs}/svgs/information-circle.svg +0 -0
  94. data/app/{frontend → packs}/svgs/library.svg +0 -0
  95. data/app/{frontend → packs}/svgs/photograph.svg +0 -0
  96. data/app/{frontend → packs}/svgs/play.svg +0 -0
  97. data/app/{frontend → packs}/svgs/plus-circle.svg +0 -0
  98. data/app/{frontend → packs}/svgs/plus.svg +0 -0
  99. data/app/{frontend → packs}/svgs/question-mark-circle.svg +0 -0
  100. data/app/{frontend → packs}/svgs/save.svg +0 -0
  101. data/app/{frontend → packs}/svgs/selector.svg +0 -0
  102. data/app/{frontend → packs}/svgs/sort-ascending.svg +0 -0
  103. data/app/{frontend → packs}/svgs/sort-descending.svg +0 -0
  104. data/app/{frontend → packs}/svgs/switch-horizontal.svg +0 -0
  105. data/app/{frontend → packs}/svgs/thumbs-down.svg +0 -0
  106. data/app/{frontend → packs}/svgs/thumbs-up.svg +0 -0
  107. data/app/{frontend → packs}/svgs/times.svg +0 -0
  108. data/app/{frontend → packs}/svgs/trash-sm.svg +0 -0
  109. data/app/{frontend → packs}/svgs/trash.svg +0 -0
  110. data/app/{frontend → packs}/svgs/view-grid-add.svg +0 -0
  111. data/app/{frontend → packs}/svgs/view-grid.svg +0 -0
  112. data/app/{frontend → packs}/svgs/view-list.svg +0 -0
  113. data/app/{frontend → packs}/svgs/x-circle.svg +0 -0
  114. data/app/views/avo/actions/show.html.erb +3 -39
  115. data/app/views/avo/attachments/show.html.erb +8 -1
  116. data/app/views/avo/base/_actions.html.erb +0 -6
  117. data/app/views/avo/base/_boolean_filter.html.erb +2 -1
  118. data/app/views/avo/base/_filters.html.erb +4 -11
  119. data/app/views/avo/base/_select_filter.html.erb +2 -1
  120. data/app/views/avo/home/_resources.html.erb +0 -1
  121. data/app/views/avo/partials/_paginator.html.erb +24 -5
  122. data/app/views/avo/relations/new.html.erb +5 -1
  123. data/app/views/layouts/avo/_filter_wrapper.html.erb +1 -1
  124. data/avo.gemspec +1 -1
  125. data/bin/helpers.rb +0 -0
  126. data/bin/rspec +1 -0
  127. data/bin/webpack +3 -1
  128. data/config/webpack/aliases.js +1 -1
  129. data/config/webpack/base.js +14 -0
  130. data/config/webpack/development.js +2 -2
  131. data/config/webpack/production.js +2 -2
  132. data/config/webpack/test.js +2 -2
  133. data/config/webpacker.yml +10 -62
  134. data/db/factories.rb +1 -0
  135. data/lib/avo.rb +5 -16
  136. data/lib/avo/action_model.rb +20 -0
  137. data/lib/avo/app.rb +162 -0
  138. data/lib/avo/base_action.rb +126 -0
  139. data/lib/avo/base_resource.rb +301 -0
  140. data/lib/avo/configuration.rb +6 -4
  141. data/lib/avo/engine.rb +17 -20
  142. data/lib/avo/{app/fields → fields}/badge_field.rb +1 -1
  143. data/lib/avo/{app/fields/field.rb → fields/base_field.rb} +22 -16
  144. data/lib/avo/{app/fields/belongs_to.rb → fields/belongs_to_field.rb} +3 -3
  145. data/lib/avo/{app/fields → fields}/boolean_field.rb +1 -1
  146. data/lib/avo/{app/fields → fields}/boolean_group_field.rb +1 -1
  147. data/lib/avo/{app/fields → fields}/code_field.rb +1 -1
  148. data/lib/avo/{app/fields → fields}/country_field.rb +1 -1
  149. data/lib/avo/{app/fields → fields}/currency_field.rb +1 -1
  150. data/lib/avo/{app/fields → fields}/date_field.rb +0 -2
  151. data/lib/avo/{app/fields → fields}/date_time_field.rb +0 -2
  152. data/lib/avo/{app/fields → fields}/external_image_field.rb +1 -1
  153. data/lib/avo/{app/fields → fields}/field_extensions/has_field_name.rb +2 -9
  154. data/lib/avo/{app/fields → fields}/field_extensions/visible_in_different_views.rb +1 -1
  155. data/lib/avo/{app/fields → fields}/file_field.rb +1 -2
  156. data/lib/avo/{app/fields → fields}/files_field.rb +1 -2
  157. data/lib/avo/{app/fields → fields}/gravatar_field.rb +2 -2
  158. data/lib/avo/{app/fields/has_and_belongs_to_many.rb → fields/has_and_belongs_to_many_field.rb} +1 -1
  159. data/lib/avo/{app/fields/has_many.rb → fields/has_many_field.rb} +1 -1
  160. data/lib/avo/{app/fields/has_one.rb → fields/has_one_field.rb} +1 -1
  161. data/lib/avo/{app/fields → fields}/heading_field.rb +1 -1
  162. data/lib/avo/{app/fields → fields}/hidden_field.rb +0 -2
  163. data/lib/avo/{app/fields → fields}/id_field.rb +1 -1
  164. data/lib/avo/{app/fields → fields}/key_value_field.rb +1 -1
  165. data/lib/avo/{app/fields → fields}/markdown_field.rb +1 -3
  166. data/lib/avo/{app/fields → fields}/number_field.rb +0 -2
  167. data/lib/avo/{app/fields → fields}/password_field.rb +0 -2
  168. data/lib/avo/{app/fields → fields}/select_field.rb +1 -1
  169. data/lib/avo/{app/fields → fields}/status_field.rb +1 -1
  170. data/lib/avo/{app/fields → fields}/text_field.rb +1 -1
  171. data/lib/avo/{app/fields → fields}/textarea_field.rb +0 -2
  172. data/lib/avo/{app/fields → fields}/trix_field.rb +1 -3
  173. data/lib/avo/fields_collector.rb +31 -0
  174. data/lib/avo/filters/base_filter.rb +20 -0
  175. data/lib/avo/filters/boolean_filter.rb +7 -0
  176. data/lib/avo/filters/select_filter.rb +7 -0
  177. data/lib/avo/grid_collector.rb +39 -0
  178. data/lib/avo/{app/grid_fields → grid_fields}/body_field.rb +0 -2
  179. data/lib/avo/{app/grid_fields → grid_fields}/grid_field.rb +0 -0
  180. data/lib/avo/{app/grid_fields → grid_fields}/preview_field.rb +0 -2
  181. data/lib/avo/{app/grid_fields → grid_fields}/title_field.rb +0 -2
  182. data/lib/avo/has_context.rb +7 -0
  183. data/lib/avo/licensing/community_license.rb +6 -0
  184. data/lib/avo/licensing/h_q.rb +88 -0
  185. data/lib/avo/licensing/license.rb +50 -0
  186. data/lib/avo/licensing/license_manager.rb +22 -0
  187. data/lib/avo/licensing/null_license.rb +14 -0
  188. data/lib/avo/licensing/pro_license.rb +11 -0
  189. data/lib/avo/loaders/actions_loader.rb +6 -0
  190. data/lib/avo/loaders/fields_loader.rb +27 -0
  191. data/lib/avo/loaders/filters_loader.rb +6 -0
  192. data/lib/avo/loaders/loader.rb +15 -0
  193. data/lib/avo/services/authorization_service.rb +93 -0
  194. data/lib/avo/services/panel_service.rb +27 -0
  195. data/lib/avo/{app/tools_manager.rb → tools_manager.rb} +0 -0
  196. data/lib/avo/version.rb +1 -1
  197. data/lib/generators/avo/action_generator.rb +11 -5
  198. data/lib/generators/avo/controller_generator.rb +14 -8
  199. data/lib/generators/avo/filter_generator.rb +14 -8
  200. data/lib/generators/avo/install_generator.rb +14 -10
  201. data/lib/generators/avo/locales_generator.rb +11 -7
  202. data/lib/generators/avo/partials_generator.rb +11 -5
  203. data/lib/generators/avo/resource_generator.rb +33 -15
  204. data/lib/generators/avo/templates/{action.rb → action.tt} +4 -6
  205. data/lib/generators/avo/templates/filters/boolean_filter.tt +11 -0
  206. data/lib/generators/avo/templates/filters/select_filter.tt +11 -0
  207. data/lib/generators/avo/templates/initializer/{avo.rb → avo.tt} +6 -0
  208. data/lib/generators/avo/templates/resource/controller.tt +2 -0
  209. data/lib/generators/avo/templates/resource/resource.tt +17 -0
  210. data/public/avo-packs/css/application-38e7e91b.css +5975 -0
  211. data/public/avo-packs/css/application-38e7e91b.css.br +0 -0
  212. data/public/avo-packs/css/application-38e7e91b.css.gz +0 -0
  213. data/public/avo-packs/css/application-38e7e91b.css.map +1 -0
  214. data/public/avo-packs/css/application-38e7e91b.css.map.br +0 -0
  215. data/public/avo-packs/css/application-38e7e91b.css.map.gz +0 -0
  216. data/public/avo-packs/js/219-9aa2b689f44613118203.chunk.js +2 -0
  217. data/public/avo-packs/js/219-9aa2b689f44613118203.chunk.js.br +0 -0
  218. data/public/avo-packs/js/219-9aa2b689f44613118203.chunk.js.gz +0 -0
  219. data/public/avo-packs/js/219-9aa2b689f44613118203.chunk.js.map +1 -0
  220. data/public/avo-packs/js/219-9aa2b689f44613118203.chunk.js.map.br +0 -0
  221. data/public/avo-packs/js/219-9aa2b689f44613118203.chunk.js.map.gz +0 -0
  222. data/public/avo-packs/js/application-2b90fe889f7d6df1ad92.js +26 -0
  223. data/public/avo-packs/js/{application-6ba2bd1bca05d69b96e0.js.LICENSE.txt → application-2b90fe889f7d6df1ad92.js.LICENSE.txt} +17 -17
  224. data/public/avo-packs/js/application-2b90fe889f7d6df1ad92.js.br +0 -0
  225. data/public/avo-packs/js/application-2b90fe889f7d6df1ad92.js.gz +0 -0
  226. data/public/avo-packs/js/application-2b90fe889f7d6df1ad92.js.map +1 -0
  227. data/public/avo-packs/js/application-2b90fe889f7d6df1ad92.js.map.br +0 -0
  228. data/public/avo-packs/js/application-2b90fe889f7d6df1ad92.js.map.gz +0 -0
  229. data/public/avo-packs/manifest.json +46 -23
  230. data/public/avo-packs/media/{fonts/nunito-v16-latin-regular-00fbd8a72a3708b8314cce5f0515640e.svg → images/13ae283c0d7cc04efe7e.svg} +0 -0
  231. data/public/avo-packs/media/{fonts/nunito-v16-latin-regular-00fbd8a72a3708b8314cce5f0515640e.svg.br → images/13ae283c0d7cc04efe7e.svg.br} +0 -0
  232. data/public/avo-packs/media/{fonts/nunito-v16-latin-regular-00fbd8a72a3708b8314cce5f0515640e.svg.gz → images/13ae283c0d7cc04efe7e.svg.gz} +0 -0
  233. data/public/avo-packs/media/{fonts/nunito-v16-latin-700-35bd1c96bc2e402cf22ea812ae067995.svg → images/195026a50008c53526ef.svg} +0 -0
  234. data/public/avo-packs/media/{fonts/nunito-v16-latin-700-35bd1c96bc2e402cf22ea812ae067995.svg.br → images/195026a50008c53526ef.svg.br} +0 -0
  235. data/public/avo-packs/media/{fonts/nunito-v16-latin-700-35bd1c96bc2e402cf22ea812ae067995.svg.gz → images/195026a50008c53526ef.svg.gz} +0 -0
  236. data/public/avo-packs/media/{fonts/nunito-v16-latin-regular-cb632c9fe211ba2c2bf1564c9a9295cc.woff → images/1f30e08faa7c60d1f7ac.woff} +0 -0
  237. data/public/avo-packs/media/{fonts/nunito-v16-latin-700-2cc22f9c0cf217cbfc371f3b74992305.ttf → images/1fd17dabf6b7d2b15348.ttf} +0 -0
  238. data/public/avo-packs/media/{fonts/nunito-v16-latin-700-2cc22f9c0cf217cbfc371f3b74992305.ttf.br → images/1fd17dabf6b7d2b15348.ttf.br} +0 -0
  239. data/public/avo-packs/media/{fonts/nunito-v16-latin-700-2cc22f9c0cf217cbfc371f3b74992305.ttf.gz → images/1fd17dabf6b7d2b15348.ttf.gz} +0 -0
  240. data/public/avo-packs/media/{fonts/nunito-v16-latin-regular-bcf84d6cb8a0ac214c8c14ba9af834f3.woff2 → images/39a18f443d434999b89b.woff2} +0 -0
  241. data/public/avo-packs/media/{fonts/nunito-v16-latin-700-412073df419ad5f6f8f2ea76eb4aced9.woff2 → images/4ad349571e28bb59c5a5.woff2} +0 -0
  242. data/public/avo-packs/media/{fonts/nunito-v16-latin-regular-2fae1e2418251b68fe5d0505ab93dd5c.eot → images/57a5470848663767abbf.eot} +0 -0
  243. data/public/avo-packs/media/{fonts/nunito-v16-latin-regular-df8c4bee41b6ca0ed2b7b71456ed7fbb.ttf → images/b2e4cf0fab6c8ca66b7f.ttf} +0 -0
  244. data/public/avo-packs/media/{fonts/nunito-v16-latin-regular-df8c4bee41b6ca0ed2b7b71456ed7fbb.ttf.br → images/b2e4cf0fab6c8ca66b7f.ttf.br} +0 -0
  245. data/public/avo-packs/media/{fonts/nunito-v16-latin-regular-df8c4bee41b6ca0ed2b7b71456ed7fbb.ttf.gz → images/b2e4cf0fab6c8ca66b7f.ttf.gz} +0 -0
  246. data/public/avo-packs/media/{fonts/nunito-v16-latin-700-df7e79af617f98cd3b95d320e8b2a1af.eot → images/b78d61ab7e046de8c156.eot} +0 -0
  247. data/public/avo-packs/media/{fonts/nunito-v16-latin-700-7c472b19cb573f537bad8ef62ca917ac.woff → images/c9ab29becb76ddab01d0.woff} +0 -0
  248. data/public/avo-packs/media/images/{logo-edf8d8d0d263e0c1f73bb32a222d9991.png → f1b4befac91a3336db9a.png} +0 -0
  249. metadata +195 -193
  250. data/app/frontend/css/components/code.css +0 -27
  251. data/app/views/layouts/avo/application_vue.html.erb +0 -61
  252. data/config/webpack/environment.js +0 -18
  253. data/config/webpacker_packed.yml +0 -86
  254. data/db/migrate/20210305082639_add_url_to_teams.rb +0 -5
  255. data/lib/avo/app/action.rb +0 -145
  256. data/lib/avo/app/actions_loader.rb +0 -11
  257. data/lib/avo/app/app.rb +0 -183
  258. data/lib/avo/app/fields_loader.rb +0 -29
  259. data/lib/avo/app/filter.rb +0 -23
  260. data/lib/avo/app/filters/boolean_filter.rb +0 -13
  261. data/lib/avo/app/filters/select_filter.rb +0 -13
  262. data/lib/avo/app/licensing/community_license.rb +0 -4
  263. data/lib/avo/app/licensing/hq.rb +0 -86
  264. data/lib/avo/app/licensing/license.rb +0 -48
  265. data/lib/avo/app/licensing/license_manager.rb +0 -25
  266. data/lib/avo/app/licensing/null_license.rb +0 -12
  267. data/lib/avo/app/licensing/pro_license.rb +0 -9
  268. data/lib/avo/app/resource.rb +0 -299
  269. data/lib/avo/app/resource_grid_fields.rb +0 -30
  270. data/lib/avo/app/services/authorization_service.rb +0 -110
  271. data/lib/avo/app/services/panel_service.rb +0 -25
  272. data/lib/avo/app/tool.rb +0 -5
  273. data/lib/generators/avo/templates/filters/boolean_filter.rb +0 -17
  274. data/lib/generators/avo/templates/filters/select_filter.rb +0 -17
  275. data/lib/generators/avo/templates/resource/%plural_name%_controller.tt +0 -2
  276. data/lib/generators/avo/templates/resource/%singular_name%.tt +0 -20
  277. data/public/avo-packs/css/application-3598cfbb.css +0 -6
  278. data/public/avo-packs/css/application-3598cfbb.css.br +0 -0
  279. data/public/avo-packs/css/application-3598cfbb.css.gz +0 -0
  280. data/public/avo-packs/js/1-0565987ca0c3045602ad.chunk.js +0 -2
  281. data/public/avo-packs/js/1-0565987ca0c3045602ad.chunk.js.br +0 -0
  282. data/public/avo-packs/js/1-0565987ca0c3045602ad.chunk.js.gz +0 -0
  283. data/public/avo-packs/js/1-0565987ca0c3045602ad.chunk.js.map +0 -1
  284. data/public/avo-packs/js/1-0565987ca0c3045602ad.chunk.js.map.br +0 -0
  285. data/public/avo-packs/js/1-0565987ca0c3045602ad.chunk.js.map.gz +0 -0
  286. data/public/avo-packs/js/application-6ba2bd1bca05d69b96e0.js +0 -26
  287. data/public/avo-packs/js/application-6ba2bd1bca05d69b96e0.js.br +0 -0
  288. data/public/avo-packs/js/application-6ba2bd1bca05d69b96e0.js.gz +0 -0
  289. data/public/avo-packs/js/application-6ba2bd1bca05d69b96e0.js.map +0 -1
  290. data/public/avo-packs/js/application-6ba2bd1bca05d69b96e0.js.map.br +0 -0
  291. data/public/avo-packs/js/application-6ba2bd1bca05d69b96e0.js.map.gz +0 -0
  292. data/public/avo-packs/manifest.json.br +0 -0
  293. data/public/avo-packs/manifest.json.gz +0 -0
@@ -0,0 +1,301 @@
1
+ module Avo
2
+ class BaseResource
3
+ extend ActiveSupport::DescendantsTracker
4
+ extend FieldsCollector
5
+ extend HasContext
6
+
7
+ attr_accessor :view
8
+ attr_accessor :model
9
+ attr_accessor :user
10
+ attr_accessor :params
11
+
12
+ class_attribute :id, default: :id
13
+ class_attribute :title, default: :id
14
+ class_attribute :search, default: [:id]
15
+ class_attribute :includes, default: []
16
+ class_attribute :model_class
17
+ class_attribute :translation_key
18
+ class_attribute :default_view_type, default: :table
19
+ class_attribute :devise_password_optional, default: false
20
+ class_attribute :actions_loader
21
+ class_attribute :filters_loader
22
+ class_attribute :fields
23
+ class_attribute :grid_loader
24
+
25
+ class << self
26
+ def grid(&block)
27
+ grid_collector = GridCollector.new
28
+ grid_collector.instance_eval(&block)
29
+
30
+ self.grid_loader = grid_collector
31
+ end
32
+
33
+ def action(action_class)
34
+ self.actions_loader ||= Avo::Loaders::Loader.new
35
+
36
+ self.actions_loader.use action_class
37
+ end
38
+
39
+ def filter(filter_class)
40
+ self.filters_loader ||= Avo::Loaders::Loader.new
41
+
42
+ self.filters_loader.use filter_class
43
+ end
44
+ end
45
+
46
+ def hydrate(model: nil, view: nil, user: nil, params: nil)
47
+ @view = view if view.present?
48
+ @user = user if user.present?
49
+ @params = params if params.present?
50
+
51
+ if model.present?
52
+ @model = model
53
+
54
+ hydrate_model_with_default_values if @view == :new
55
+ end
56
+
57
+ self
58
+ end
59
+
60
+ def get_field_definitions
61
+ return [] if self.class.fields.blank?
62
+
63
+ self.class.fields.map do |field|
64
+ field.hydrate(resource: self, panel_name: default_panel_name, user: user)
65
+ end
66
+ end
67
+
68
+ def get_fields(panel: nil, reflection: nil)
69
+ fields = get_field_definitions.select do |field|
70
+ field.send("show_on_#{@view.to_s}")
71
+ end
72
+ .select do |field|
73
+ field.visible?
74
+ end
75
+ .select do |field|
76
+ unless field.respond_to?(:foreign_key) &&
77
+ reflection.present? &&
78
+ reflection.respond_to?(:foreign_key) &&
79
+ reflection.foreign_key == field.foreign_key
80
+ true
81
+ end
82
+ end
83
+
84
+ if panel.present?
85
+ fields = fields.select do |field|
86
+ field.panel_name == panel
87
+ end
88
+ end
89
+
90
+ fields = fields.map do |field|
91
+ field.hydrate(model: @model, view: @view, resource: self)
92
+ end
93
+
94
+ fields
95
+ end
96
+
97
+ def get_grid_fields
98
+ return if self.class.grid_loader.blank?
99
+
100
+ self.class.grid_loader.hydrate(model: @model, view: @view, resource: self)
101
+ end
102
+
103
+ def get_filters
104
+ return [] if self.class.filters_loader.blank?
105
+
106
+ self.class.filters_loader.bag
107
+ end
108
+
109
+ def get_actions
110
+ return [] if self.class.actions_loader.blank?
111
+
112
+ self.class.actions_loader.bag
113
+ end
114
+
115
+ def default_panel_name
116
+ return @params[:related_name].capitalize if @params[:related_name].present?
117
+
118
+ case @view
119
+ when :show
120
+ I18n.t('avo.resource_details', item: self.name.downcase, title: model_title).upcase_first
121
+ when :edit
122
+ I18n.t('avo.update_item', item: self.name.downcase, title: model_title).upcase_first
123
+ when :new
124
+ I18n.t('avo.create_new_item', item: self.name.downcase).upcase_first
125
+ end
126
+ end
127
+
128
+ def panels
129
+ panels = [
130
+ {
131
+ name: default_panel_name,
132
+ type: :fields,
133
+ in_panel: true,
134
+ }
135
+ ]
136
+
137
+ panels
138
+ end
139
+
140
+ def model_class
141
+ return self.class.model_class if self.class.model_class.present?
142
+
143
+ return @model.class if @model.present?
144
+
145
+ self.class.name.demodulize.chomp('Resource').safe_constantize
146
+ end
147
+
148
+ def model_title
149
+ return @model.send title if @model.present?
150
+
151
+ name
152
+ end
153
+
154
+ def name
155
+ return @name if @name.present?
156
+
157
+ return I18n.t(@translation_key, count: 1).capitalize if @translation_key
158
+
159
+ self.class.name.demodulize.chomp('Resource').titlecase
160
+ end
161
+
162
+ def singular_name
163
+ name
164
+ end
165
+
166
+ def plural_name
167
+ return I18n.t(@translation_key, count: 2).capitalize if @translation_key
168
+
169
+ name.pluralize
170
+ end
171
+
172
+ def underscore_name
173
+ return @name if @name.present?
174
+
175
+ self.class.name.demodulize.underscore
176
+ end
177
+
178
+ def available_view_types
179
+ view_types = [:table]
180
+
181
+ view_types << :grid if get_grid_fields.present?
182
+
183
+ view_types
184
+ end
185
+
186
+ def route_key
187
+ model_class.model_name.route_key
188
+ end
189
+
190
+ def context
191
+ self.class.context
192
+ end
193
+
194
+ def query_search(query: '', via_resource_name: , via_resource_id:, user:)
195
+ # model_class = self.model
196
+
197
+ db_query = AuthorizationService.apply_policy(user, model_class)
198
+
199
+ if via_resource_name.present?
200
+ related_model = App.get_resource_by_name(via_resource_name).model
201
+
202
+ db_query = related_model.find(via_resource_id).public_send(self.plural_name.downcase)
203
+ end
204
+
205
+ new_query = []
206
+
207
+ [self.search].flatten.each_with_index do |search_by, index|
208
+ new_query.push 'or' if index != 0
209
+
210
+ new_query.push "text(#{search_by}) ILIKE '%#{query}%'"
211
+ end
212
+
213
+ db_query.where(new_query.join(' '))
214
+ end
215
+
216
+ def attached_file_fields
217
+ get_field_definitions.select do |field|
218
+ [Avo::Fields::FileField, Avo::Fields::FilesField].include? field.class
219
+ end
220
+ end
221
+
222
+ def fill_model(model, params)
223
+ # Map the received params to their actual fields
224
+ fields_by_database_id = self.get_field_definitions.map { |field| [field.database_id(model).to_s, field] }.to_h
225
+
226
+ params.each do |key, value|
227
+ field = fields_by_database_id[key]
228
+
229
+ next unless field
230
+
231
+ model = field.fill_field model, key, value
232
+ end
233
+
234
+ model
235
+ end
236
+
237
+ def authorization
238
+ Avo::Services::AuthorizationService.new(user, model)
239
+ end
240
+
241
+ def file_hash
242
+ content_to_be_hashed = ''
243
+
244
+ # resource file hash
245
+ resource_path = Rails.root.join('app', 'avo', 'resources', "#{name.underscore}.rb").to_s
246
+ if File.file? resource_path
247
+ content_to_be_hashed += File.read(resource_path)
248
+ end
249
+
250
+ # policy file hash
251
+ policy_path = Rails.root.join('app', 'policies', "#{name.underscore}_policy.rb").to_s
252
+ if File.file? policy_path
253
+ content_to_be_hashed += File.read(policy_path)
254
+ end
255
+
256
+ Digest::MD5.hexdigest(content_to_be_hashed)
257
+ end
258
+
259
+ def cache_hash(parent_model)
260
+ if parent_model.present?
261
+ [self.model, self.file_hash, parent_model]
262
+ else
263
+ [self.model, self.file_hash]
264
+ end
265
+ end
266
+
267
+ # For :new views we're hydrating the model with the values from the resource's default attribute.
268
+ # We will not overwrite any attributes that come pre-filled in the model.
269
+ def hydrate_model_with_default_values
270
+ default_values = get_fields.select do |field|
271
+ !field.computed
272
+ end
273
+ .map do |field|
274
+ id = field.id
275
+ value = field.value
276
+
277
+ if field.respond_to? :foreign_key
278
+ id = field.foreign_key.to_sym
279
+
280
+ reflection = @model._reflections[@params[:via_relation]]
281
+
282
+ if reflection.present? && reflection.foreign_key.present?
283
+ value = @params[:via_resource_id]
284
+ end
285
+ end
286
+
287
+ [id, value]
288
+ end
289
+ .to_h
290
+ .select do |id, value|
291
+ value.present?
292
+ end
293
+
294
+ default_values.each do |id, value|
295
+ if @model.send(id).nil?
296
+ @model.send("#{id}=", value)
297
+ end
298
+ end
299
+ end
300
+ end
301
+ end
@@ -9,8 +9,6 @@ module Avo
9
9
  attr_accessor :locale
10
10
  attr_accessor :currency
11
11
  attr_accessor :default_view_type
12
- attr_accessor :hide_resource_overview_component
13
- attr_accessor :hide_documentation_link
14
12
  attr_accessor :license
15
13
  attr_accessor :license_key
16
14
  attr_accessor :authorization_methods
@@ -20,6 +18,7 @@ module Avo
20
18
  attr_accessor :full_width_container
21
19
  attr_accessor :full_width_index_view
22
20
  attr_accessor :cache_resources_on_index_view
21
+ attr_accessor :context
23
22
 
24
23
  def initialize
25
24
  @root_path = '/avo'
@@ -31,8 +30,6 @@ module Avo
31
30
  @locale = 'en-US'
32
31
  @currency = 'USD'
33
32
  @default_view_type = :table
34
- @hide_resource_overview_component = false
35
- @hide_documentation_link = false
36
33
  @license = 'community'
37
34
  @license_key = nil
38
35
  @current_user = proc {}
@@ -50,6 +47,7 @@ module Avo
50
47
  @full_width_container = false
51
48
  @full_width_index_view = false
52
49
  @cache_resources_on_index_view = Avo::PACKED
50
+ @context = proc {}
53
51
  end
54
52
 
55
53
  def locale_tag
@@ -71,6 +69,10 @@ module Avo
71
69
  def authenticate_with(&block)
72
70
  @authenticate = block if block.present?
73
71
  end
72
+
73
+ def set_context(&block)
74
+ @context = block if block.present?
75
+ end
74
76
  end
75
77
 
76
78
  def self.configuration
data/lib/avo/engine.rb CHANGED
@@ -8,24 +8,25 @@ module Avo
8
8
  class Engine < ::Rails::Engine
9
9
  isolate_namespace Avo
10
10
 
11
- initializer 'avo.autoload', before: :set_autoload_paths do |app|
12
- {
13
- 'Avo::Resources': ['app', 'avo', 'resources'],
14
- 'Avo::Filters': ['app', 'avo', 'filters'],
15
- 'Avo::Actions': ['app', 'avo', 'actions'],
16
- }.each do |namespace, path|
17
- next unless Rails.root.join(*path).exist?
18
-
19
- Rails.autoloaders.main.push_dir(Rails.root.join(*path), namespace: namespace.to_s.safe_constantize)
20
- end
11
+ config.after_initialize do
12
+ # Boot Avo
13
+ ::Avo::App.boot
21
14
  end
22
15
 
23
- initializer 'avo.init' do |app|
24
- avo_root_path = Avo::Engine.root.to_s
16
+ initializer 'avo.autoload', before: :set_autoload_paths do |app|
17
+ Rails.autoloaders.main.push_dir(Rails.root.join('app', 'avo', 'filters'))
18
+ Rails.autoloaders.main.push_dir(Rails.root.join('app', 'avo', 'actions'))
19
+ Rails.autoloaders.main.push_dir(Rails.root.join('app', 'avo', 'resources'))
20
+ end
25
21
 
26
- app.config.middleware.use I18n::JS::Middleware
22
+ initializer 'avo.init_fields' do |app|
23
+ # Init the fields
24
+ ::Avo::App.init_fields
25
+ end
27
26
 
28
- if Avo::IN_DEVELOPMENT
27
+ initializer 'avo.reload_avo_files' do |app|
28
+ if Avo::IN_DEVELOPMENT && ENV['RELOAD_AVO_FILES']
29
+ avo_root_path = Avo::Engine.root.to_s
29
30
  # Register reloader
30
31
  app.reloaders << app.config.file_watcher.new([], {
31
32
  Avo::Engine.root.join('lib', 'avo').to_s => ['rb'],
@@ -33,19 +34,15 @@ module Avo
33
34
 
34
35
  # What to do on file change
35
36
  config.to_prepare do
36
- Dir.glob(avo_root_path + '/lib/avo/app/**/*.rb'.to_s).each { |c| load c }
37
+ Dir.glob(avo_root_path + '/lib/avo/**/*.rb'.to_s).each { |c| load c }
37
38
  Avo::App.boot
38
39
  end
39
- else
40
- Dir.glob(avo_root_path + '/lib/avo/app/**/*.rb'.to_s).each { |c| require c }
41
-
42
- Avo::App.boot if Avo::PACKED
43
40
  end
44
41
  end
45
42
 
46
43
  initializer 'webpacker.proxy' do |app|
47
44
  app.config.debug_exception_response_format = :api
48
- app.config.logger = ::Logger.new(STDOUT)
45
+ # app.config.logger = ::Logger.new(STDOUT)
49
46
 
50
47
  insert_middleware = begin
51
48
  Avo.webpacker.config.dev_server.present?
@@ -1,6 +1,6 @@
1
1
  module Avo
2
2
  module Fields
3
- class BadgeField < Field
3
+ class BadgeField < BaseField
4
4
  def initialize(name, **args, &block)
5
5
  @defaults = {
6
6
  partial_name: 'badge-field',
@@ -1,11 +1,9 @@
1
- require_relative 'field_extensions/visible_in_different_views'
2
- require_relative 'field_extensions/has_field_name'
3
-
4
1
  module Avo
5
2
  module Fields
6
- class Field
7
- include Avo::Fields::FieldExtensions::VisibleOnDifferentViews
3
+ class BaseField
4
+ extend ActiveSupport::DescendantsTracker
8
5
  extend Avo::Fields::FieldExtensions::HasFieldName
6
+ include Avo::Fields::FieldExtensions::VisibleInDifferentViews
9
7
 
10
8
  attr_accessor :id
11
9
  attr_accessor :name
@@ -26,17 +24,18 @@ module Avo
26
24
  attr_accessor :placeholder
27
25
  attr_accessor :help
28
26
  attr_accessor :default
29
- attr_accessor :can_see
27
+ attr_accessor :visible
30
28
  attr_accessor :model
31
29
  attr_accessor :resource
32
30
  attr_accessor :view
33
31
  attr_accessor :user
34
32
  attr_accessor :action
35
- attr_accessor :grid_position
36
33
  attr_accessor :meta
37
34
  attr_accessor :panel_name
38
35
  attr_accessor :link_to_resource
39
36
 
37
+ class_attribute :field_name_attribute
38
+
40
39
  @meta = {}
41
40
 
42
41
  def initialize(id, **args, &block)
@@ -66,8 +65,7 @@ module Avo
66
65
  placeholder: id.to_s.humanize,
67
66
  help: nil,
68
67
  default: nil,
69
- can_see: nil,
70
- grid_position: false,
68
+ visible: true,
71
69
  meta: {},
72
70
  panel_name: nil,
73
71
  }
@@ -103,27 +101,35 @@ module Avo
103
101
  self
104
102
  end
105
103
 
104
+ def visible?
105
+ if visible.present? and visible.respond_to? :call
106
+ visible.call
107
+ else
108
+ visible
109
+ end
110
+ end
111
+
106
112
  def value
107
113
  # Get model value
108
- value = @model.send(id) if model_or_class(@model) == 'model' and @model.respond_to? id
114
+ final_value = @model.send(id) if model_or_class(@model) == 'model' and @model.respond_to? id
109
115
 
110
116
  if @view === :new or @action.present?
111
117
  if default.present? and default.respond_to? :call
112
- value = default.call @model, @resource, @view, self
118
+ final_value = default.call
113
119
  else
114
- value = default
120
+ final_value = default
115
121
  end
116
122
  end
117
123
 
118
124
  # Run callback block if present
119
125
  if computable and block.present?
120
- value = block.call @model, @resource, @view, self
126
+ final_value = block.call @model, @resource, @view, self
121
127
  end
122
128
 
123
129
  # Run the value through resolver if present
124
- value = @format_using.call value if @format_using.present?
130
+ final_value = @format_using.call final_value if @format_using.present?
125
131
 
126
- value
132
+ final_value
127
133
  end
128
134
 
129
135
  def fill_field(model, key, value)
@@ -172,7 +178,7 @@ module Avo
172
178
  end
173
179
 
174
180
  def type
175
- self.class.name.demodulize.to_s.underscore
181
+ self.class.name.demodulize.to_s.underscore.gsub('_field', '')
176
182
  end
177
183
 
178
184
  private