avo 2.9.2.pre1 → 2.10.3.pre.1

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 (141) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +69 -69
  3. data/README.md +4 -0
  4. data/app/assets/stylesheets/css/buttons.css +4 -1
  5. data/app/components/avo/actions_component.rb +6 -2
  6. data/app/components/avo/base_component.rb +2 -0
  7. data/app/components/avo/button_component.rb +3 -1
  8. data/app/components/avo/fields/common/key_value_component.html.erb +2 -2
  9. data/app/components/avo/fields/common/single_file_viewer_component.rb +1 -1
  10. data/app/components/avo/fields/country_field/edit_component.html.erb +9 -3
  11. data/app/components/avo/fields/date_field/edit_component.html.erb +26 -7
  12. data/app/components/avo/fields/date_field/index_component.html.erb +7 -1
  13. data/app/components/avo/fields/date_field/show_component.html.erb +7 -1
  14. data/app/components/avo/fields/date_time_field/edit_component.html.erb +1 -0
  15. data/app/components/avo/fields/edit_component.rb +5 -0
  16. data/app/components/avo/fields/file_field/edit_component.html.erb +1 -0
  17. data/app/components/avo/fields/files_field/edit_component.html.erb +1 -0
  18. data/app/components/avo/fields/select_field/edit_component.html.erb +14 -10
  19. data/app/components/avo/fields/show_component.rb +1 -1
  20. data/app/components/avo/index/ordering/button_component.rb +1 -15
  21. data/app/components/avo/index/resource_controls_component.html.erb +2 -2
  22. data/app/components/avo/index/resource_controls_component.rb +5 -1
  23. data/app/components/avo/index/resource_table_component.html.erb +1 -1
  24. data/app/components/avo/index/table_row_component.html.erb +1 -1
  25. data/app/components/avo/item_switcher_component.html.erb +19 -0
  26. data/app/components/avo/item_switcher_component.rb +45 -0
  27. data/app/components/avo/panel_component.html.erb +23 -24
  28. data/app/components/avo/panel_component.rb +8 -5
  29. data/app/components/avo/tab_group_component.html.erb +53 -0
  30. data/app/components/avo/tab_group_component.rb +51 -0
  31. data/app/components/avo/tab_switcher_component.html.erb +21 -0
  32. data/app/components/avo/tab_switcher_component.rb +86 -0
  33. data/app/components/avo/views/resource_edit_component.html.erb +34 -56
  34. data/app/components/avo/views/resource_edit_component.rb +11 -1
  35. data/app/components/avo/views/resource_index_component.html.erb +2 -2
  36. data/app/components/avo/views/resource_index_component.rb +3 -3
  37. data/app/components/avo/views/resource_show_component.html.erb +58 -89
  38. data/app/components/avo/views/resource_show_component.rb +2 -2
  39. data/app/controllers/avo/actions_controller.rb +1 -1
  40. data/app/controllers/avo/application_controller.rb +33 -10
  41. data/app/controllers/avo/base_controller.rb +11 -3
  42. data/app/controllers/avo/reorder_controller.rb +25 -0
  43. data/app/helpers/avo/application_helper.rb +6 -6
  44. data/app/helpers/avo/url_helpers.rb +1 -5
  45. data/app/javascript/avo.js +5 -1
  46. data/app/javascript/js/controllers/fields/date_field_controller.js +15 -3
  47. data/app/javascript/js/controllers/loading_button_controller.js +25 -21
  48. data/app/javascript/js/controllers/search_controller.js +3 -0
  49. data/app/javascript/js/controllers/tabs_controller.js +86 -0
  50. data/app/javascript/js/controllers.js +2 -0
  51. data/app/views/avo/base/index.html.erb +1 -1
  52. data/app/views/avo/base/show.html.erb +1 -1
  53. data/app/views/avo/cards/show.html.erb +1 -1
  54. data/app/views/avo/debug/index.html.erb +1 -1
  55. data/app/views/avo/home/_actions.html.erb +1 -1
  56. data/app/views/avo/home/_dashboards.html.erb +19 -0
  57. data/app/views/avo/home/_filters.html.erb +1 -1
  58. data/app/views/avo/home/_resources.html.erb +1 -1
  59. data/app/views/avo/home/failed_to_load.html.erb +1 -1
  60. data/app/views/avo/home/index.html.erb +14 -2
  61. data/app/views/avo/partials/_javascript.html.erb +1 -1
  62. data/app/views/avo/partials/_tabs_toggle.html.erb +20 -0
  63. data/app/views/avo/private/design.html.erb +1 -1
  64. data/config/routes.rb +5 -4
  65. data/db/factories.rb +1 -0
  66. data/lib/avo/app.rb +12 -7
  67. data/lib/avo/base_action.rb +2 -19
  68. data/lib/avo/base_card.rb +1 -7
  69. data/lib/avo/base_resource.rb +6 -98
  70. data/lib/avo/base_resource_tool.rb +3 -1
  71. data/lib/avo/concerns/has_fields.rb +249 -50
  72. data/lib/avo/concerns/has_html_attributes.rb +1 -1
  73. data/lib/avo/concerns/is_resource_item.rb +36 -0
  74. data/lib/avo/concerns/model_class_constantized.rb +23 -0
  75. data/lib/avo/configuration.rb +2 -12
  76. data/lib/avo/dashboards/base_dashboard.rb +1 -1
  77. data/lib/avo/dsl/field_parser.rb +83 -0
  78. data/lib/avo/fields/base_field.rb +21 -2
  79. data/lib/avo/fields/country_field.rb +2 -0
  80. data/lib/avo/fields/date_field.rb +13 -9
  81. data/lib/avo/fields/field_extensions/has_include_blank.rb +17 -0
  82. data/lib/avo/fields/field_extensions/visible_in_different_views.rb +18 -1
  83. data/lib/avo/fields/file_field.rb +2 -0
  84. data/lib/avo/fields/files_field.rb +2 -0
  85. data/lib/avo/fields/has_base_field.rb +20 -1
  86. data/lib/avo/fields/has_one_field.rb +4 -1
  87. data/lib/avo/fields/key_value_field.rb +4 -4
  88. data/lib/avo/fields/select_field.rb +2 -0
  89. data/lib/avo/grid_collector.rb +6 -3
  90. data/lib/avo/items_holder.rb +68 -0
  91. data/lib/avo/licensing/h_q.rb +12 -0
  92. data/lib/avo/main_panel.rb +3 -0
  93. data/lib/avo/menu/builder.rb +8 -7
  94. data/lib/avo/panel.rb +25 -0
  95. data/lib/avo/panel_builder.rb +23 -0
  96. data/lib/avo/services/uri_service.rb +75 -0
  97. data/lib/avo/tab.rb +78 -0
  98. data/lib/avo/tab_builder.rb +25 -0
  99. data/lib/avo/tab_group.rb +40 -0
  100. data/lib/avo/tab_group_builder.rb +43 -0
  101. data/lib/avo/version.rb +1 -1
  102. data/lib/avo.rb +1 -0
  103. data/lib/generators/avo/action_generator.rb +3 -2
  104. data/lib/generators/avo/base_generator.rb +14 -0
  105. data/lib/generators/avo/card/chartkick_generator.rb +18 -0
  106. data/lib/generators/avo/card/metric_generator.rb +18 -0
  107. data/lib/generators/avo/card/partial_generator.rb +19 -0
  108. data/lib/generators/avo/controller_generator.rb +9 -3
  109. data/lib/generators/avo/dashboard_generator.rb +2 -2
  110. data/lib/generators/avo/eject_generator.rb +2 -3
  111. data/lib/generators/avo/field_generator.rb +2 -2
  112. data/lib/generators/avo/filter_generator.rb +3 -2
  113. data/lib/generators/avo/install_generator.rb +2 -2
  114. data/lib/generators/avo/locales_generator.rb +2 -2
  115. data/lib/generators/avo/named_base_generator.rb +14 -0
  116. data/lib/generators/avo/resource_generator.rb +2 -2
  117. data/lib/generators/avo/resource_tool_generator.rb +4 -4
  118. data/lib/generators/avo/templates/locales/avo.fr.yml +115 -0
  119. data/lib/generators/avo/templates/resource/controller.tt +2 -0
  120. data/lib/generators/avo/templates/resource_tools/partial.tt +1 -1
  121. data/lib/generators/avo/templates/tool/view.tt +1 -1
  122. data/lib/generators/avo/tool_generator.rb +4 -4
  123. data/lib/generators/avo/version_generator.rb +23 -0
  124. data/public/avo-assets/avo.css +31 -3
  125. data/public/avo-assets/avo.js +72 -72
  126. data/public/avo-assets/avo.js.map +3 -3
  127. metadata +32 -16
  128. data/app/assets/builds/action_cable.js +0 -2
  129. data/app/assets/builds/action_cable.js.map +0 -7
  130. data/app/assets/builds/application.js +0 -2
  131. data/app/assets/builds/application.js.map +0 -7
  132. data/app/assets/builds/avo.css +0 -9028
  133. data/app/assets/builds/avo.js +0 -512
  134. data/app/assets/builds/avo.js.map +0 -7
  135. data/app/assets/builds/avo_custom.js +0 -6
  136. data/app/assets/builds/avo_custom.js.map +0 -7
  137. data/lib/avo/concerns/has_tools.rb +0 -47
  138. data/lib/avo/fields/currency_field.rb +0 -15
  139. data/lib/generators/avo/chartkick_card_generator.rb +0 -16
  140. data/lib/generators/avo/metric_card_generator.rb +0 -16
  141. data/lib/generators/avo/partial_card_generator.rb +0 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ec2fea3d7eaa7759c9864553df3ed3e2375691e8e77616526a3bdf24a9b7c095
