avo 0.5.0.beta5 → 0.5.0.beta10

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 (275) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +47 -48
  3. data/Gemfile.lock +28 -22
  4. data/Rakefile +14 -14
  5. data/app/components/avo/common/badge_viewer_component.html.erb +1 -1
  6. data/app/components/avo/common/gravatar_viewer_component.html.erb +2 -2
  7. data/app/components/avo/common/gravatar_viewer_component.rb +2 -1
  8. data/app/components/avo/common/multiple_file_viewer_component.rb +1 -1
  9. data/app/components/avo/common/single_file_viewer_component.rb +1 -1
  10. data/app/components/avo/edit/field_wrapper_component.rb +3 -3
  11. data/app/components/avo/edit/fields/trix_field_component.html.erb +1 -1
  12. data/app/components/avo/index/field_wrapper_component.html.erb +1 -1
  13. data/app/components/avo/index/field_wrapper_component.rb +1 -1
  14. data/app/components/avo/index/fields/belongs_to_field_component.html.erb +1 -5
  15. data/app/components/avo/index/fields/boolean_group_field_component.html.erb +1 -1
  16. data/app/components/avo/index/fields/gravatar_field_component.html.erb +2 -1
  17. data/app/components/avo/index/fields/has_one_field_component.html.erb +1 -5
  18. data/app/components/avo/index/fields/id_field_component.html.erb +1 -1
  19. data/app/components/avo/index/grid_item_component.html.erb +2 -2
  20. data/app/components/avo/index/grid_item_component.rb +10 -9
  21. data/app/components/avo/index/resource_controls_component.html.erb +12 -4
  22. data/app/components/avo/index/resource_controls_component.rb +2 -2
  23. data/app/components/avo/panel_component.rb +7 -6
  24. data/app/components/avo/resource_component.rb +4 -3
  25. data/app/components/avo/show/field_wrapper_component.html.erb +1 -1
  26. data/app/components/avo/show/field_wrapper_component.rb +3 -3
  27. data/app/components/avo/show/fields/boolean_group_field_component.html.erb +1 -1
  28. data/app/components/avo/show/fields/external_image_field_component.html.erb +1 -1
  29. data/app/components/avo/views/resource_edit_component.rb +4 -3
  30. data/app/components/avo/views/resource_index_component.rb +8 -7
  31. data/app/components/avo/views/resource_new_component.rb +4 -3
  32. data/app/components/avo/views/resource_show_component.html.erb +14 -2
  33. data/app/components/avo/views/resource_show_component.rb +21 -21
  34. data/app/controllers/avo/actions_controller.rb +34 -33
  35. data/app/controllers/avo/application_controller.rb +124 -116
  36. data/app/controllers/avo/attachments_controller.rb +3 -3
  37. data/app/controllers/avo/base_controller.rb +80 -87
  38. data/app/controllers/avo/home_controller.rb +2 -2
  39. data/app/controllers/avo/relations_controller.rb +29 -28
  40. data/app/controllers/avo/resources_controller.rb +1 -1
  41. data/app/controllers/avo/search_controller.rb +20 -19
  42. data/app/helpers/avo/application_helper.rb +49 -43
  43. data/app/helpers/avo/resources_helper.rb +11 -11
  44. data/app/mailers/avo/application_mailer.rb +2 -2
  45. data/app/{frontend/css → packs/entrypoints}/application.css +12 -11
  46. data/app/{frontend/packs → packs/entrypoints}/application.js +9 -3
  47. data/app/{frontend → packs}/fonts/nunito-v16-latin-700.eot +0 -0
  48. data/app/{frontend → packs}/fonts/nunito-v16-latin-700.svg +0 -0
  49. data/app/{frontend → packs}/fonts/nunito-v16-latin-700.ttf +0 -0
  50. data/app/{frontend → packs}/fonts/nunito-v16-latin-700.woff +0 -0
  51. data/app/{frontend → packs}/fonts/nunito-v16-latin-700.woff2 +0 -0
  52. data/app/{frontend → packs}/fonts/nunito-v16-latin-regular.eot +0 -0
  53. data/app/{frontend → packs}/fonts/nunito-v16-latin-regular.svg +0 -0
  54. data/app/{frontend → packs}/fonts/nunito-v16-latin-regular.ttf +0 -0
  55. data/app/{frontend → packs}/fonts/nunito-v16-latin-regular.woff +0 -0
  56. data/app/{frontend → packs}/fonts/nunito-v16-latin-regular.woff2 +0 -0
  57. data/app/{frontend → packs}/images/logo.png +0 -0
  58. data/app/{frontend → packs}/importmap.json.erb +0 -0
  59. data/app/{frontend → packs}/js/controllers/action_controller.js +0 -0
  60. data/app/{frontend → packs}/js/controllers/actions_picker_controller.js +0 -0
  61. data/app/{frontend → packs}/js/controllers/alerts_controller.js +0 -0
  62. data/app/{frontend → packs}/js/controllers/attachments_controller.js +0 -0
  63. data/app/{frontend → packs}/js/controllers/boolean_filter_controller.js +0 -0
  64. data/app/{frontend → packs}/js/controllers/fields/code_field_controller.js +14 -14
  65. data/app/{frontend → packs}/js/controllers/fields/date_field_controller.js +0 -0
  66. data/app/{frontend → packs}/js/controllers/fields/simple_mde_controller.js +0 -0
  67. data/app/{frontend → packs}/js/controllers/filter_controller.js +20 -3
  68. data/app/{frontend → packs}/js/controllers/hidden_input_controller.js +0 -0
  69. data/app/{frontend → packs}/js/controllers/item_selector_controller.js +0 -0
  70. data/app/{frontend → packs}/js/controllers/modal_controller.js +0 -0
  71. data/app/{frontend → packs}/js/controllers/per_page_controller.js +5 -1
  72. data/app/{frontend → packs}/js/controllers/select_filter_controller.js +0 -0
  73. data/app/{frontend → packs}/js/controllers/tippy_controller.js +0 -0
  74. data/app/{frontend → packs}/js/controllers/toggle_panel_controller.js +0 -0
  75. data/app/{frontend → packs}/js/helpers/cast_boolean.js +0 -0
  76. data/app/{frontend → packs}/js/toastr.js +1 -0
  77. data/app/{frontend/css → packs/stylesheets}/alerts.css +0 -0
  78. data/app/packs/stylesheets/components/code.css +11 -0
  79. data/app/{frontend/css → packs/stylesheets}/components/status.css +0 -0
  80. data/app/{frontend/css → packs/stylesheets}/fonts.css +0 -0
  81. data/app/{frontend/css → packs/stylesheets}/loader.css +0 -0
  82. data/app/{frontend/css → packs/stylesheets}/pagination.css +0 -0
  83. data/app/{frontend/css → packs/stylesheets}/tailwindcss/base.css +0 -0
  84. data/app/{frontend/css → packs/stylesheets}/tailwindcss/components.css +0 -0
  85. data/app/{frontend/css → packs/stylesheets}/tailwindcss/utilities.css +0 -0
  86. data/app/{frontend/css → packs/stylesheets}/tooltips.css +0 -0
  87. data/app/{frontend/css → packs/stylesheets}/typography.css +0 -0
  88. data/app/{frontend → packs}/svgs/arrow-circle-right.svg +0 -0
  89. data/app/{frontend → packs}/svgs/arrow-left.svg +0 -0
  90. data/app/{frontend → packs}/svgs/avocado.svg +0 -0
  91. data/app/{frontend → packs}/svgs/badge-check-sm.svg +0 -0
  92. data/app/{frontend → packs}/svgs/check-circle.svg +0 -0
  93. data/app/{frontend → packs}/svgs/chevron-down.svg +0 -0
  94. data/app/{frontend → packs}/svgs/chevron-up.svg +0 -0
  95. data/app/{frontend → packs}/svgs/code.svg +0 -0
  96. data/app/{frontend → packs}/svgs/color-swatch.svg +0 -0
  97. data/app/{frontend → packs}/svgs/document-text.svg +0 -0
  98. data/app/{frontend → packs}/svgs/download.svg +0 -0
  99. data/app/{frontend → packs}/svgs/edit.svg +0 -0
  100. data/app/{frontend → packs}/svgs/exclamation-circle-sm.svg +0 -0
  101. data/app/{frontend → packs}/svgs/exclamation-sm.svg +0 -0
  102. data/app/{frontend → packs}/svgs/exclamation.svg +0 -0
  103. data/app/{frontend → packs}/svgs/eye.svg +0 -0
  104. data/app/{frontend → packs}/svgs/filter.svg +0 -0
  105. data/app/{frontend → packs}/svgs/fire.svg +0 -0
  106. data/app/{frontend → packs}/svgs/game-board.svg +0 -0
  107. data/app/{frontend → packs}/svgs/globe.svg +0 -0
  108. data/app/{frontend → packs}/svgs/information-circle-sm.svg +0 -0
  109. data/app/{frontend → packs}/svgs/information-circle.svg +0 -0
  110. data/app/{frontend → packs}/svgs/library.svg +0 -0
  111. data/app/{frontend → packs}/svgs/photograph.svg +0 -0
  112. data/app/{frontend → packs}/svgs/play.svg +0 -0
  113. data/app/{frontend → packs}/svgs/plus-circle.svg +0 -0
  114. data/app/{frontend → packs}/svgs/plus.svg +0 -0
  115. data/app/{frontend → packs}/svgs/question-mark-circle.svg +0 -0
  116. data/app/{frontend → packs}/svgs/save.svg +0 -0
  117. data/app/{frontend → packs}/svgs/selector.svg +0 -0
  118. data/app/{frontend → packs}/svgs/sort-ascending.svg +0 -0
  119. data/app/{frontend → packs}/svgs/sort-descending.svg +0 -0
  120. data/app/{frontend → packs}/svgs/switch-horizontal.svg +0 -0
  121. data/app/{frontend → packs}/svgs/thumbs-down.svg +0 -0
  122. data/app/{frontend → packs}/svgs/thumbs-up.svg +0 -0
  123. data/app/{frontend → packs}/svgs/times.svg +0 -0
  124. data/app/{frontend → packs}/svgs/trash-sm.svg +0 -0
  125. data/app/{frontend → packs}/svgs/trash.svg +0 -0
  126. data/app/{frontend → packs}/svgs/view-grid-add.svg +0 -0
  127. data/app/{frontend → packs}/svgs/view-grid.svg +0 -0
  128. data/app/{frontend → packs}/svgs/view-list.svg +0 -0
  129. data/app/{frontend → packs}/svgs/x-circle.svg +0 -0
  130. data/app/views/avo/actions/show.html.erb +3 -39
  131. data/app/views/avo/attachments/show.html.erb +8 -1
  132. data/app/views/avo/base/_boolean_filter.html.erb +1 -0
  133. data/app/views/avo/base/_filters.html.erb +1 -0
  134. data/app/views/avo/base/_select_filter.html.erb +1 -0
  135. data/app/views/avo/partials/_paginator.html.erb +24 -5
  136. data/app/views/avo/relations/new.html.erb +5 -1
  137. data/app/views/layouts/avo/application.html.erb +0 -5
  138. data/avo.gemspec +31 -31
  139. data/bin/helpers.rb +0 -0
  140. data/bin/rspec +1 -0
  141. data/bin/webpack +3 -1
  142. data/config/initializers/inline_svg.rb +1 -1
  143. data/config/initializers/pagy.rb +1 -1
  144. data/config/routes.rb +12 -12
  145. data/config/spring.rb +5 -5
  146. data/config/webpack/aliases.js +1 -1
  147. data/config/webpack/base.js +14 -0
  148. data/config/webpack/development.js +2 -2
  149. data/config/webpack/production.js +2 -2
  150. data/config/webpack/test.js +2 -2
  151. data/config/webpacker.yml +5 -44
  152. data/db/factories.rb +4 -5
  153. data/lib/avo.rb +6 -6
  154. data/lib/avo/action_model.rb +20 -0
  155. data/lib/avo/app.rb +34 -62
  156. data/lib/avo/base_action.rb +56 -45
  157. data/lib/avo/base_resource.rb +69 -93
  158. data/lib/avo/configuration.rb +16 -22
  159. data/lib/avo/engine.rb +30 -14
  160. data/lib/avo/fields/badge_field.rb +2 -2
  161. data/lib/avo/fields/base_field.rb +38 -29
  162. data/lib/avo/fields/belongs_to_field.rb +13 -12
  163. data/lib/avo/fields/boolean_field.rb +4 -4
  164. data/lib/avo/fields/boolean_group_field.rb +3 -3
  165. data/lib/avo/fields/code_field.rb +4 -4
  166. data/lib/avo/fields/country_field.rb +2 -2
  167. data/lib/avo/fields/currency_field.rb +3 -3
  168. data/lib/avo/fields/date_field.rb +3 -3
  169. data/lib/avo/fields/date_time_field.rb +2 -2
  170. data/lib/avo/fields/external_image_field.rb +2 -2
  171. data/lib/avo/fields/field_extensions/has_field_name.rb +2 -9
  172. data/lib/avo/fields/field_extensions/visible_in_different_views.rb +34 -33
  173. data/lib/avo/fields/file_field.rb +1 -1
  174. data/lib/avo/fields/files_field.rb +2 -2
  175. data/lib/avo/fields/gravatar_field.rb +10 -10
  176. data/lib/avo/fields/has_and_belongs_to_many_field.rb +1 -1
  177. data/lib/avo/fields/has_many_field.rb +1 -1
  178. data/lib/avo/fields/has_one_field.rb +2 -2
  179. data/lib/avo/fields/heading_field.rb +2 -2
  180. data/lib/avo/fields/hidden_field.rb +1 -1
  181. data/lib/avo/fields/id_field.rb +3 -3
  182. data/lib/avo/fields/key_value_field.rb +12 -12
  183. data/lib/avo/fields/markdown_field.rb +2 -2
  184. data/lib/avo/fields/number_field.rb +3 -3
  185. data/lib/avo/fields/password_field.rb +1 -1
  186. data/lib/avo/fields/select_field.rb +8 -12
  187. data/lib/avo/fields/status_field.rb +4 -4
  188. data/lib/avo/fields/text_field.rb +2 -2
  189. data/lib/avo/fields/textarea_field.rb +2 -2
  190. data/lib/avo/fields/trix_field.rb +1 -1
  191. data/lib/avo/fields_collector.rb +30 -0
  192. data/lib/avo/filters/base_filter.rb +6 -6
  193. data/lib/avo/filters/boolean_filter.rb +1 -1
  194. data/lib/avo/filters/select_filter.rb +1 -1
  195. data/lib/avo/grid_collector.rb +39 -0
  196. data/lib/avo/has_context.rb +7 -0
  197. data/lib/avo/licensing/h_q.rb +56 -55
  198. data/lib/avo/licensing/license.rb +5 -5
  199. data/lib/avo/licensing/license_manager.rb +4 -4
  200. data/lib/avo/licensing/null_license.rb +2 -2
  201. data/lib/avo/licensing/pro_license.rb +1 -1
  202. data/lib/avo/loaders/fields_loader.rb +4 -4
  203. data/lib/avo/services/authorization_service.rb +2 -2
  204. data/lib/avo/services/panel_service.rb +4 -4
  205. data/lib/avo/version.rb +1 -1
  206. data/lib/generators/avo/action_generator.rb +4 -4
  207. data/lib/generators/avo/controller_generator.rb +4 -4
  208. data/lib/generators/avo/filter_generator.rb +5 -5
  209. data/lib/generators/avo/install_generator.rb +8 -8
  210. data/lib/generators/avo/locales_generator.rb +5 -5
  211. data/lib/generators/avo/partials_generator.rb +4 -4
  212. data/lib/generators/avo/resource_generator.rb +5 -5
  213. data/lib/generators/avo/templates/action.tt +2 -2
  214. data/lib/tasks/avo_tasks.rake +52 -53
  215. data/public/avo-packs/css/application-4e16d6a6.css +5975 -0
  216. data/public/avo-packs/css/application-4e16d6a6.css.br +0 -0
  217. data/public/avo-packs/css/application-4e16d6a6.css.gz +0 -0
  218. data/public/avo-packs/css/application-4e16d6a6.css.map +1 -0
  219. data/public/avo-packs/css/application-4e16d6a6.css.map.br +0 -0
  220. data/public/avo-packs/css/application-4e16d6a6.css.map.gz +0 -0
  221. data/public/avo-packs/js/219-9aa2b689f44613118203.chunk.js +2 -0
  222. data/public/avo-packs/js/219-9aa2b689f44613118203.chunk.js.br +0 -0
  223. data/public/avo-packs/js/219-9aa2b689f44613118203.chunk.js.gz +0 -0
  224. data/public/avo-packs/js/219-9aa2b689f44613118203.chunk.js.map +1 -0
  225. data/public/avo-packs/js/219-9aa2b689f44613118203.chunk.js.map.br +0 -0
  226. data/public/avo-packs/js/219-9aa2b689f44613118203.chunk.js.map.gz +0 -0
  227. data/public/avo-packs/js/application-8eb130a4688f2c667703.js +26 -0
  228. data/public/avo-packs/js/{application-8849c6e2c8f75d55c666.js.LICENSE.txt → application-8eb130a4688f2c667703.js.LICENSE.txt} +17 -17
  229. data/public/avo-packs/js/application-8eb130a4688f2c667703.js.br +0 -0
  230. data/public/avo-packs/js/application-8eb130a4688f2c667703.js.gz +0 -0
  231. data/public/avo-packs/js/application-8eb130a4688f2c667703.js.map +1 -0
  232. data/public/avo-packs/js/application-8eb130a4688f2c667703.js.map.br +0 -0
  233. data/public/avo-packs/js/application-8eb130a4688f2c667703.js.map.gz +0 -0
  234. data/public/avo-packs/manifest.json +46 -23
  235. data/public/avo-packs/media/{fonts/nunito-v16-latin-regular-00fbd8a72a3708b8314cce5f0515640e.svg → images/13ae283c0d7cc04efe7e.svg} +0 -0
  236. data/public/avo-packs/media/{fonts/nunito-v16-latin-regular-00fbd8a72a3708b8314cce5f0515640e.svg.br → images/13ae283c0d7cc04efe7e.svg.br} +0 -0
  237. data/public/avo-packs/media/{fonts/nunito-v16-latin-regular-00fbd8a72a3708b8314cce5f0515640e.svg.gz → images/13ae283c0d7cc04efe7e.svg.gz} +0 -0
  238. data/public/avo-packs/media/{fonts/nunito-v16-latin-700-35bd1c96bc2e402cf22ea812ae067995.svg → images/195026a50008c53526ef.svg} +0 -0
  239. data/public/avo-packs/media/{fonts/nunito-v16-latin-700-35bd1c96bc2e402cf22ea812ae067995.svg.br → images/195026a50008c53526ef.svg.br} +0 -0
  240. data/public/avo-packs/media/{fonts/nunito-v16-latin-700-35bd1c96bc2e402cf22ea812ae067995.svg.gz → images/195026a50008c53526ef.svg.gz} +0 -0
  241. data/public/avo-packs/media/{fonts/nunito-v16-latin-regular-cb632c9fe211ba2c2bf1564c9a9295cc.woff → images/1f30e08faa7c60d1f7ac.woff} +0 -0
  242. data/public/avo-packs/media/{fonts/nunito-v16-latin-700-2cc22f9c0cf217cbfc371f3b74992305.ttf → images/1fd17dabf6b7d2b15348.ttf} +0 -0
  243. data/public/avo-packs/media/{fonts/nunito-v16-latin-700-2cc22f9c0cf217cbfc371f3b74992305.ttf.br → images/1fd17dabf6b7d2b15348.ttf.br} +0 -0
  244. data/public/avo-packs/media/{fonts/nunito-v16-latin-700-2cc22f9c0cf217cbfc371f3b74992305.ttf.gz → images/1fd17dabf6b7d2b15348.ttf.gz} +0 -0
  245. data/public/avo-packs/media/{fonts/nunito-v16-latin-regular-bcf84d6cb8a0ac214c8c14ba9af834f3.woff2 → images/39a18f443d434999b89b.woff2} +0 -0
  246. data/public/avo-packs/media/{fonts/nunito-v16-latin-700-412073df419ad5f6f8f2ea76eb4aced9.woff2 → images/4ad349571e28bb59c5a5.woff2} +0 -0
  247. data/public/avo-packs/media/{fonts/nunito-v16-latin-regular-2fae1e2418251b68fe5d0505ab93dd5c.eot → images/57a5470848663767abbf.eot} +0 -0
  248. data/public/avo-packs/media/{fonts/nunito-v16-latin-regular-df8c4bee41b6ca0ed2b7b71456ed7fbb.ttf → images/b2e4cf0fab6c8ca66b7f.ttf} +0 -0
  249. data/public/avo-packs/media/{fonts/nunito-v16-latin-regular-df8c4bee41b6ca0ed2b7b71456ed7fbb.ttf.br → images/b2e4cf0fab6c8ca66b7f.ttf.br} +0 -0
  250. data/public/avo-packs/media/{fonts/nunito-v16-latin-regular-df8c4bee41b6ca0ed2b7b71456ed7fbb.ttf.gz → images/b2e4cf0fab6c8ca66b7f.ttf.gz} +0 -0
  251. data/public/avo-packs/media/{fonts/nunito-v16-latin-700-df7e79af617f98cd3b95d320e8b2a1af.eot → images/b78d61ab7e046de8c156.eot} +0 -0
  252. data/public/avo-packs/media/{fonts/nunito-v16-latin-700-7c472b19cb573f537bad8ef62ca917ac.woff → images/c9ab29becb76ddab01d0.woff} +0 -0
  253. data/public/avo-packs/media/images/{logo-edf8d8d0d263e0c1f73bb32a222d9991.png → f1b4befac91a3336db9a.png} +0 -0
  254. metadata +135 -132
  255. data/app/frontend/css/components/code.css +0 -27
  256. data/app/views/layouts/avo/application_vue.html.erb +0 -61
  257. data/config/webpack/environment.js +0 -18
  258. data/db/migrate/20210305082639_add_url_to_teams.rb +0 -5
  259. data/public/avo-packs/css/application-c75ac28c.css +0 -6
  260. data/public/avo-packs/css/application-c75ac28c.css.br +0 -0
  261. data/public/avo-packs/css/application-c75ac28c.css.gz +0 -0
  262. data/public/avo-packs/js/1-0565987ca0c3045602ad.chunk.js +0 -2
  263. data/public/avo-packs/js/1-0565987ca0c3045602ad.chunk.js.br +0 -0
  264. data/public/avo-packs/js/1-0565987ca0c3045602ad.chunk.js.gz +0 -0
  265. data/public/avo-packs/js/1-0565987ca0c3045602ad.chunk.js.map +0 -1
  266. data/public/avo-packs/js/1-0565987ca0c3045602ad.chunk.js.map.br +0 -0
  267. data/public/avo-packs/js/1-0565987ca0c3045602ad.chunk.js.map.gz +0 -0
  268. data/public/avo-packs/js/application-8849c6e2c8f75d55c666.js +0 -26
  269. data/public/avo-packs/js/application-8849c6e2c8f75d55c666.js.br +0 -0
  270. data/public/avo-packs/js/application-8849c6e2c8f75d55c666.js.gz +0 -0
  271. data/public/avo-packs/js/application-8849c6e2c8f75d55c666.js.map +0 -1
  272. data/public/avo-packs/js/application-8849c6e2c8f75d55c666.js.map.br +0 -0
  273. data/public/avo-packs/js/application-8849c6e2c8f75d55c666.js.map.gz +0 -0
  274. data/public/avo-packs/manifest.json.br +0 -0
  275. data/public/avo-packs/manifest.json.gz +0 -0
