avo 1.19.1.pre.2 → 1.19.1.pre.6

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 (206) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -7
  3. data/Gemfile.lock +31 -51
  4. data/README.md +3 -0
  5. data/app/assets/builds/avo.css +8590 -0
  6. data/app/assets/builds/avo.js +87755 -0
  7. data/app/assets/builds/avo.js.map +7 -0
  8. data/app/assets/config/avo_manifest.js +2 -1
  9. data/app/{packs/images → assets/images/avo}/logo.png +0 -0
  10. data/app/{packs/entrypoints/application.css → assets/stylesheets/avo.css} +31 -24
  11. data/app/{packs/stylesheets → assets/stylesheets/css}/active-storage.css +0 -0
  12. data/app/{packs/stylesheets → assets/stylesheets/css}/alerts.css +0 -0
  13. data/app/{packs/stylesheets → assets/stylesheets/css}/breadcrumbs.css +0 -0
  14. data/app/{packs/stylesheets → assets/stylesheets/css}/components/code.css +0 -0
  15. data/app/{packs/stylesheets → assets/stylesheets/css}/components/progress.css +0 -0
  16. data/app/{packs/stylesheets → assets/stylesheets/css}/components/status.css +0 -0
  17. data/app/assets/stylesheets/css/fonts.css +26 -0
  18. data/app/{packs/stylesheets → assets/stylesheets/css}/loader.css +0 -0
  19. data/app/{packs/stylesheets → assets/stylesheets/css}/pagination.css +0 -0
  20. data/app/{packs/stylesheets → assets/stylesheets/css}/search.css +1 -1
  21. data/app/{packs/stylesheets → assets/stylesheets/css}/spinner.css +0 -0
  22. data/app/{packs/stylesheets → assets/stylesheets/css}/tailwindcss/base.css +0 -0
  23. data/app/{packs/stylesheets → assets/stylesheets/css}/tailwindcss/components.css +0 -0
  24. data/app/{packs/stylesheets → assets/stylesheets/css}/tailwindcss/utilities.css +0 -0
  25. data/app/{packs/stylesheets → assets/stylesheets/css}/tooltips.css +0 -0
  26. data/app/{packs/stylesheets → assets/stylesheets/css}/typography.css +0 -0
  27. data/app/{packs → assets}/svgs/arrow-circle-right.svg +0 -0
  28. data/app/{packs → assets}/svgs/arrow-left.svg +0 -0
  29. data/app/{packs → assets}/svgs/avocado.svg +0 -0
  30. data/app/{packs → assets}/svgs/badge-check-sm.svg +0 -0
  31. data/app/{packs → assets}/svgs/check-circle-sm.svg +0 -0
  32. data/app/{packs → assets}/svgs/check-circle.svg +0 -0
  33. data/app/{packs → assets}/svgs/chevron-down.svg +0 -0
  34. data/app/{packs → assets}/svgs/chevron-right.svg +0 -0
  35. data/app/{packs → assets}/svgs/chevron-up.svg +0 -0
  36. data/app/{packs → assets}/svgs/code.svg +0 -0
  37. data/app/{packs → assets}/svgs/color-swatch.svg +0 -0
  38. data/app/{packs → assets}/svgs/document-text.svg +0 -0
  39. data/app/{packs → assets}/svgs/download.svg +0 -0
  40. data/app/{packs → assets}/svgs/edit.svg +0 -0
  41. data/app/{packs → assets}/svgs/exclamation-circle-sm.svg +0 -0
  42. data/app/{packs → assets}/svgs/exclamation-sm.svg +0 -0
  43. data/app/{packs → assets}/svgs/exclamation.svg +0 -0
  44. data/app/{packs → assets}/svgs/eye.svg +0 -0
  45. data/app/{packs → assets}/svgs/filter.svg +0 -0
  46. data/app/{packs → assets}/svgs/fire.svg +0 -0
  47. data/app/{packs → assets}/svgs/game-board.svg +0 -0
  48. data/app/{packs → assets}/svgs/globe.svg +0 -0
  49. data/app/{packs → assets}/svgs/information-circle-sm.svg +0 -0
  50. data/app/{packs → assets}/svgs/information-circle.svg +0 -0
  51. data/app/{packs → assets}/svgs/library.svg +0 -0
  52. data/app/{packs → assets}/svgs/photograph.svg +0 -0
  53. data/app/{packs → assets}/svgs/play.svg +0 -0
  54. data/app/{packs → assets}/svgs/plus-circle.svg +0 -0
  55. data/app/{packs → assets}/svgs/plus.svg +0 -0
  56. data/app/{packs → assets}/svgs/question-mark-circle.svg +0 -0
  57. data/app/{packs → assets}/svgs/save.svg +0 -0
  58. data/app/{packs → assets}/svgs/selector.svg +0 -0
  59. data/app/{packs → assets}/svgs/sort-ascending.svg +0 -0
  60. data/app/{packs → assets}/svgs/sort-descending.svg +0 -0
  61. data/app/{packs → assets}/svgs/switch-horizontal.svg +0 -0
  62. data/app/{packs → assets}/svgs/thumbs-down.svg +0 -0
  63. data/app/{packs → assets}/svgs/thumbs-up.svg +0 -0
  64. data/app/{packs → assets}/svgs/times.svg +0 -0
  65. data/app/{packs → assets}/svgs/trash-sm.svg +0 -0
  66. data/app/{packs → assets}/svgs/trash.svg +0 -0
  67. data/app/{packs → assets}/svgs/view-grid-add.svg +0 -0
  68. data/app/{packs → assets}/svgs/view-grid.svg +0 -0
  69. data/app/{packs → assets}/svgs/view-list.svg +0 -0
  70. data/app/{packs → assets}/svgs/x-circle-sm.svg +0 -0
  71. data/app/{packs → assets}/svgs/x-circle.svg +0 -0
  72. data/app/components/avo/edit/field_wrapper_component.html.erb +1 -1
  73. data/app/components/avo/fields/common/files_list_viewer_component.html.erb +1 -1
  74. data/app/components/avo/fields/common/heading_component.html.erb +1 -1
  75. data/app/components/avo/index/field_wrapper_component.html.erb +1 -1
  76. data/app/components/avo/index/table_row_component.html.erb +1 -1
  77. data/app/components/avo/resource_component.rb +0 -4
  78. data/app/components/avo/show/field_wrapper_component.html.erb +1 -1
  79. data/app/components/avo/views/resource_edit_component.html.erb +1 -1
  80. data/app/components/avo/views/resource_edit_component.rb +6 -0
  81. data/app/components/avo/views/resource_index_component.html.erb +1 -1
  82. data/app/components/avo/views/resource_index_component.rb +21 -9
  83. data/app/components/avo/views/resource_new_component.html.erb +6 -4
  84. data/app/components/avo/views/resource_new_component.rb +6 -0
  85. data/app/components/avo/views/resource_show_component.html.erb +2 -2
  86. data/app/components/avo/views/resource_show_component.rb +9 -1
  87. data/app/controllers/avo/application_controller.rb +1 -1
  88. data/app/controllers/avo/base_controller.rb +39 -9
  89. data/app/helpers/avo/application_helper.rb +4 -16
  90. data/app/{packs/entrypoints/application.js → javascript/avo.js} +15 -18
  91. data/{public/avo-packs/media/images/dadf2db36589607d107d.png → app/javascript/images/logo.png} +0 -0
  92. data/app/{packs → javascript}/js/active-storage.js +0 -0
  93. data/app/javascript/js/application.js +9 -0
  94. data/app/{packs → javascript}/js/controllers/action_controller.js +1 -1
  95. data/app/{packs → javascript}/js/controllers/actions_picker_controller.js +0 -0
  96. data/app/{packs → javascript}/js/controllers/alerts_controller.js +0 -0
  97. data/app/{packs → javascript}/js/controllers/attachments_controller.js +0 -0
  98. data/app/{packs → javascript}/js/controllers/boolean_filter_controller.js +0 -0
  99. data/app/{packs → javascript}/js/controllers/fields/belongs_to_field_controller.js +0 -0
  100. data/app/{packs → javascript}/js/controllers/fields/code_field_controller.js +2 -1
  101. data/app/{packs → javascript}/js/controllers/fields/date_field_controller.js +1 -1
  102. data/app/{packs → javascript}/js/controllers/fields/key_value_controller.js +1 -1
  103. data/app/{packs → javascript}/js/controllers/fields/simple_mde_controller.js +0 -0
  104. data/app/{packs → javascript}/js/controllers/fields/trix_field_controller.js +1 -1
  105. data/app/{packs → javascript}/js/controllers/filter_controller.js +0 -0
  106. data/app/{packs → javascript}/js/controllers/hidden_input_controller.js +0 -0
  107. data/app/{packs → javascript}/js/controllers/item_select_all_controller.js +0 -0
  108. data/app/{packs → javascript}/js/controllers/item_selector_controller.js +0 -0
  109. data/app/{packs → javascript}/js/controllers/loading_button_controller.js +0 -0
  110. data/app/{packs → javascript}/js/controllers/modal_controller.js +0 -0
  111. data/app/{packs → javascript}/js/controllers/multiple_select_filter_controller.js +0 -0
  112. data/app/{packs → javascript}/js/controllers/per_page_controller.js +0 -0
  113. data/app/{packs → javascript}/js/controllers/search_controller.js +1 -1
  114. data/app/{packs → javascript}/js/controllers/select_filter_controller.js +0 -0
  115. data/app/{packs → javascript}/js/controllers/text_filter_controller.js +0 -0
  116. data/app/{packs → javascript}/js/controllers/tippy_controller.js +0 -0
  117. data/app/{packs → javascript}/js/controllers/toggle_panel_controller.js +0 -0
  118. data/app/javascript/js/controllers.js +53 -0
  119. data/app/{packs → javascript}/js/helpers/cast_boolean.js +0 -0
  120. data/app/{packs → javascript}/js/helpers/debounce_promise.js +0 -0
  121. data/app/{packs → javascript}/js/toastr.js +0 -0
  122. data/app/views/avo/actions/show.html.erb +1 -1
  123. data/app/views/avo/base/_actions.html.erb +1 -1
  124. data/app/views/avo/base/_filters.html.erb +3 -3
  125. data/app/views/avo/home/_actions.html.erb +1 -1
  126. data/app/views/avo/home/_filters.html.erb +1 -1
  127. data/app/views/avo/home/_resources.html.erb +2 -2
  128. data/app/views/avo/partials/_footer.html.erb +1 -1
  129. data/app/views/avo/partials/_global_search.html.erb +4 -1
  130. data/app/views/avo/partials/_logo.html.erb +1 -1
  131. data/app/views/avo/partials/_paginator.html.erb +3 -3
  132. data/app/views/avo/partials/_table_header.html.erb +2 -2
  133. data/app/views/layouts/avo/application.html.erb +9 -4
  134. data/avo.gemspec +1 -2
  135. data/bin/dev +9 -0
  136. data/bin/test +2 -1
  137. data/lib/avo/base_resource.rb +4 -3
  138. data/lib/avo/configuration.rb +6 -0
  139. data/lib/avo/engine.rb +2 -16
  140. data/lib/avo/version.rb +1 -1
  141. data/lib/avo.rb +0 -18
  142. data/lib/generators/avo/filter_generator.rb +2 -0
  143. data/lib/generators/avo/templates/filters/text_filter.tt +8 -0
  144. data/public/avo-assets/avo.css +8590 -0
  145. data/public/avo-assets/avo.js +87755 -0
  146. data/public/avo-assets/avo.js.map +7 -0
  147. data/{app/packs → public/avo-assets}/fonts/nunito-v16-latin-700.eot +0 -0
  148. data/{app/packs → public/avo-assets}/fonts/nunito-v16-latin-700.svg +0 -0
  149. data/{app/packs → public/avo-assets}/fonts/nunito-v16-latin-700.ttf +0 -0
  150. data/{app/packs → public/avo-assets}/fonts/nunito-v16-latin-700.woff +0 -0
  151. data/{app/packs → public/avo-assets}/fonts/nunito-v16-latin-700.woff2 +0 -0
  152. data/{app/packs → public/avo-assets}/fonts/nunito-v16-latin-regular.eot +0 -0
  153. data/{app/packs → public/avo-assets}/fonts/nunito-v16-latin-regular.svg +0 -0
  154. data/{app/packs → public/avo-assets}/fonts/nunito-v16-latin-regular.ttf +0 -0
  155. data/{app/packs → public/avo-assets}/fonts/nunito-v16-latin-regular.woff +0 -0
  156. data/{app/packs → public/avo-assets}/fonts/nunito-v16-latin-regular.woff2 +0 -0
  157. metadata +116 -168
  158. data/app/assets/stylesheets/avo/application.css +0 -15
  159. data/app/packs/importmap.json.erb +0 -5
  160. data/app/packs/stylesheets/fonts.css +0 -26
  161. data/bin/webpack +0 -20
  162. data/bin/webpack-dev-server +0 -18
  163. data/config/webpack/aliases.js +0 -10
  164. data/config/webpack/base.js +0 -14
  165. data/config/webpack/development.js +0 -5
  166. data/config/webpack/production.js +0 -5
  167. data/config/webpack/test.js +0 -5
  168. data/config/webpacker.yml +0 -79
  169. data/public/avo-packs/css/application-c3b50b28.css +0 -6329
  170. data/public/avo-packs/css/application-c3b50b28.css.br +0 -0
  171. data/public/avo-packs/css/application-c3b50b28.css.gz +0 -0
  172. data/public/avo-packs/css/application-c3b50b28.css.map +0 -1
  173. data/public/avo-packs/css/application-c3b50b28.css.map.br +0 -0
  174. data/public/avo-packs/css/application-c3b50b28.css.map.gz +0 -0
  175. data/public/avo-packs/js/actioncable-7119dbc1a908641fb263.chunk.js +0 -2
  176. data/public/avo-packs/js/actioncable-7119dbc1a908641fb263.chunk.js.br +0 -0
  177. data/public/avo-packs/js/actioncable-7119dbc1a908641fb263.chunk.js.gz +0 -0
  178. data/public/avo-packs/js/actioncable-7119dbc1a908641fb263.chunk.js.map +0 -1
  179. data/public/avo-packs/js/actioncable-7119dbc1a908641fb263.chunk.js.map.br +0 -0
  180. data/public/avo-packs/js/actioncable-7119dbc1a908641fb263.chunk.js.map.gz +0 -0
  181. data/public/avo-packs/js/application-6fc968cfa52976c4582b.js +0 -26
  182. data/public/avo-packs/js/application-6fc968cfa52976c4582b.js.LICENSE.txt +0 -77
  183. data/public/avo-packs/js/application-6fc968cfa52976c4582b.js.br +0 -0
  184. data/public/avo-packs/js/application-6fc968cfa52976c4582b.js.gz +0 -0
  185. data/public/avo-packs/js/application-6fc968cfa52976c4582b.js.map +0 -1
  186. data/public/avo-packs/js/application-6fc968cfa52976c4582b.js.map.br +0 -0
  187. data/public/avo-packs/js/application-6fc968cfa52976c4582b.js.map.gz +0 -0
  188. data/public/avo-packs/manifest.json +0 -52
  189. data/public/avo-packs/media/images/13ae283c0d7cc04efe7e.svg +0 -380
  190. data/public/avo-packs/media/images/13ae283c0d7cc04efe7e.svg.br +0 -0
  191. data/public/avo-packs/media/images/13ae283c0d7cc04efe7e.svg.gz +0 -0
  192. data/public/avo-packs/media/images/195026a50008c53526ef.svg +0 -388
  193. data/public/avo-packs/media/images/195026a50008c53526ef.svg.br +0 -0
  194. data/public/avo-packs/media/images/195026a50008c53526ef.svg.gz +0 -0
  195. data/public/avo-packs/media/images/1f30e08faa7c60d1f7ac.woff +0 -0
  196. data/public/avo-packs/media/images/1fd17dabf6b7d2b15348.ttf +0 -0
  197. data/public/avo-packs/media/images/1fd17dabf6b7d2b15348.ttf.br +0 -0
  198. data/public/avo-packs/media/images/1fd17dabf6b7d2b15348.ttf.gz +0 -0
  199. data/public/avo-packs/media/images/39a18f443d434999b89b.woff2 +0 -0
  200. data/public/avo-packs/media/images/4ad349571e28bb59c5a5.woff2 +0 -0
  201. data/public/avo-packs/media/images/57a5470848663767abbf.eot +0 -0
  202. data/public/avo-packs/media/images/b2e4cf0fab6c8ca66b7f.ttf +0 -0
  203. data/public/avo-packs/media/images/b2e4cf0fab6c8ca66b7f.ttf.br +0 -0
  204. data/public/avo-packs/media/images/b2e4cf0fab6c8ca66b7f.ttf.gz +0 -0
  205. data/public/avo-packs/media/images/b78d61ab7e046de8c156.eot +0 -0
  206. data/public/avo-packs/media/images/c9ab29becb76ddab01d0.woff +0 -0