4
- data.tar.gz: f958e3660b85e7f55352ca3680b1cbc6db6f5241a4b67335cc734c32f042c4b6
3
+ metadata.gz: eaf0eb69447308c9c5124d557cacfcc5fce7ad1ee307980ea1601671e861346b
4
+ data.tar.gz: 1e1b14789776d3d3382fca548f8ab1f18d05996ce39fce98091a75723e3b9dd0
5
5
  SHA512:
6
- metadata.gz: 184f093da1d7adec6414db22ca03f8222103768c35c382c3c0806311665094e02f0573889769f42ff100e3eb82a0f1e3d43a77fd10ad6c22d5357c6ec1a4fdbf
7
- data.tar.gz: 03b309a8cff875d3aa1459a51d1196881ac03eae9935b3a4edf152125216bacbfbc0d468afdeb0e1f4da7998adcb468c0639615e396b4f5554e1f597b6f67ee2
6
+ metadata.gz: 7c42723dfef266320c8b26820c3e9d4670b2c7ce1dccfc49f808cd035d751711479753bb441d15e7b62190b3550d9ea8d435dfe47289c0a8aaa431de37127bc4
7
+ data.tar.gz: 8ea62dec974fc99d1f75f4e38a168738be810e118d99526f3cc166b9a12c1c13a8cfa33310fa6af24be32a838cb4e7cbd6f42c10108b76956a2b268525210992
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- avo (2.9.2.pre1)
4
+ avo (2.10.3.pre.1)
5
5
  active_link_to