@@ -3,7 +3,7 @@ module Avo
3
3
  class StatusField < BaseField
4
4
  def initialize(name, **args, &block)
5
5
  @defaults = {
6
- partial_name: 'status-field',
6
+ partial_name: "status-field"
7
7
  }
8
8
 
9
9
  super(name, **args, &block)
@@ -13,10 +13,10 @@ module Avo
13
13
  end
14
14
 
15
15
  def status
16
- status = 'success'
16
+ status = "success"
17
17
  if value.present?
18
- status = 'failed' if @failed_when.include? value.to_sym
19
- status = 'loading' if @loading_when.include? value.to_sym
18
+ status = "failed" if @failed_when.include? value.to_sym
19
+ status = "loading" if @loading_when.include? value.to_sym
20
20
  end
21
21
 
22
22
  status
@@ -3,8 +3,8 @@ module Avo
3
3
  class TextField < BaseField
4
4
  def initialize(name, **args, &block)
5
5
  @defaults = {
6
- partial_name: 'text-field',
7
- computable: true,
6
+ partial_name: "text-field",
7
+ computable: true
8
8
  }.merge(@defaults || {})
9
9
 
10
10
  super(name, **args, &block)
@@ -3,8 +3,8 @@ module Avo
3
3
  class TextareaField < TextField