@@ -1 +1,2 @@
1
- //= link_directory ../stylesheets/avo .css
1
+ //= link_directory ../images/avo
2
+ //= link_tree ../builds
File without changes
@@ -6,25 +6,26 @@
6
6
  @import './../../../node_modules/flatpickr/dist/flatpickr.css';
7
7
  @import './../../../node_modules/@algolia/autocomplete-theme-classic/dist/theme.css';
8
8
 
9
- @import './../stylesheets/tailwindcss/base.css';
10
-
11
- @import './../stylesheets/fonts.css';
12
- @import './../stylesheets/typography.css';
13
- @import './../stylesheets/tooltips.css';
14
- @import './../stylesheets/alerts.css';
15
- @import './../stylesheets/loader.css';
16
- @import './../stylesheets/pagination.css';
17
- @import './../stylesheets/breadcrumbs.css';
18
- @import './../stylesheets/search.css';
19
- @import './../stylesheets/active-storage.css';
20
- @import './../stylesheets/spinner.css';
21
-
22
- @import './../stylesheets/components/status.css';
23
- @import './../stylesheets/components/code.css';
24
- @import './../stylesheets/components/progress.css';
25
- @import './../stylesheets/tailwindcss/components.css';
26
-
27
- @import './../stylesheets/tailwindcss/utilities.css';
9
+ @import 'tailwindcss/base';
10
+
11
+ @import './css/fonts.css';
12
+ @import './css/typography.css';
13
+ @import './css/tooltips.css';
14
+ @import './css/alerts.css';
15
+ @import './css/loader.css';
16
+ @import './css/pagination.css';
17
+ @import './css/breadcrumbs.css';
18
+ @import './css/search.css';
19
+ @import './css/active-storage.css';
20
+ @import './css/spinner.css';
21
+
22
+ @import './css/components/status.css';
23
+ @import './css/components/code.css';
24
+ @import './css/components/progress.css';
25
+
26
+ @import 'tailwindcss/components';
27
+
28
+ @import 'tailwindcss/utilities';
28
29
 