6
6
  addressable
7
7
  breadcrumbs_on_rails
@@ -22,40 +22,40 @@ PATH
22
22
  GEM
23
23
  remote: https://rubygems.org/
24
24
  specs:
25
- actioncable (6.1.4.6)
26
- actionpack (= 6.1.4.6)
27
- activesupport (= 6.1.4.6)
25
+ actioncable (6.1.6.1)
26
+ actionpack (= 6.1.6.1)
27
+ activesupport (= 6.1.6.1)
28
28
  nio4r (~> 2.0)
29
29
  websocket-driver (>= 0.6.1)
30
- actionmailbox (6.1.4.6)
31
- actionpack (= 6.1.4.6)
32
- activejob (= 6.1.4.6)
33
- activerecord (= 6.1.4.6)
34
- activestorage (= 6.1.4.6)
35
- activesupport (= 6.1.4.6)
30
+ actionmailbox (6.1.6.1)
31
+ actionpack (= 6.1.6.1)
32
+ activejob (= 6.1.6.1)
33
+ activerecord (= 6.1.6.1)
34
+ activestorage (= 6.1.6.1)
35
+ activesupport (= 6.1.6.1)
36
36
  mail (>= 2.7.1)
37
- actionmailer (6.1.4.6)
38
- actionpack (= 6.1.4.6)
39
- actionview (= 6.1.4.6)
40
- activejob (= 6.1.4.6)
41
- activesupport (= 6.1.4.6)
37
+ actionmailer (6.1.6.1)
38
+ actionpack (= 6.1.6.1)
39
+ actionview (= 6.1.6.1)
40
+ activejob (= 6.1.6.1)
41
+ activesupport (= 6.1.6.1)
42
42
  mail (~> 2.5, >= 2.5.4)
43
43
  rails-dom-testing (~> 2.0)
44
- actionpack (6.1.4.6)
45
- actionview (= 6.1.4.6)
46
- activesupport (= 6.1.4.6)
44
+ actionpack (6.1.6.1)
45
+ actionview (= 6.1.6.1)
46
+ activesupport (= 6.1.6.1)
47
47
  rack (~> 2.0, >= 2.0.9)
48
48
  rack-test (>= 0.6.3)
49
49
  rails-dom-testing (~> 2.0)
50
50
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
51
- actiontext (6.1.4.6)
52
- actionpack (= 6.1.4.6)
53
- activerecord (= 6.1.4.6)
54
- activestorage (= 6.1.4.6)
55
- activesupport (= 6.1.4.6)
51
+ actiontext (6.1.6.1)
52
+ actionpack (= 6.1.6.1)
53
+ activerecord (= 6.1.6.1)
54
+ activestorage (= 6.1.6.1)
55
+ activesupport (= 6.1.6.1)
56
56
  nokogiri (>= 1.8.5)
57
- actionview (6.1.4.6)
58
- activesupport (= 6.1.4.6)
57
+ actionview (6.1.6.1)
58
+ activesupport (= 6.1.6.1)
59
59
  builder (~> 3.1)
60
60
  erubi (~> 1.4)
61
61
  rails-dom-testing (~> 2.0)
@@ -65,22 +65,22 @@ GEM
65
65
  addressable
66
66
  active_median (0.3.3)
67
67
  activesupport (>= 5.2)
68
- activejob (6.1.4.6)
69
- activesupport (= 6.1.4.6)
68
+ activejob (6.1.6.1)
69
+ activesupport (= 6.1.6.1)
70
70
  globalid (>= 0.3.6)