4
4
  def initialize(name, **args, &block)
5
5
  @defaults = {
6
- partial_name: 'textarea-field',
7
- computable: true,
6
+ partial_name: "textarea-field",
7
+ computable: true
8
8
  }
9
9
 
10
10
  super(name, **args, &block)
@@ -5,7 +5,7 @@ module Avo
5
5
 
6
6
  def initialize(name, **args, &block)
7
7
  @defaults = {
8
- partial_name: 'trix-field',
8
+ partial_name: "trix-field"
9
9
  }
10
10
 
11
11
  super(name, **args, &block)
@@ -0,0 +1,30 @@
1
+ module Avo
2
+ module FieldsCollector
3
+ def field(field_name, as:, **args, &block)
4
+ self.fields ||= []
5
+
6
+ self.fields << parse_field(field_name, as: as, **args, &block)
7
+ end
8
+
9
+ def parse_field(field_name, as:, **args, &block)
10
+ matched_field = Avo::App.fields.find do |field|
11
+ field[:name].to_s == as.to_s
12
+ end
13
+
14
+ if matched_field.present? && matched_field[:class].present?
15
+ klass = matched_field[:class]
16
+
17
+ if block
18
+ klass.new(field_name, **args || {}, &block)
19
+ else
20
+ klass.new(field_name, **args || {})
21
+ end
22
+
23
+ end
24
+ end
25
+
26
+ def heading(body, **args)
27
+ self.fields << Avo::Fields::HeadingField.new(body, **args)
28
+ end
29
+ end
30
+ end
@@ -1,19 +1,19 @@
1
1
  module Avo