29
30
  html,
30
31
  body {
@@ -67,13 +68,19 @@ body {
67
68
  @apply opacity-0 translate-y-1;
68
69
  }
69
70
 
70
- .application-sidebar {
71
- .active:hover,
72
- .active {
73
- @apply bg-gray-200;
74
- }
71
+ .application-sidebar .active:hover,
72
+ .application-sidebar .active {
73
+ @apply bg-gray-200;
75
74
  }
76
75
 
77
76
  .turbo-progress-bar {
78
77
  @apply bg-green-500;
79
78
  }
79
+
80
+ body.os-mac .mac\:hidden {
81
+ display: none;
82
+ }
83
+
84
+ body.os-pc .pc\:hidden {
85
+ display: none;
86
+ }
@@ -0,0 +1,26 @@
1
+ /* nunito-regular - latin */
2
+ @font-face {
3
+ font-family: 'Nunito';
4
+ font-style: normal;
5
+ font-weight: 400;
6
+ src: url('/avo-assets/fonts/nunito-v16-latin-regular.eot'); /* IE9 Compat Modes */
7
+ src: local(''),
8
+ url('/avo-assets/fonts/nunito-v16-latin-regular.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
9
+ url('/avo-assets/fonts/nunito-v16-latin-regular.woff2') format('woff2'), /* Super Modern Browsers */
10
+ url('/avo-assets/fonts/nunito-v16-latin-regular.woff') format('woff'), /* Modern Browsers */
11
+ url('/avo-assets/fonts/nunito-v16-latin-regular.ttf') format('truetype'), /* Safari, Android, iOS */
12
+ url('/avo-assets/fonts/nunito-v16-latin-regular.svg#Nunito') format('svg'); /* Legacy iOS */
13
+ }
14
+ /* nunito-700 - latin */
15
+ @font-face {
16
+ font-family: 'Nunito';
17
+ font-style: normal;
18
+ font-weight: 700;
19
+ src: url('/avo-assets/fonts/nunito-v16-latin-700.eot'); /* IE9 Compat Modes */
20
+ src: local(''),
21
+ url('/avo-assets/fonts/nunito-v16-latin-700.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
22
+ url('/avo-assets/fonts/nunito-v16-latin-700.woff2') format('woff2'), /* Super Modern Browsers */
23
+ url('/avo-assets/fonts/nunito-v16-latin-700.woff') format('woff'), /* Modern Browsers */
24
+ url('/avo-assets/fonts/nunito-v16-latin-700.ttf') format('truetype'), /* Safari, Android, iOS */
25
+ url('/avo-assets/fonts/nunito-v16-latin-700.svg#Nunito') format('svg'); /* Legacy iOS */
26
+ }
@@ -27,7 +27,7 @@
27
27
 
28
28
  .aa-DetachedFormContainer,
29
29
  .aa-DetachedContainer .aa-Panel {
30
- @apply bg-blue-gray-100 border-b-0;
30
+ @apply bg-slate-100 border-b-0;
31
31
  }
32
32
 
33
33
  .aa-Form {
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,5 +1,5 @@
1
1
  <div class="flex items-center py-0 leading-tight <%= @classes %> min-h-16" data-field-id="<%= @field.id %>" data-field-type="<%= @field.type %>">
2
- <div class="h-16 flex self-start items-center text-blue-gray-800">
2
+ <div class="h-16 flex self-start items-center text-slate-800">
3
3
  <div class="<% if @displayed_in_modal %> md:w-48 <% else %> md:w-64 <% end %> w-48 px-8 flex" data-slot="label">
4
4
  <%= @form.label @field.id, label %> <% if @field.required %> <span class="text-red-600">*</span> <% end %>
5
5
  </div>
@@ -1,4 +1,4 @@
1
- <div class="relative p-3 bg-blue-gray-200 grid grid-cols-3 xl:grid-cols-4 gap-3 rounded-xl">
1
+ <div class="relative p-3 bg-slate-200 grid grid-cols-3 xl:grid-cols-4 gap-3 rounded-xl">
2
2
  <% @field.value.attachments.each do |file| %>
3
3
  <%= render Avo::Fields::Common::MultipleFileViewerComponent.new id: @field.id, file: file, is_image: @field.is_image, button_size: :xs, resource: @resource %>
4
4
  <% end %>
@@ -1,4 +1,4 @@
1
- <div class="flex items-start py-1 leading-tight border-t bg-blue-gray-600 text-white text-xs">
1
+ <div class="flex items-start py-1 leading-tight border-t bg-slate-600 text-white text-xs">
2
2
  <div class="p-3 pl-6 h-full w-full">
3
3
  <% if @value.present? %>
4
4
  <% if @as_html %>
@@ -1,4 +1,4 @@
1
- <td class="px-4 py-2 leading-tight whitespace-nowrap h-12 text-blue-gray-800 <%= @classes %>" data-field-id="<%= @field.id %>" data-field-type="<%= @field.type %>">
1
+ <td class="px-4 py-2 leading-tight whitespace-nowrap h-12 text-slate-800 <%= @classes %>" data-field-id="<%= @field.id %>" data-field-type="<%= @field.type %>">
2
2
  <% if @field.value.blank? && @dash_if_blank %>
3
3
 
4
4
  <% else %>
@@ -1,5 +1,5 @@
1
1
  <tr
2
- class="hover:bg-light-blue-50 hover:shadow-row relative z-20 border-b"
2
+ class="hover:bg-sky-50 hover:shadow-row relative z-20 border-b"
3
3
  <%== item_selector_init @resource %>
4
4
  >
5
5
  <td class="w-10">
@@ -25,10 +25,6 @@ class Avo::ResourceComponent < ViewComponent::Base
25
25
 
26
26
  private
27
27
 
28
- def simple_relation?
29
- @reflection.is_a? ::ActiveRecord::Reflection::HasManyReflection
30
- end
31
-
32
28
  def relation_resource
33
29
  ::Avo::App.get_resource_by_model_name params[:via_resource_class].safe_constantize
34
30
  end
@@ -1,5 +1,5 @@
1
1
  <div class="flex items-start leading-tight <%= @classes %> min-h-16" data-field-id="<%= @field.id %>" data-field-type="<%= @field.type %>">
2
- <div class="h-16 flex self-start items-center text-blue-gray-800">
2
+ <div class="h-16 flex self-start items-center text-slate-800">
3
3
  <div class="w-48 md:w-64 px-8" data-slot="label">
4
4
  <%= @field.name %> <% if @field.required %> <span class="text-red-600">*</span> <% end %>
5
5
  </div>
@@ -10,7 +10,7 @@
10
10
  <%= helpers.svg 'arrow-left' %> <%= t('avo.cancel').capitalize %>
11
11
  <% end %>
12
12
 
13
- <% if @resource.authorization.authorize_action :update, raise_exception: false %>
13
+ <% if can_see_the_save_button? %>
14
14
  <%= a_button color: 'green', variant: 'outlined', spinner: true, type: :submit do %>
15
15
  <%= helpers.svg 'save' %> <%= t('avo.save').capitalize %>
16
16
  <% end %>
@@ -16,6 +16,12 @@ class Avo::Views::ResourceEditComponent < Avo::ResourceComponent
16
16
  end
17
17
  end
18
18
 
19
+ # The save button is dependent on the edit? policy method.
20
+ # The update? method should be called only when the user clicks the Save button so the developer gets access to the params from the form.
21
+ def can_see_the_save_button?
22
+ @resource.authorization.authorize_action :edit, raise_exception: false
23
+ end
24
+
19
25
  private
20
26
 
21
27
  def via_resource?
@@ -3,7 +3,7 @@
3
3
  <% c.tools do %>
4
4
  <%= render 'actions' if @actions.present? %>
5
5
 
6
- <% if can_create? %>
6
+ <% if can_see_the_create_button? %>
7
7
  <%= a_link create_path do %>
8
8
  <%= svg 'plus' %> <%= t('avo.create_new_item', item: singular_resource_name.downcase ) %>
9
9
  <% end %>
@@ -44,8 +44,10 @@ class Avo::Views::ResourceIndexComponent < Avo::ResourceComponent
44
44
  @index_params[:available_view_types]
45
45
  end
46
46
 
47
- def can_create?
48
- @resource.authorization.authorize_action(:create, raise_exception: false) && simple_relation? && !has_reflection_and_is_read_only
47
+ # The Create button is dependent on the new? policy method.
48
+ # The create? should be called only when the user clicks the Save button so the developers gets access to the params from the form.
49
+ def can_see_the_create_button?
50
+ @resource.authorization.authorize_action(:new, raise_exception: false) && !has_reflection_and_is_read_only
49
51
  end
50
52
 
51
53
  def can_attach?
@@ -58,7 +60,7 @@ class Avo::Views::ResourceIndexComponent < Avo::ResourceComponent
58
60
  def has_reflection_and_is_read_only
59
61
  if @reflection.present? && @reflection.active_record.name && @reflection.name
60
62
  fields = ::Avo::App.get_resource_by_model_name(@reflection.active_record.name).get_field_definitions
61
- filtered_fields = fields.filter{ |f| f.id == @reflection.name}
63
+ filtered_fields = fields.filter { |f| f.id == @reflection.name }
62
64
  else
63
65
  return false
64
66
  end
@@ -75,10 +77,22 @@ class Avo::Views::ResourceIndexComponent < Avo::ResourceComponent
75
77
 
76
78
  if @reflection.present?
77
79
  args = {
78
- via_relation_class: @parent_model.model_name,
79
- via_resource_id: @parent_model.id
80
+ via_relation_class: reflection_model_class,
81
+ via_resource_id: @parent_model.id,
80
82
  }
81
83
 
84
+ if @reflection.is_a? ActiveRecord::Reflection::ThroughReflection
85
+ args[:via_relation] = params[:resource_name]
86
+ end
87
+
88
+ if @reflection.is_a? ActiveRecord::Reflection::HasManyReflection
89
+ args[:via_relation] = @reflection.name
90
+ end
91
+
92
+ if @reflection.parent_reflection.present? && @reflection.parent_reflection.inverse_of.present?
93
+ args[:via_relation] = @reflection.parent_reflection.inverse_of.name
94
+ end
95
+
82
96
  if @reflection.inverse_of.present?
83
97
  args[:via_relation] = @reflection.inverse_of.name
84
98
  end
@@ -101,9 +115,7 @@ class Avo::Views::ResourceIndexComponent < Avo::ResourceComponent
101
115
 
102
116
  private
103
117
 
104
- def simple_relation?
105
- return @reflection.is_a? ::ActiveRecord::Reflection::HasManyReflection if @reflection.present?
106
-
107
- true
118
+ def reflection_model_class
119
+ @reflection.active_record.to_s
108
120
  end
109
121
  end
@@ -1,6 +1,6 @@
1
1
  <div>
2
2
  <% @resource.panels.each do |resource_panel| %>
3
- <%= form_with model: @resource.model, url: helpers.resources_path(resource: @resource, via_relation_class: params[:via_relation_class], via_resource_id: params[:via_resource_id]), local: true, multipart: true do |form| %>
3
+ <%= form_with model: @resource.model, url: helpers.resources_path(resource: @resource, via_relation_class: params[:via_relation_class], via_relation: params[:via_relation], via_resource_id: params[:via_resource_id]), local: true, multipart: true do |form| %>
4
4
  <%= render Avo::PanelComponent.new(title: resource_panel[:name], display_breadcrumbs: true) do |c| %>
5
5
  <% c.tools do %>
6
6
  <div class="flex justify-end space-x-2">
@@ -8,9 +8,11 @@
8
8
  <%= svg 'arrow-left' %> <%= t('avo.cancel').capitalize %>
9
9
  <% end %>
10
10
 
11
- <%= a_button color: 'green', spinner: true, type: :submit do %>
12
- <%= svg 'save' %> <%= t('avo.save').capitalize %>
13
- <% end if @resource.authorization.authorize_action :create, raise_exception: false %>
11
+ <% if can_see_the_save_button? %>
12
+ <%= a_button color: 'green', spinner: true, type: :submit do %>
13
+ <%= svg 'save' %> <%= t('avo.save').capitalize %>
14
+ <% end %>
15
+ <% end %>
14
16
  </div>
15
17
  <% end %>
16
18
 
@@ -20,6 +20,12 @@ class Avo::Views::ResourceNewComponent < ViewComponent::Base
20
20
  end
21
21
  end
22
22
 
23
+ # The create button is dependent on the new? policy method.
24
+ # The create? should be called only when the user clicks the Save button so the developers gets access to the params from the form.
25
+ def can_see_the_save_button?
26
+ @resource.authorization.authorize_action :new, raise_exception: false
27
+ end
28
+
23
29
  private
24
30
 
25
31
  def via_resource?
@@ -14,7 +14,7 @@
14
14
  <%= svg 'trash' %> <%= t('avo.detach_item', item: @reflection.name.to_s).capitalize %>
15
15
  <% end %>
16
16
  <% end %>
17
- <% if @resource.authorization.authorize_action(:edit, raise_exception: false) %>
17
+ <% if can_see_the_edit_button? %>
18
18
  <%= a_link edit_path, color: 'indigo' do %>
19
19
  <%= svg 'edit' %> <%= t('avo.edit').capitalize %>
20
20
  <% end %>
@@ -24,7 +24,7 @@
24
24
  <%= svg 'arrow-left' %> <%= t('avo.go_back') %>
25
25
  <% end %>
26
26
 
27
- <% if @resource.authorization.authorize_action(:destroy, raise_exception: false) %>
27
+ <% if can_see_the_destroy_button? %>
28
28
  <%= form_with url: helpers.resource_path(model: @resource.model, resource: @resource), method: :delete, html: { 'data-turbo-frame': params[:turbo_frame] } do |form| %>
29
29
  <%= a_button title: t('avo.delete_item', item: @resource.model.model_name.name.downcase).capitalize,
30
30
  spinner: true,
@@ -43,7 +43,15 @@ class Avo::Views::ResourceShowComponent < Avo::ResourceComponent
43
43
  end
44
44
 
45
45
  def can_detach?
46
- authorize_association_for('detach')
46
+ authorize_association_for("detach")
47
+ end
48
+
49
+ def can_see_the_edit_button?
50
+ @resource.authorization.authorize_action(:edit, raise_exception: false)
51
+ end
52
+
53
+ def can_see_the_destroy_button?
54
+ @resource.authorization.authorize_action(:destroy, raise_exception: false)
47
55
  end
48
56
 
49
57
  private
@@ -102,7 +102,7 @@ module Avo
102
102
  end
103
103
 
104
104
  def set_view
105
- @view = params[:action].to_sym
105
+ @view = action_name.to_sym
106
106
  end
107
107
 
108
108
  def set_model_to_fill
@@ -7,7 +7,6 @@ module Avo
7
7
  before_action :hydrate_resource
8
8
  before_action :set_model, only: [:show, :edit, :destroy, :update]
9
9
  before_action :set_model_to_fill
10
- before_action :fill_model, only: [:create, :update]
11
10
  before_action :authorize_action
12
11
  before_action :reset_pagination_if_filters_changed, only: :index
13
12
  before_action :cache_applied_filters, only: :index
@@ -25,8 +24,8 @@ module Avo
25
24
  @query = @resource.class.query_scope
26
25
  end
27
26
 
28
- # Remove default_scope for index view
29
- if @resource.unscoped_queries_on_index
27
+ # Remove default_scope for index view if no parent_resource present
28
+ if @resource.unscoped_queries_on_index && @parent_resource.blank?
30
29
  @query = @query.unscoped
31
30
  end
32
31
 
@@ -112,17 +111,47 @@ module Avo
112
111
  end
113
112
 
114
113
  def create
115
- # model gets instantiated and filled in the fill_model before_action
114
+ # model gets instantiated and filled in the fill_model method
115
+ fill_model
116
116
  saved = @model.save
117
117
  @resource.hydrate(model: @model, view: :new, user: _current_user)
118
118
 
119
+ # This means that the record has been created through another parent record and we need to attach it somehow.
120
+ if params[:via_resource_id].present?
121
+ @reflection = @model._reflections[params[:via_relation]]
122
+ # Figure out what kind of association does the record have with the parent record
123
+
124
+ # belongs_to
125
+ # has_many
126
+ # Get the foreign key and set it to the id we received in the params
127
+ if @reflection.is_a?(ActiveRecord::Reflection::BelongsToReflection) || @reflection.is_a?(ActiveRecord::Reflection::HasManyReflection)
128
+ foreign_key = @reflection.foreign_key
129
+ @model.send("#{foreign_key}=", params[:via_resource_id])
130
+ @model.save
131
+ end
132
+
133
+ # has_one
134
+ # has_one_through
135
+
136
+ # has_many_through
137
+ # has_and_belongs_to_many
138
+ # polymorphic
139
+ if @reflection.is_a? ActiveRecord::Reflection::ThroughReflection
140
+ # find the record
141
+ via_resource = ::Avo::App.get_resource_by_model_name params[:via_relation_class]
142
+ @related_record = via_resource.model_class.find params[:via_resource_id]
143
+
144
+ @model.send(params[:via_relation]) << @related_record
145
+ end
146
+ end
147
+
119
148
  respond_to do |format|
120
149
  if saved
121
- redirect_path = if params[:via_relation_class].present? && params[:via_resource_id].present?
150
+ redirect_path = resource_path(model: @model, resource: @resource)
151
+
152
+ if params[:via_relation_class].present? && params[:via_resource_id].present?
122
153
  parent_resource = ::Avo::App.get_resource_by_model_name params[:via_relation_class].safe_constantize
123
- resource_path(model: params[:via_relation_class].safe_constantize, resource: parent_resource, resource_id: params[:via_resource_id])
124
- else
125
- resource_path(model: @model, resource: @resource)
154
+ redirect_path = resource_path(model: params[:via_relation_class].safe_constantize, resource: parent_resource, resource_id: params[:via_resource_id])
126
155
  end
127
156
 
128
157
  format.html { redirect_to redirect_path, notice: "#{@model.class.name} #{t("avo.was_successfully_created")}." }
@@ -136,7 +165,8 @@ module Avo
136
165
  end
137
166
 
138
167
  def update
139
- # model gets instantiated and filled in the fill_model before_action
168
+ # model gets instantiated and filled in the fill_model method
169
+ fill_model
140
170
  saved = @model.save
141
171
  @resource = @resource.hydrate(model: @model, view: :edit, user: _current_user)
142
172