71
- activemodel (6.1.4.6)
72
- activesupport (= 6.1.4.6)
73
- activerecord (6.1.4.6)
74
- activemodel (= 6.1.4.6)
75
- activesupport (= 6.1.4.6)
76
- activestorage (6.1.4.6)
77
- actionpack (= 6.1.4.6)
78
- activejob (= 6.1.4.6)
79
- activerecord (= 6.1.4.6)
80
- activesupport (= 6.1.4.6)
81
- marcel (~> 1.0.0)
71
+ activemodel (6.1.6.1)
72
+ activesupport (= 6.1.6.1)
73
+ activerecord (6.1.6.1)
74
+ activemodel (= 6.1.6.1)
75
+ activesupport (= 6.1.6.1)
76
+ activestorage (6.1.6.1)
77
+ actionpack (= 6.1.6.1)
78
+ activejob (= 6.1.6.1)
79
+ activerecord (= 6.1.6.1)
80
+ activesupport (= 6.1.6.1)
81
+ marcel (~> 1.0)
82
82
  mini_mime (>= 1.1.0)
83
- activesupport (6.1.4.6)
83
+ activesupport (6.1.6.1)
84
84
  concurrent-ruby (~> 1.0, >= 1.0.2)
85
85
  i18n (>= 1.6, < 2)
86
86
  minitest (>= 5.1)
@@ -138,7 +138,7 @@ GEM
138
138
  xpath (~> 3.2)
139
139
  chartkick (4.2.0)
140
140
  childprocess (4.1.0)
141
- concurrent-ruby (1.1.9)
141
+ concurrent-ruby (1.1.10)
142
142
  countries (4.2.1)
143
143
  i18n_data (~> 0.15.0)
144
144
  sixarm_ruby_unaccent (~> 1.1)
@@ -201,7 +201,7 @@ GEM
201
201
  httparty (0.20.0)
202
202
  mime-types (~> 3.0)
203
203
  multi_xml (>= 0.5.2)
204
- i18n (1.10.0)
204
+ i18n (1.11.0)
205
205
  concurrent-ruby (~> 1.0)
206
206
  i18n_data (0.15.0)
207
207
  simple_po_parser (~> 1.1)
@@ -219,7 +219,7 @@ GEM
219
219
  listen (3.7.1)
220
220
  rb-fsevent (~> 0.10, >= 0.10.3)
221
221
  rb-inotify (~> 0.9, >= 0.9.10)
222
- loofah (2.14.0)
222
+ loofah (2.18.0)
223
223
  crass (~> 1.0.2)
224
224
  nokogiri (>= 1.5.9)
225
225
  mail (2.7.1)
@@ -238,7 +238,7 @@ GEM
238
238
  mini_magick (4.11.0)
239
239
  mini_mime (1.1.2)
240
240
  mini_portile2 (2.8.0)
241
- minitest (5.15.0)
241
+ minitest (5.16.2)
242
242
  msgpack (1.4.4)
243
243
  multi_xml (0.6.0)
244
244
  net-protocol (0.1.2)
@@ -249,10 +249,10 @@ GEM
249
249
  net-protocol
250
250
  timeout
251
251
  nio4r (2.5.8)
252
- nokogiri (1.13.4)
252
+ nokogiri (1.13.7)
253
253
  mini_portile2 (~> 2.8.0)
254
254
  racc (~> 1.4)
255
- nokogiri (1.13.4-x86_64-linux)
255
+ nokogiri (1.13.7-x86_64-linux)
256
256
  racc (~> 1.4)
257
257
  orm_adapter (0.5.0)
258
258
  pagy (5.10.1)
@@ -267,23 +267,23 @@ GEM
267
267
  pundit (2.2.0)
268
268
  activesupport (>= 3.0.0)
269
269
  racc (1.6.0)
270
- rack (2.2.3.1)
271
- rack-test (1.1.0)
272
- rack (>= 1.0, < 3)
273
- rails (6.1.4.6)
274
- actioncable (= 6.1.4.6)
275
- actionmailbox (= 6.1.4.6)
276
- actionmailer (= 6.1.4.6)
277
- actionpack (= 6.1.4.6)
278
- actiontext (= 6.1.4.6)
279
- actionview (= 6.1.4.6)
280
- activejob (= 6.1.4.6)
281
- activemodel (= 6.1.4.6)
282
- activerecord (= 6.1.4.6)
283
- activestorage (= 6.1.4.6)
284
- activesupport (= 6.1.4.6)
270
+ rack (2.2.4)
271
+ rack-test (2.0.2)
272
+ rack (>= 1.3)
273
+ rails (6.1.6.1)
274
+ actioncable (= 6.1.6.1)
275
+ actionmailbox (= 6.1.6.1)
276
+ actionmailer (= 6.1.6.1)
277
+ actionpack (= 6.1.6.1)
278
+ actiontext (= 6.1.6.1)
279
+ actionview (= 6.1.6.1)
280
+ activejob (= 6.1.6.1)
281
+ activemodel (= 6.1.6.1)
282
+ activerecord (= 6.1.6.1)
283
+ activestorage (= 6.1.6.1)
284
+ activesupport (= 6.1.6.1)
285
285
  bundler (>= 1.15.0)