2
2
  module Filters
3
3
  class BaseFilter
4
- class_attribute :name, default: 'Filter'
5
- class_attribute :component, default: 'boolean-filter'
6
- class_attribute :default, default: ''
7
- class_attribute :template, default: 'avo/base/select_filter'
4
+ class_attribute :name, default: "Filter"
5
+ class_attribute :component, default: "boolean-filter"
6
+ class_attribute :default, default: ""
7
+ class_attribute :template, default: "avo/base/select_filter"
8
8
 
9
9
  def apply_query(request, query, value)
10
10
  value.symbolize_keys! if value.is_a? Hash
11
11
 
12
- self.apply(request, query, value)
12
+ apply(request, query, value)
13
13
  end
14
14
 
15
15
  def id
16
- self.class.name.underscore.gsub('/', '_')
16
+ self.class.name.underscore.tr("/", "_")
17
17
  end
18
18
  end
19
19
  end
@@ -1,7 +1,7 @@
1
1
  module Avo
2
2
  module Filters
3
3
  class BooleanFilter < BaseFilter
4
- self.template = 'avo/base/boolean_filter'
4
+ self.template = "avo/base/boolean_filter"
5
5
  end
6
6
  end
7
7
  end
@@ -1,7 +1,7 @@
1
1
  module Avo
2
2
  module Filters
3
3
  class SelectFilter < BaseFilter
4
- self.template = 'avo/base/select_filter'
4
+ self.template = "avo/base/select_filter"
5
5
  end
6
6
  end
7
7
  end
@@ -0,0 +1,39 @@
1
+ module Avo
2
+ class GridCollector
3
+ include FieldsCollector
4
+
5
+ attr_accessor :cover_field
6
+ attr_accessor :title_field
7
+ attr_accessor :body_field
8
+
9
+ def initialize
10
+ @cover_field = nil
11
+ @title_field = nil
12
+ @body_field = nil
13
+ end
14
+
15
+ def cover(field_name, as:, **args, &block)
16
+ self.cover_field = parse_field(field_name, as: as, **args, &block)
17
+ end
18
+
19
+ def title(field_name, as:, **args, &block)
20
+ self.title_field = parse_field(field_name, as: as, **args, &block)
21
+ end
22
+
23
+ def body(field_name, as:, **args, &block)
24
+ self.body_field = parse_field(field_name, as: as, **args, &block)
25
+ end
26
+
27
+ def hydrate(model:, view:, resource:)
28
+ cover_field.hydrate(model: model, view: view, resource: resource) if cover_field.present?
29
+ title_field.hydrate(model: model, view: view, resource: resource) if title_field.present?
30
+ body_field.hydrate(model: model, view: view, resource: resource) if title_field.present?
31
+
32
+ self
33
+ end
34
+
35
+ def blank?
36
+ title_field.blank?
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,7 @@
1
+ module Avo
2
+ module HasContext
3
+ def context
4
+ App.context
5
+ end
6
+ end
7
+ end
@@ -3,8 +3,8 @@ module Avo
3
3
  class HQ