286
- railties (= 6.1.4.6)
286
+ railties (= 6.1.6.1)
287
287
  sprockets-rails (>= 2.0.0)
288
288
  rails-controller-testing (1.0.5)
289
289
  actionpack (>= 5.0.1.rc1)
@@ -292,13 +292,13 @@ GEM
292
292
  rails-dom-testing (2.0.3)
293
293
  activesupport (>= 4.2.0)
294
294
  nokogiri (>= 1.6)
295
- rails-html-sanitizer (1.4.2)
295
+ rails-html-sanitizer (1.4.3)
296
296
  loofah (~> 2.3)
297
- railties (6.1.4.6)
298
- actionpack (= 6.1.4.6)
299
- activesupport (= 6.1.4.6)
297
+ railties (6.1.6.1)
298
+ actionpack (= 6.1.6.1)
299
+ activesupport (= 6.1.6.1)
300
300
  method_source
301
- rake (>= 0.13)
301
+ rake (>= 12.2)
302
302
  thor (~> 1.0)
303
303
  rainbow (3.1.1)
304
304
  rake (13.0.6)
@@ -372,7 +372,7 @@ GEM
372
372
  spring (4.0.0)
373
373
  spring-commands-rspec (1.0.4)
374
374
  spring (>= 0.9.1)
375
- sprockets (4.0.2)
375
+ sprockets (4.1.1)
376
376
  concurrent-ruby (~> 1.0)
377
377
  rack (> 1, < 3)
378
378
  sprockets-rails (3.4.2)
@@ -393,7 +393,7 @@ GEM
393
393
  tzinfo (2.0.4)
394
394
  concurrent-ruby (~> 1.0)
395
395
  unicode-display_width (2.1.0)
396
- view_component (2.49.1)
396
+ view_component (2.57.1)
397
397
  activesupport (>= 5.0.0, < 8.0)
398
398
  method_source (~> 1.0)
399
399
  warden (1.2.9)
@@ -416,7 +416,7 @@ GEM
416
416
  websocket-extensions (0.1.5)
417
417
  xpath (3.2.0)
418
418
  nokogiri (~> 1.8)
419
- zeitwerk (2.5.4)
419
+ zeitwerk (2.6.0)
420
420
 
421
421
  PLATFORMS
422
422
  ruby
data/README.md CHANGED
@@ -69,6 +69,10 @@ Please read [CONTRIBUTING.MD](./CONTRIBUTING.MD)
69
69
 