4
4
  attr_accessor :current_request
5
5
 
6
- ENDPOINT = 'https://avohq.io/api/v1/licenses/check' unless const_defined?(:ENDPOINT)
7
- CACHE_KEY = 'avo.hq.response' unless const_defined?(:CACHE_KEY)
6
+ ENDPOINT = "https://avohq.io/api/v1/licenses/check" unless const_defined?(:ENDPOINT)
7
+ CACHE_KEY = "avo.hq.response" unless const_defined?(:CACHE_KEY)
8
8
  REQUEST_TIMEOUT = 5 unless const_defined?(:REQUEST_TIMEOUT) # seconds
9
9
 
10
10
  def initialize(current_request)
@@ -13,76 +13,77 @@ module Avo
13
13
  end
14
14
 
15
15
  def response
16
- @hq_response or request
16
+ @hq_response || request
17
17
  end
18
18
 
19
19
  private
20
- def request
21
- return cached_response if has_cached_response
22
-
23
- begin
24
- perform_and_cache_request
25
- rescue HTTParty::Error => exception
26
- cache_and_return_error 'HTTP client error.', exception.message
27
- rescue Net::OpenTimeout => exception
28
- cache_and_return_error 'Request timeout.', exception.message
29
- rescue SocketError => exception
30
- cache_and_return_error 'Connection error.', exception.message
31
- end
20
+
21
+ def request
22
+ return cached_response if has_cached_response
23
+
24
+ begin
25
+ perform_and_cache_request
26
+ rescue HTTParty::Error => exception
27
+ cache_and_return_error "HTTP client error.", exception.message
28
+ rescue Net::OpenTimeout => exception
29
+ cache_and_return_error "Request timeout.", exception.message
30
+ rescue SocketError => exception
31
+ cache_and_return_error "Connection error.", exception.message
32
32
  end
33
+ end
33
34
 
34
- def perform_and_cache_request
35
- hq_response = perform_request
35
+ def perform_and_cache_request
36
+ hq_response = perform_request
36
37
 
37
- return cache_and_return_error 'Avo HQ Internal server error.', hq_response.body if hq_response.code == 500
38
+ return cache_and_return_error "Avo HQ Internal server error.", hq_response.body if hq_response.code == 500
38
39
 
39
- cache_response 1.hour.to_i, hq_response.parsed_response if hq_response.code == 200
40
- end
40
+ cache_response 1.hour.to_i, hq_response.parsed_response if hq_response.code == 200
41
+ end
41
42
 
42
- def cache_response(time, response)
43
- response.merge!(
44
- expiry: time,
45
- **payload,
46
- ).stringify_keys!
43
+ def cache_response(time, response)
44
+ response.merge!(
45
+ expiry: time,
46
+ **payload
47
+ ).stringify_keys!
47
48
 
48
- @cache_store.write(CACHE_KEY, response, expires_in: time)
49
+ @cache_store.write(CACHE_KEY, response, expires_in: time)
49
50
 
50
- @hq_response = response
51
+ @hq_response = response
51
52
 
52
- response
53
- end
53
+ response
54
+ end
54
55
 
55
- def perform_request
56
- puts 'Performing request to avohq.io API to check license availability.'.inspect if Rails.env.development?
56
+ def perform_request
57
+ puts "Performing request to avohq.io API to check license availability.".inspect if Rails.env.development?
57
58
 
58
- HTTParty.post ENDPOINT, body: payload.to_json, headers: { 'Content-type': 'application/json' }, timeout: REQUEST_TIMEOUT
59
- end
59
+ HTTParty.post ENDPOINT, body: payload.to_json, headers: {'Content-type': "application/json"}, timeout: REQUEST_TIMEOUT
60
+ end
60
61
 
61
- def payload
62
- {
63
- license: Avo.configuration.license,
64
- license_key: Avo.configuration.license_key,
65
- avo_version: Avo::VERSION,
66
- rails_version: Rails::VERSION::STRING,
67
- ruby_version: RUBY_VERSION,
68
- environment: Rails.env,
69
- ip: current_request.ip,
70
- host: current_request.host,
71
- port: current_request.port,
72
- }
73
- end
62
+ def payload
63
+ {
64
+ license: Avo.configuration.license,
65
+ license_key: Avo.configuration.license_key,
66
+ avo_version: Avo::VERSION,
67
+ rails_version: Rails::VERSION::STRING,
68
+ ruby_version: RUBY_VERSION,
69
+ environment: Rails.env,
70
+ ip: current_request.ip,
71
+ host: current_request.host,
72
+ port: current_request.port
73
+ }
74
+ end
74
75
 