70
70
  Please read the [UPGRADE_GUIDE.MD](https://docs.avohq.io/2.0/upgrade.html)
71
71
 
72
+ # Release schedule
73
+
74
+ Please read the [RELEASE.MD](./RELEASE.MD)
75
+
72
76
  # ✨ Contributors
73
77
 
74
78
  <a href="https://github.com/avo-hq/avo/graphs/contributors">
@@ -1,8 +1,11 @@
1
1
  .button-group {
2
2
  @apply flex;
3
+
3
4
  .button-component {
5
+ @apply -mr-px;
6
+
4
7
  &:first-child {
5
- @apply rounded-l -mr-px;
8
+ @apply rounded-l;
6
9
  }
7
10
 
8
11
  &:last-child {
@@ -43,10 +43,14 @@ class Avo::ActionsComponent < ViewComponent::Base
43
43
  end
44
44
 
45
45
  def single_record_path(id)
46
- "#{@resource.record_path}/actions/#{id}"
46
+ Avo::Services::URIService.parse(@resource.record_path)
47
+ .append_paths("actions", id)
48
+ .to_s
47
49
  end
48
50
 
49
51
  def many_records_path(id)
50
- "#{@resource.records_path}/actions/#{id}"
52
+ Avo::Services::URIService.parse(@resource.records_path)
53
+ .append_paths("actions", id)
54
+ .to_s
51
55
  end
52
56
  end
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Avo::BaseComponent < ViewComponent::Base
4
+ include Turbo::FramesHelper
5
+
4
6
  def has_with_trial(ability)
5
7
  ::Avo::App.license.has_with_trial(ability)
6
8
  end
@@ -26,9 +26,11 @@ class Avo::ButtonComponent < ViewComponent::Base
26
26
  def args
27
27
  if @args[:loading]
28
28
  @args[:"data-controller"] = "loading-button"
29
+ @args[:"data-loading-button-confirmed-value"] = false
30
+ @args[:"data-action"] = "click->loading-button#attemptSubmit"
29
31
 
30
32
  if @args[:confirm]
31
- @args[:"data-avo-confirm"] = @args.delete(:confirm)
33
+ @args[:"data-loading-button-confirmation-message-value"] = @args.delete(:confirm)
32
34
  end
33
35
  end
34
36
 
@@ -3,7 +3,7 @@
3
3
  data-key-value-target="controller"
4
4
  data-options="<%= @field.options.to_json %>"
5
5
  data-input-classes="<%= input_classes %>"
6
- data-editable="<%= @view.in?([:edit, :create]) %>"
6
+ data-editable="<%= @view.in?([:edit, :new]) %>"
7
7
  >
8
8
  <div class="w-full flex flex-col">
9
9
  <div class="flex w-full">
@@ -14,7 +14,7 @@
14
14
  <div class="w-1/2 py-3 px-3 uppercase font-semibold text-xs text-white">
15
15
  <%= @field.value_label %>
16
16
  </div>
17
- <% if @view.in?([:edit, :create]) %>
17
+ <% if @view.in?([:edit, :new]) %>
18
18
  <div class="flex items-center justify-center p-2 px-3 border-l border-gray-600">
19
19
  <a href="javascript:void(0);"
20
20
  title="<%= @field.action_text %>"
@@ -10,7 +10,7 @@ class Avo::Fields::Common::SingleFileViewerComponent < ViewComponent::Base
10
10
  end
11
11
 
12
12
  def destroy_path
13
- "#{@resource.record_path}/active_storage_attachments/#{id}/#{file.id}"
13
+ Avo::Services::URIService.parse(@resource.record_path).append_paths("active_storage_attachments", id, file.id).to_s
14
14
  end
15
15
 
16
16
  def id
@@ -1,9 +1,15 @@
1
1
  <%= edit_field_wrapper field: @field, index: @index, form: @form, resource: @resource, displayed_in_modal: @displayed_in_modal do %>
2
- <%= @form.select @field.id, @field.select_options, { selected: @field.value, prompt: @field.placeholder },
2
+ <%= @form.select @field.id, @field.select_options, {
3
+ selected: @field.value,
4
+ include_blank: @field.include_blank
5
+ },
6
+ aria: {
7
+ placeholder: @field.placeholder
8
+ },
3
9
  class: classes("w-full"),
4
10
  data: @field.get_html(:data, view: view, element: :input),
5
11
  disabled: @field.readonly,
6
- placeholder: @field.placeholder,
7
- style: @field.get_html(:style, view: view, element: :input)
12
+ style: @field.get_html(:style, view: view, element: :input),
13
+ placeholder: @field.include_blank.present? ? nil : @field.placeholder
8
14
  %>
9
15
  <% end %>
@@ -1,13 +1,32 @@
1
1
  <%= edit_field_wrapper field: @field, index: @index, form: @form, resource: @resource, displayed_in_modal: @displayed_in_modal do %>
2
- <div data-controller="date-field">
3
- <%= @form.date_field @field.id,
2
+ <%= content_tag :div, data: {
3
+ controller: "date-field",
4
+ date_field_view_value: @view,
5
+ date_field_enable_time_value: false,
6
+ date_field_format_value: @field.format,
7
+ date_field_picker_format_value: @field.picker_format,
8
+ date_field_first_day_of_week_value: @field.first_day_of_week,
9
+ date_field_disable_mobile_value: @field.disable_mobile,
10
+ date_field_relative_value: @field.relative,
11
+ } do %>
12
+ <%= datetime_field "fake_#{@field.id}", "fake",
13
+ value: @field.edit_formatted_value,
4
14
  class: classes("w-full"),
15
+ data: {
16
+ 'date-field-target': 'fakeInput',
17
+ placeholder: @field.placeholder,
18
+ relative: @field.relative,
19
+ **@field.get_html(:data, view: view, element: :input)
20
+ },
21
+ disabled: @field.readonly,
22
+ placeholder: @field.placeholder,
23
+ style: @field.get_html(:style, view: view, element: :input)
24
+ %>
25
+ <%= @form.text_field @field.id,
26
+ value: @field.edit_formatted_value,
27
+ class: classes("w-full hidden"),
5
28
  data: {
6
29
  'date-field-target': 'input',
7
- 'first-day-of-week': @field.first_day_of_week,
8
- 'picker-format': @field.picker_format,
9
- 'enable-time': false,
10
- format: @field.format,
11
30
  placeholder: @field.placeholder,
12
31
  relative: @field.relative,
13
32
  **@field.get_html(:data, view: view, element: :input)
@@ -16,5 +35,5 @@
16
35
  placeholder: @field.placeholder,
17
36
  style: @field.get_html(:style, view: view, element: :input)
18
37
  %>
19
- </div>
38
+ <% end %>
20
39
  <% end %>
@@ -1,3 +1,9 @@
1
1
  <%= index_field_wrapper field: @field, resource: @resource do %>
2
- <%= @field.formatted_value %>
2
+ <%= content_tag :div, data: {
3
+ controller: "date-field",
4
+ date_field_view_value: @view,
5
+ date_field_format_value: @field.format,
6
+ } do %>
7
+ <%= @field.formatted_value %>
8
+ <% end %>
3
9
  <% end %>
@@ -1,3 +1,9 @@
1
1
  <%= show_field_wrapper field: @field, resource: @resource, index: @index do %>
2
- <%= @field.formatted_value %>
2
+ <%= content_tag :div, data: {
3
+ controller: "date-field",
4
+ date_field_view_value: @view,
5
+ date_field_format_value: @field.format,
6
+ } do %>
7
+ <%= @field.formatted_value %>
8
+ <% end %>
3
9
  <% end %>
@@ -5,6 +5,7 @@
5
5
  date_field_enable_time_value: true,
6
6
  date_field_picker_format_value: @field.picker_format,
7
7
  date_field_first_day_of_week_value: @field.first_day_of_week,
8
+ date_field_disable_mobile_value: @field.disable_mobile,
8
9
  date_field_time24_hr_value: @field.time_24hr,
9
10
  date_field_timezone_value: @field.timezone,
10
11
  } do %>
@@ -3,6 +3,7 @@
3
3
  class Avo::Fields::EditComponent < ViewComponent::Base
4
4
  include Avo::ResourcesHelper
5
5
 
6
+ attr_reader :field
6
7
  attr_reader :view
7
8
 
8
9
  def initialize(field: nil, resource: nil, index: 0, form: nil, displayed_in_modal: false)
@@ -17,4 +18,8 @@ class Avo::Fields::EditComponent < ViewComponent::Base
17
18
  def classes(extra_classes = "")
18
19
  helpers.input_classes("#{@field.get_html(:classes, view: view, element: :input)} #{extra_classes}", has_error: @field.model_errors.include?(@field.id))
19
20
  end
21
+
22
+ def render?
23
+ !field.computed
24
+ end
20
25
  end
@@ -7,6 +7,7 @@
7
7
 
8
8
  <% if @resource.authorization.authorize_action(:upload_attachments?, raise_exception: false) %>
9
9
  <%= @form.file_field @field.id,
10
+ accept: @field.accept,
10
11
  data: @field.get_html(:data, view: view, element: :input),
11
12
  direct_upload: @field.direct_upload,
12
13
  disabled: @field.readonly,
@@ -4,6 +4,7 @@
4
4
  <% if @resource.authorization.authorize_action(:upload_attachments?, raise_exception: false) %>
5
5
  <div class="mt-2">
6
6
  <%= @form.file_field @field.id,
7
+ accept: @field.accept,
7
8
  data: @field.get_html(:data, view: view, element: :input),
8
9
  direct_upload: @field.direct_upload,
9
10
  disabled: @field.readonly,
@@ -1,12 +1,16 @@
1
1
  <%= edit_field_wrapper field: @field, index: @index, form: @form, resource: @resource, displayed_in_modal: @displayed_in_modal do %>
2
- <%= @form.select @field.id, @field.options_for_select, { selected: @field.value, prompt: @field.placeholder }, {
3
- aria: {
4
- placeholder: @field.placeholder
5
- },
6
- class: classes("w-full"),
7
- data: @field.get_html(:data, view: view, element: :input),
8
- disabled: @field.readonly,
9
- style: @field.get_html(:style, view: view, element: :input),
10
- value: @field.model.present? ? @field.model[@field.id] : @field.value
11
- } %>
2
+ <%= @form.select @field.id, @field.options_for_select, {
3
+ selected: @field.value,
4
+ include_blank: @field.include_blank
5
+ },
6
+ aria: {
7
+ placeholder: @field.placeholder
8
+ },
9
+ class: classes("w-full"),
10
+ data: @field.get_html(:data, view: view, element: :input),
11
+ disabled: @field.readonly,
12
+ style: @field.get_html(:style, view: view, element: :input),
13
+ value: @field.model.present? ? @field.model[@field.id] : @field.value,
14
+ placeholder: @field.include_blank.present? ? nil : @field.placeholder
15
+ %>
12
16
  <% end %>
@@ -5,7 +5,7 @@ class Avo::Fields::ShowComponent < ViewComponent::Base
5
5
 
6
6
  attr_reader :view
7
7
 
8
- def initialize(field: nil, resource: nil, index: 0)
8
+ def initialize(field: nil, resource: nil, index: 0, form: nil)
9
9
  @field = field
10
10
  @resource = resource
11
11
  @index = index
@@ -18,20 +18,6 @@ class Avo::Index::Ordering::ButtonComponent < Avo::Index::Ordering::BaseComponen
18
18
  end
19
19
 
20
20
  def order_path(args)
21
- if reflection.present?
22
- path = "#{::Avo::App.root_path}/resources/#{reflection_parent_resource.route_key}/#{params[:id]}/#{field.id}/#{resource.model.id}/order"
23
- else
24
- path = "#{::Avo::App.root_path}/resources/#{resource.route_key}/#{resource.model.id}/order"
25
- end
26
-
27
- if args.present?
28
- string_args = args.map do |key, value|
29
- "#{key}=#{value}"
30
- end.join('&')
31
-
32
- path = "#{path}?#{string_args}"
33
- end
34
-
35
- path
21
+ Avo::App.view_context.avo.reorder_order_path(resource.route_key, resource.model.id, **args)
36
22
  end
37
23
  end
@@ -46,7 +46,7 @@
46
46
  }
47
47
  %>
48
48
  <%= hidden_field_tag :turbo_frame, params[:turbo_frame], id: "turbo_frame_detach_#{@resource.model.id}" if params[:turbo_frame] %>
49
- <%= hidden_field_tag :referrer, request.fullpath, id: "referrer_detach_#{@resource.model.id}" if params[:turbo_frame] %>
49
+ <%= hidden_field_tag :referrer, referrer_path, id: "referrer_detach_#{@resource.model.id}" if params[:turbo_frame] %>
50
50
  <% end %>
51
51
  <% end %>
52
52
 
@@ -71,7 +71,7 @@
71
71
  %>
72
72
  <%= form.hidden_field :view_type, value: params[:view_type], id: "turbo_view_type_#{@resource.model.id}" if params[:view_type] %>
73
73
  <%= form.hidden_field :turbo_frame, value: params[:turbo_frame], id: "turbo_frame_destroy_#{@resource.model.id}" if params[:turbo_frame] %>
74
- <%= form.hidden_field :referrer, value: request.fullpath, id: "referrer_destroy_#{@resource.model.id}" if params[:turbo_frame] %>
74
+ <%= form.hidden_field :referrer, value: referrer_path, id: "referrer_destroy_#{@resource.model.id}" if params[:turbo_frame] %>
75
75
  <% end %>
76
76
  <% end %>
77
77
  </div>
@@ -41,7 +41,7 @@ class Avo::Index::ResourceControlsComponent < Avo::ResourceComponent
41
41
  end
42
42
 
43
43
  def edit_path
44
- #Add the `view` param to let Avo know where to redirect back when the user clicks the `Cancel` button.
44
+ # Add the `view` param to let Avo know where to redirect back when the user clicks the `Cancel` button.
45
45
  args = {via_view: 'index'}
46
46
 
47
47
  if @parent_model.present?
@@ -71,4 +71,8 @@ class Avo::Index::ResourceControlsComponent < Avo::ResourceComponent
71
71
  def is_has_many_association
72
72
  @reflection.is_a?(::ActiveRecord::Reflection::HasManyReflection) || @reflection.is_a?(::ActiveRecord::Reflection::ThroughReflection)
73
73
  end
74
+
75
+ def referrer_path
76
+ Avo::App.root_path(paths: ['resources', params[:resource_name], params[:id], params[:related_name]], query: request.query_parameters.to_h)
77
+ end
74
78
  end
@@ -1,6 +1,6 @@
1
1
  <div class="w-full ">
2
2
  <table class="w-full px-4 bg-white" data-resource-name='<%= @resource.model_key %>' data-controller='item-select-all'>
3
- <%= render partial: 'avo/partials/table_header', locals: {fields: @resource.get_fields(reflection: @reflection)} %>
3
+ <%= render partial: 'avo/partials/table_header', locals: {fields: @resource.get_fields(reflection: @reflection, only_root: true)} %>
4
4
  <tbody class="divide-y">
5
5
  <% @resources.each_with_index do |resource, index| %>
6
6
  <% cache_if Avo.configuration.cache_resources_on_index_view, resource.cache_hash(@parent_model), expires_in: 1.day do %>
@@ -9,7 +9,7 @@
9
9
  </div>
10
10
  </td>
11
11
  <% end %>
12
- <% @resource.get_fields(reflection: @reflection).each_with_index do |field, index| %>
12
+ <% @resource.get_fields(reflection: @reflection, only_root: true).each_with_index do |field, index| %>
13
13
  <%= render field.component_for_view(:index).new(field: field, resource: @resource, index: index, parent_model: @parent_model) %>
14
14
  <% end %>
15
15
  <td class="text-right whitespace-nowrap px-2">
@@ -0,0 +1,19 @@
1
+ <% if item.is_tool? %>
2
+ <% if item&.partial.present? %>
3
+ <%= render item.partial, tool: item %>
4
+ <% end %>
5
+ <% elsif item.is_panel? %>
6
+ <%= render Avo::PanelComponent.new(title: item.name, description: item.description, index: index, view: view) do |c| %>
7
+ <% c.body do %>
8
+ <div class="divide-y">
9
+ <% item.items.each_with_index do |field, index| %>
10
+ <%= render field.hydrate(resource: @resource, model: @resource.model, user: resource.user, view: view).component_for_view(view).new(field: field, resource: @resource, index: index, form: form) %>
11
+ <% end %>
12
+ </div>
13
+ <% end %>
14
+ <% end %>
15
+ <% elsif item.is_tab_group? %>
16
+ <%= render tab_group_component %>
17
+ <% elsif item.is_field? %>
18
+ <%= render field_component %>
19
+ <% end %>