75
- def cache_and_return_error(error, exception_message = '')
76
- cache_response 5.minutes.to_i, { error: error, exception_message: exception_message }.stringify_keys
77
- end
76
+ def cache_and_return_error(error, exception_message = "")
77
+ cache_response 5.minutes.to_i, {error: error, exception_message: exception_message}.stringify_keys
78
+ end
78
79
 
79
- def has_cached_response
80
- @cache_store.exist? CACHE_KEY
81
- end
80
+ def has_cached_response
81
+ @cache_store.exist? CACHE_KEY
82
+ end
82
83
 
83
- def cached_response
84
- @cache_store.read CACHE_KEY
85
- end
84
+ def cached_response
85
+ @cache_store.read CACHE_KEY
86
+ end
86
87
  end
87
88
  end
88
89
  end
@@ -7,8 +7,8 @@ module Avo
7
7
 
8
8
  def initialize(response)
9
9
  @response = response
10
- @id = response['id']
11
- @valid = response['valid']
10
+ @id = response["id"]
11
+ @valid = response["valid"]
12
12
  end
13
13
 
14
14
  def valid?
@@ -20,15 +20,15 @@ module Avo
20
20
  end
21
21
 
22
22
  def pro?
23
- id == 'pro'
23
+ id == "pro"
24
24
  end
25
25
 
26
26
  def error
27
- @response['error']
27
+ @response["error"]
28
28
  end
29
29
 
30
30
  def properties
31
- @response.slice('valid', 'id', 'error').symbolize_keys
31
+ @response.slice("valid", "id", "error").symbolize_keys
32
32
  end
33
33
 
34
34
  def abilities
@@ -6,12 +6,12 @@ module Avo
6
6
  end
7
7
 
8
8
  def license
9
- return NullLicense.new if Rails.env.test? and ENV['RUN_WITH_NULL_LICENSE'] == '1'
9
+ return NullLicense.new if Rails.env.test? && (ENV["RUN_WITH_NULL_LICENSE"] == "1")
10
10
 
11
- case @hq_response['id']
12
- when 'community'
11
+ case @hq_response["id"]
12
+ when "community"
13
13
  CommunityLicense.new @hq_response
14
- when 'pro'
14
+ when "pro"
15
15
  ProLicense.new @hq_response
16
16
  else
17
17
  NullLicense.new @hq_response
@@ -3,8 +3,8 @@ module Avo
3
3
  class NullLicense < License
4
4
  def initialize(response = nil)
5
5
  response ||= {
6
- id: 'community',
7
- valid: true,
6
+ id: "community",
7
+ valid: true
8
8
  }
9
9
 
10
10
  super(response)
@@ -3,7 +3,7 @@ module Avo
3
3
  class ProLicense < License
4
4
  def abilities
5
5
  [
6
- :authorization,
6
+ :authorization
7
7
  ]
8
8
  end
9
9
  end
@@ -10,13 +10,13 @@ module Avo
10
10
  field[:name].to_s == method.to_s
11
11
  end
12
12
 
13
- if matched_field.present? and matched_field[:class].present?
13
+ if matched_field.present? && matched_field[:class].present?
14
14
  klass = matched_field[:class]
15
15
 
16
- if block.present?
17
- field = klass.new(args[0], **args[1] || {}, &block)
16
+ field = if block.present?
17
+ klass.new(args[0], **args[1] || {}, &block)
18
18
  else
19
- field = klass.new(args[0], **args[1] || {})
19
+ klass.new(args[0], **args[1] || {})
20
20
  end
21
21
 
22
22
  add_field field
@@ -44,7 +44,7 @@ module Avo
44
44
  end
45
45
 
46
46
  true
47
- rescue Pundit::NotDefinedError => error
47
+ rescue Pundit::NotDefinedError
48
48
  false
49
49
  rescue => error
50
50
  if args[:raise_exception] == false
@@ -69,7 +69,7 @@ module Avo
69
69
 
70
70
  begin
71
71
  Pundit.policy_scope! user, model
72
- rescue => exception
72
+ rescue
73
73
  model
74
74
  end
75
75
  end
@@ -11,15 +11,15 @@ module Avo
11
11
  end
12
12
 
13
13
  def default_panel_name
14
- return @request[:via_relation_param].capitalize if @request[:via_relation_param] == 'has_one'
14
+ return @request[:via_relation_param].capitalize if @request[:via_relation_param] == "has_one"
15
15
 
16
16
  case @view
17
17
  when :show
18
- I18n.t('avo.resource_details', item: @resource.name.downcase, title: @resource.model_title).upcase_first
18
+ I18n.t("avo.resource_details", item: @resource.name.downcase, title: @resource.model_title).upcase_first
19
19
  when :edit
20
- I18n.t('avo.update_item', item: @resource.name.downcase, title: @resource.model_title).upcase_first
20
+ I18n.t("avo.update_item", item: @resource.name.downcase, title: @resource.model_title).upcase_first
21
21
  when :new
22
- I18n.t('avo.create_new_item', item: @resource.name.downcase).upcase_first
22
+ I18n.t("avo.create_new_item", item: @resource.name.downcase).upcase_first
23
23
  end
24
24
  end
25
25
  end