avo 2.16.1.pre.1.nativefields → 2.17.1.pre.1.zeitwerk.eager.load.dir

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 (120) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +7 -3
  3. data/Gemfile.lock +43 -8
  4. data/README.md +1 -1
  5. data/app/assets/config/avo_manifest.js +1 -0
  6. data/app/assets/svgs/placeholder.svg +1 -0
  7. data/app/components/avo/actions_component.html.erb +3 -3
  8. data/app/components/avo/base_component.rb +7 -4
  9. data/app/components/avo/field_wrapper_component.html.erb +8 -10
  10. data/app/components/avo/field_wrapper_component.rb +14 -12
  11. data/app/components/avo/fields/badge_field/index_component.html.erb +1 -1
  12. data/app/components/avo/fields/belongs_to_field/edit_component.rb +9 -3
  13. data/app/components/avo/fields/belongs_to_field/index_component.html.erb +1 -1
  14. data/app/components/avo/fields/belongs_to_field/show_component.html.erb +1 -1
  15. data/app/components/avo/fields/belongs_to_field/show_component.rb +1 -1
  16. data/app/components/avo/fields/boolean_field/index_component.html.erb +1 -1
  17. data/app/components/avo/fields/boolean_field/show_component.html.erb +1 -1
  18. data/app/components/avo/fields/boolean_group_field/index_component.html.erb +1 -1
  19. data/app/components/avo/fields/boolean_group_field/show_component.html.erb +1 -1
  20. data/app/components/avo/fields/code_field/show_component.html.erb +1 -1
  21. data/app/components/avo/fields/common/heading_component.html.erb +5 -4
  22. data/app/components/avo/fields/common/heading_component.rb +6 -1
  23. data/app/components/avo/fields/country_field/index_component.html.erb +1 -1
  24. data/app/components/avo/fields/date_field/index_component.html.erb +1 -1
  25. data/app/components/avo/fields/date_time_field/index_component.html.erb +1 -1
  26. data/app/components/avo/fields/edit_component.rb +6 -4
  27. data/app/components/avo/fields/external_image_field/index_component.html.erb +1 -1
  28. data/app/components/avo/fields/file_field/edit_component.html.erb +2 -1
  29. data/app/components/avo/fields/file_field/index_component.html.erb +1 -1
  30. data/app/components/avo/fields/files_field/edit_component.html.erb +2 -1
  31. data/app/components/avo/fields/files_field/index_component.html.erb +1 -1
  32. data/app/components/avo/fields/files_field/show_component.html.erb +1 -1
  33. data/app/components/avo/fields/gravatar_field/index_component.html.erb +1 -1
  34. data/app/components/avo/fields/has_one_field/index_component.html.erb +1 -1
  35. data/app/components/avo/fields/heading_field/edit_component.html.erb +1 -1
  36. data/app/components/avo/fields/heading_field/show_component.html.erb +1 -1
  37. data/app/components/avo/fields/id_field/index_component.html.erb +1 -1
  38. data/app/components/avo/fields/index_component.rb +11 -2
  39. data/app/components/avo/fields/number_field/index_component.html.erb +1 -1
  40. data/app/components/avo/fields/progress_bar_field/index_component.html.erb +1 -1
  41. data/app/components/avo/fields/select_field/index_component.html.erb +1 -1
  42. data/app/components/avo/fields/show_component.rb +7 -1
  43. data/app/components/avo/fields/status_field/index_component.html.erb +1 -1
  44. data/app/components/avo/fields/tags_field/index_component.html.erb +1 -1
  45. data/app/components/avo/fields/text_field/edit_component.html.erb +3 -1
  46. data/app/components/avo/fields/text_field/index_component.html.erb +1 -1
  47. data/app/components/avo/fields/trix_field/edit_component.html.erb +1 -1
  48. data/app/components/avo/filters_component.html.erb +2 -2
  49. data/app/components/avo/index/grid_cover_empty_state_component.html.erb +1 -1
  50. data/app/components/avo/index/grid_item_component.html.erb +15 -13
  51. data/app/components/avo/index/grid_item_component.rb +1 -1
  52. data/app/components/avo/index/ordering/buttons_component.html.erb +1 -1
  53. data/app/components/avo/index/resource_controls_component.rb +2 -2
  54. data/app/components/avo/index/table_row_component.html.erb +1 -1
  55. data/app/components/avo/panel_component.html.erb +9 -2
  56. data/app/components/avo/panel_component.rb +3 -4
  57. data/app/components/avo/resource_component.rb +18 -0
  58. data/app/components/avo/resource_sidebar_component.html.erb +19 -0
  59. data/app/components/avo/resource_sidebar_component.rb +26 -0
  60. data/app/components/avo/sidebar_profile_component.html.erb +1 -1
  61. data/app/components/avo/tab_switcher_component.html.erb +2 -2
  62. data/app/components/avo/tab_switcher_component.rb +2 -0
  63. data/app/components/avo/views/resource_edit_component.html.erb +31 -25
  64. data/app/components/avo/views/resource_edit_component.rb +1 -1
  65. data/app/components/avo/views/resource_show_component.html.erb +8 -2
  66. data/app/components/avo/views/resource_show_component.rb +1 -1
  67. data/app/controllers/avo/actions_controller.rb +10 -2
  68. data/app/controllers/avo/application_controller.rb +4 -2
  69. data/app/controllers/avo/associations_controller.rb +24 -5
  70. data/app/controllers/avo/attachments_controller.rb +2 -1
  71. data/app/controllers/avo/base_controller.rb +6 -4
  72. data/app/controllers/avo/search_controller.rb +13 -4
  73. data/app/helpers/avo/application_helper.rb +7 -3
  74. data/app/helpers/avo/resources_helper.rb +2 -2
  75. data/app/javascript/avo.base.js +3 -1
  76. data/app/javascript/js/controllers/action_controller.js +1 -4
  77. data/app/javascript/js/controllers/actions_picker_controller.js +8 -9
  78. data/app/javascript/js/controllers/tabs_controller.js +14 -27
  79. data/app/views/avo/actions/show.html.erb +2 -2
  80. data/app/views/avo/home/failed_to_load.html.erb +3 -2
  81. data/avo.gemspec +2 -2
  82. data/config/brakeman.ignore +40 -0
  83. data/config/i18n-tasks.yml +159 -0
  84. data/config/routes.rb +1 -1
  85. data/db/factories.rb +20 -0
  86. data/lib/avo/app.rb +6 -0
  87. data/lib/avo/base_resource.rb +26 -0
  88. data/lib/avo/concerns/fetches_things.rb +1 -1
  89. data/lib/avo/concerns/has_fields.rb +22 -0
  90. data/lib/avo/concerns/is_resource_item.rb +4 -0
  91. data/lib/avo/configuration/branding.rb +9 -1
  92. data/lib/avo/dynamic_router.rb +19 -15
  93. data/lib/avo/engine.rb +9 -0
  94. data/lib/avo/fields/belongs_to_field.rb +3 -0
  95. data/lib/avo/fields/heading_field.rb +15 -0
  96. data/lib/avo/items_holder.rb +4 -0
  97. data/lib/avo/licensing/pro_license.rb +1 -0
  98. data/lib/avo/menu/builder.rb +1 -1
  99. data/lib/avo/menu/menu.rb +0 -2
  100. data/lib/avo/reloader.rb +27 -26
  101. data/lib/avo/services/authorization_service.rb +17 -3
  102. data/lib/avo/services/encryption_service.rb +1 -1
  103. data/lib/avo/sidebar.rb +60 -0
  104. data/lib/avo/sidebar_builder.rb +24 -0
  105. data/lib/avo/version.rb +1 -1
  106. data/lib/generators/avo/templates/field/components/index_component.html.erb.tt +1 -1
  107. data/lib/generators/avo/templates/initializer/avo.tt +2 -1
  108. data/lib/generators/avo/templates/locales/avo.en.yml +107 -107
  109. data/lib/generators/avo/templates/locales/avo.fr.yml +107 -107
  110. data/lib/generators/avo/templates/locales/avo.nb.yml +119 -0
  111. data/lib/generators/avo/templates/locales/avo.nn.yml +119 -0
  112. data/lib/generators/avo/templates/locales/avo.pt-BR.yml +109 -84
  113. data/lib/generators/avo/templates/locales/avo.ro.yml +109 -81
  114. data/lib/generators/avo/templates/locales/avo.tr.yml +119 -0
  115. data/public/avo-assets/avo.base.css +67 -79
  116. data/public/avo-assets/avo.base.js +63 -63
  117. data/public/avo-assets/avo.base.js.map +3 -3
  118. metadata +16 -22
  119. data/app/views/avo/home/failed_to_load.html copy.erb +0 -23
  120. data/lib/generators/avo/templates/locales/avo.nb-NO.yml +0 -93
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9faaa635bf77fa6bd6267dedf2a72bea08eb21c84714da5614be28df50da9028
4
- data.tar.gz: 34418d8586a608efdcaf5b44c4cd98450578c0719e731d3534ac243681d3b994
3
+ metadata.gz: 8ce480a1789187841a9bcca025afdb3cfab7f153ba672409d23e7f8cefdfbfa3
4
+ data.tar.gz: 5737e02acb4959d6a5313dc9534ebb7a6903efeba06b1b923a9902ceaf64c2ee
5
5
  SHA512:
6
- metadata.gz: 638a6f1809a1e379206d0358b8f8cb5767f53b3a8b5db8d61aa175744dd641c5332349d6108eb8565eae26b8629b9744da3549559243a4ced410a1b01cd41296
7
- data.tar.gz: 3565f031cabab8fc386cab48276bfeb54592a45d5fdea58c5541935f4ebfed684223fdaf80baf26f5fb321641cb20644660abb70ca15400386dbaf9d9b5ee895
6
+ metadata.gz: 2c6dd37752b3279c05f68bd1c78751303b517339ecd06c93d35b33d1384527556e046a5680bff507f48a37f8d7a737e9687692d88623e39631d33cbe1266765f
7
+ data.tar.gz: b29f21327fb24141d7acb656f031decf4320e19944eb7e47d47d5d9fd6bf72148af7a46cc2ec7e0042717940b64d748ad176b0eab2e8f13145020338751c51dc
data/Gemfile CHANGED
@@ -71,7 +71,7 @@ group :development do
71
71
  gem "bump", require: false
72
72
  gem "gem-release", require: false
73
73
 
74
- gem 'annotate'
74
+ gem "annotate"
75
75
 
76
76
  # gem 'rack-mini-profiler'
77
77
  # gem 'memory_profiler'
@@ -80,14 +80,17 @@ group :development do
80
80
 
81
81
  # gem 'pry-rails'
82
82
 
83
- gem 'htmlbeautifier'
83
+ gem "htmlbeautifier"
84
84
 
85
85
  gem "hotwire-livereload", "~> 1.1"
86
+
87
+ gem "brakeman"
86
88
  end
87
89
 
88
90
  group :development, :test do
89
91
  gem "awesome_print"
90
92
  gem "faker", require: false
93
+ gem "i18n-tasks", "~> 1.0.12"
91
94
  end
92
95
 
93
96
  group :test do
@@ -111,7 +114,7 @@ end
111
114
  gem "rubocop"
112
115
  gem "rubocop-shopify", require: false
113
116
 
114
- gem "zeitwerk", "~> 2.3"
117
+ # gem "zeitwerk", "~> 2.3"
115
118
 
116
119
  gem "httparty"
117
120
 
@@ -150,3 +153,4 @@ gem 'acts-as-taggable-on', '~> 9.0'
150
153
  gem "bundler-integrity", "~> 1.0"
151
154
 
152
155
  gem 'erb-formatter'
156
+ gem "zeitwerk", github: "fxn/zeitwerk"
data/Gemfile.lock CHANGED
@@ -1,7 +1,13 @@
1
+ GIT
2
+ remote: https://github.com/fxn/zeitwerk.git
3
+ revision: 50515063d309bf50cb1fdcffa7558ca26d124b3f
4
+ specs:
5
+ zeitwerk (2.6.1)
6
+
1
7
  PATH
2
8
  remote: .
3
9
  specs:
4
- avo (2.16.1.pre.1.nativefields)
10
+ avo (2.17.1.pre.1.zeitwerk.eager.load.dir)
5
11
  active_link_to
6
12
  addressable
7
13
  breadcrumbs_on_rails
@@ -17,8 +23,7 @@ PATH
17
23
  pundit
18
24
  rails (>= 6.0)
19
25
  turbo-rails
20
- view_component (= 2.60)
21
- zeitwerk
26
+ view_component
22
27
 
23
28
  GEM
24
29
  remote: https://rubygems.org/
@@ -119,9 +124,17 @@ GEM
119
124
  aws-sigv4 (1.5.1)
120
125
  aws-eventstream (~> 1, >= 1.0.2)
121
126
  bcrypt (3.1.18)
127
+ better_html (2.0.1)
128
+ actionview (>= 6.0)
129
+ activesupport (>= 6.0)
130
+ ast (~> 2.0)
131
+ erubi (~> 1.4)
132
+ parser (>= 2.4)
133
+ smart_properties
122
134
  bindex (0.8.1)
123
135
  bootsnap (1.13.0)
124
136
  msgpack (~> 1.2)
137
+ brakeman (5.3.1)
125
138
  breadcrumbs_on_rails (4.1.0)
126
139
  railties (>= 5.0)
127
140
  builder (3.2.4)
@@ -188,6 +201,7 @@ GEM
188
201
  groupdate (6.1.0)
189
202
  activesupport (>= 5.2)
190
203
  hashdiff (1.0.1)
204
+ highline (2.0.3)
191
205
  hightop (0.3.0)
192
206
  activesupport (>= 5.2)
193
207
  hotwire-livereload (1.2.2)
@@ -199,6 +213,17 @@ GEM
199
213
  multi_xml (>= 0.5.2)
200
214
  i18n (1.12.0)
201
215
  concurrent-ruby (~> 1.0)
216
+ i18n-tasks (1.0.12)
217
+ activesupport (>= 4.0.2)
218
+ ast (>= 2.1.0)
219
+ better_html (>= 1.0, < 3.0)
220
+ erubi
221
+ highline (>= 2.0.0)
222
+ i18n
223
+ parser (>= 2.2.3.0)
224
+ rails-i18n
225
+ rainbow (>= 2.2.2, < 4.0)
226
+ terminal-table (>= 1.5.1)
202
227
  image_processing (1.12.2)
203
228
  mini_magick (>= 4.9.5, < 5)
204
229
  ruby-vips (>= 2.0.17, < 3)
@@ -248,6 +273,8 @@ GEM
248
273
  nokogiri (1.13.8)
249
274
  mini_portile2 (~> 2.8.0)
250
275
  racc (~> 1.4)
276
+ nokogiri (1.13.8-x86_64-linux)
277
+ racc (~> 1.4)
251
278
  orm_adapter (0.5.0)
252
279
  pagy (5.10.1)
253
280
  activesupport
@@ -288,6 +315,9 @@ GEM
288
315
  nokogiri (>= 1.6)
289
316
  rails-html-sanitizer (1.4.3)
290
317
  loofah (~> 2.3)
318
+ rails-i18n (7.0.5)
319
+ i18n (>= 0.7, < 2)
320
+ railties (>= 6.0.0, < 8)
291
321
  railties (6.1.6.1)
292
322
  actionpack (= 6.1.6.1)
293
323
  activesupport (= 6.1.6.1)
@@ -349,7 +379,7 @@ GEM
349
379
  ruby-vips (2.1.4)
350
380
  ffi (~> 1.12)
351
381
  rubyzip (2.3.2)
352
- selenium-webdriver (4.4.0)
382
+ selenium-webdriver (4.5.0)
353
383
  childprocess (>= 0.5, < 5.0)
354
384
  rexml (~> 3.2, >= 3.2.5)
355
385
  rubyzip (>= 1.2.2, < 3.0)
@@ -364,6 +394,7 @@ GEM
364
394
  simplecov-html (0.12.3)
365
395
  simplecov_json_formatter (0.1.4)
366
396
  sixarm_ruby_unaccent (1.2.0)
397
+ smart_properties (1.17.0)
367
398
  spring (4.0.0)
368
399
  spring-commands-rspec (1.0.4)
369
400
  spring (>= 0.9.1)
@@ -377,6 +408,8 @@ GEM
377
408
  standard (1.16.0)
378
409
  rubocop (= 1.35.0)
379
410
  rubocop-performance (= 1.14.3)
411
+ terminal-table (3.0.2)
412
+ unicode-display_width (>= 1.1.1, < 3)
380
413
  test-prof (1.0.10)
381
414
  thor (1.2.1)
382
415
  timeout (0.3.0)
@@ -387,8 +420,9 @@ GEM
387
420
  tzinfo (2.0.5)
388
421
  concurrent-ruby (~> 1.0)
389
422
  unicode-display_width (2.2.0)
390
- view_component (2.60.0)
423
+ view_component (2.74.1)
391
424
  activesupport (>= 5.0.0, < 8.0)
425
+ concurrent-ruby (~> 1.0)
392
426
  method_source (~> 1.0)
393
427
  warden (1.2.9)
394
428
  rack (>= 2.0.9)
@@ -397,7 +431,7 @@ GEM
397
431
  activemodel (>= 6.0.0)
398
432
  bindex (>= 0.4.0)
399
433
  railties (>= 6.0.0)
400
- webdrivers (5.0.0)
434
+ webdrivers (5.2.0)
401
435
  nokogiri (~> 1.6)
402
436
  rubyzip (>= 1.3.0)
403
437
  selenium-webdriver (~> 4.0)
@@ -411,7 +445,6 @@ GEM
411
445
  websocket-extensions (0.1.5)
412
446
  xpath (3.2.0)
413
447
  nokogiri (~> 1.8)
414
- zeitwerk (2.6.0)
415
448
 
416
449
  PLATFORMS
417
450
  ruby
@@ -429,6 +462,7 @@ DEPENDENCIES
429
462
  awesome_print
430
463
  aws-sdk-s3
431
464
  bootsnap (>= 1.4.2)
465
+ brakeman
432
466
  breadcrumbs_on_rails
433
467
  bump
434
468
  bundler-integrity (~> 1.0)
@@ -450,6 +484,7 @@ DEPENDENCIES
450
484
  hotwire-livereload (~> 1.1)
451
485
  htmlbeautifier
452
486
  httparty
487
+ i18n-tasks (~> 1.0.12)
453
488
  image_processing (~> 1.12)
454
489
  iso
455
490
  jsbundling-rails
@@ -480,7 +515,7 @@ DEPENDENCIES
480
515
  web-console (>= 3.3.0)
481
516
  webdrivers
482
517
  webmock
483
- zeitwerk (~> 2.3)
518
+ zeitwerk!
484
519
 
485
520
  BUNDLED WITH
486
521
  2.3.5
data/README.md CHANGED
@@ -48,7 +48,7 @@ Avo is a beautiful next-generation framework that empowers you, the developer, t
48
48
  - **Menu builder** - Group and surface information as you need to
49
49
  - **Branding** - Make it look
50
50
 
51
- ## Some of the things we're going focusing on next
51
+ ## Some of the things we're going to focus on next
52
52
 
53
53
  Theming ⭐️ &nbsp;notifications ⭐️ &nbsp;Resource segmentation ⭐️ &nbsp;filterable fields ⭐️ &nbsp;inline editing ⭐️ &nbsp;multilingual records ⭐️ &nbsp;keyboard shortcuts ⭐️ &nbsp;track resource changes ⭐️ &nbsp;smart resource generation ⭐️ &nbsp;live resources ⭐️ &nbsp;columns view ⭐️ &nbsp;list view ⭐️ &nbsp;custom action items ⭐️ &nbsp;command bar ⭐️ &nbsp; use fields DSL in your custom views
54
54
 
@@ -1,2 +1,3 @@
1
1
  //= link_directory ../images/avo
2
+ //= link_directory ../svgs
2
3
  //= link_tree ../builds
@@ -0,0 +1 @@
1
+ <svg fill="#9197A1" xmlns:x="http://ns.adobe.com/Extensibility/1.0/" xmlns:i="http://ns.adobe.com/AdobeIllustrator/10.0/" xmlns:graph="http://ns.adobe.com/Graphs/1.0/" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" x="0px" y="0px" viewBox="0 0 100 125" style="enable-background:new 0 0 100 100;" xml:space="preserve"><switch><foreignObject requiredExtensions="http://ns.adobe.com/AdobeIllustrator/10.0/" x="0" y="0" width="1" height="1"/><g i:extraneous="self"><g><path d="M61.5,61.1c0-11.8-8.7-21.5-19.5-21.5c-10.7,0-19.5,9.6-19.5,21.5s8.7,21.5,19.5,21.5C52.8,82.6,61.5,73,61.5,61.1z M27.7,61.1c0-9,6.4-16.4,14.4-16.4s14.4,7.3,14.4,16.4S50,77.5,42.1,77.5S27.7,70.2,27.7,61.1z"/><path d="M44.6,54.3c0-1.4-1.1-2.5-2.5-2.5c-4.8,0-8.7,4.2-8.7,9.4c0,1.4,1.1,2.5,2.5,2.5s2.5-1.1,2.5-2.5c0-2.4,1.6-4.3,3.6-4.3 C43.5,56.8,44.6,55.7,44.6,54.3z"/><path d="M90.3,52.6c-1.1-9.3-5.8-21.5-12-31C72.7,12.9,63.3,2.5,50.7,2.5h-8.7c-11.6,0-21.5,11-24.6,27.4 c-1.1,5.7-3.2,11.2-5.2,16.3c-1.9,4.7-2.9,9.8-2.9,15c0,20,14.7,36.4,32.8,36.4h20.3c6,0,12.5-3.4,17.8-9.4 C88.3,79,92,66.1,90.3,52.6z M14.4,61.1c0-4.6,0.9-9,2.5-13.1c2.2-5.3,4.3-11.1,5.5-17.2C25,17.2,33.1,7.6,42.1,7.6 s17,9.6,19.6,23.2c1.2,6.2,3.3,11.9,5.5,17.2h0c1.7,4.1,2.5,8.5,2.5,13.1c0,17.2-12.4,31.3-27.7,31.3S14.4,78.4,14.4,61.1z M76.3,84.8c-4.2,4.8-9.5,7.6-14,7.6h-3.7c9.6-6.3,16.1-18,16.1-31.3c0-5.2-1-10.3-2.9-15c0,0,0,0,0,0 c-2.1-5.1-4.1-10.5-5.2-16.3C64.9,20.7,61.1,13.2,56,8.4c15.5,4.9,27.6,30.3,29.3,44.8C86.7,65.2,83.5,76.7,76.3,84.8z"/></g></g></switch></svg>
@@ -1,4 +1,4 @@
1
- <div class="relative flex flex-col w-full sm:w-auto z-40 js-actions-dropdown"
1
+ <div class="relative flex flex-col w-full sm:w-auto js-actions-dropdown"
2
2
  data-controller="toggle-panel actions-picker"
3
3
  data-actions-picker-enabled-class="text-black hover:bg-primary-500 hover:text-white"
4
4
  data-actions-picker-disabled-class="cursor-wait text-gray-500"
@@ -14,7 +14,7 @@
14
14
  <%= t 'avo.actions' %>
15
15
  <% end %>
16
16
  <div
17
- class="absolute flex inset-auto xl:right-0 top-full bg-white w-full sm:w-auto sm:min-w-[300px] mt-2 z-20 shadow-modal rounded overflow-hidden hidden"
17
+ class="absolute flex inset-auto xl:right-0 top-full bg-white w-full sm:w-auto sm:min-w-[300px] mt-2 z-40 shadow-modal rounded overflow-hidden hidden"
18
18
  data-toggle-panel-target="panel"
19
19
  >
20
20
  <div class="w-full space divide-y">
@@ -28,7 +28,7 @@
28
28
  },
29
29
  title: action.action_name,
30
30
  class: "flex items-center px-4 py-3 w-full font-semibold text-sm hover:bg-primary-100 #{is_disabled?(action) ? 'text-gray-500' : 'text-black'}" do %>
31
- <%= svg 'play', class: 'h-5 mr-1 inline' %> <%= action.action_name %>
31
+ <%= svg 'play', class: 'h-5 mr-1 inline pointer-events-none' %> <%= action.action_name %>
32
32
  <% end %>
33
33
  <% end %>
34
34
  </div>
@@ -17,13 +17,16 @@ class Avo::BaseComponent < ViewComponent::Base
17
17
  end
18
18
 
19
19
  # Fetch the resource and hydrate it with the model
20
- def relation_resource
21
- model = params[:via_resource_class] || params[:via_relation_class]
22
- model_klass = model.safe_constantize
20
+ def association_resource
21
+ resource = ::Avo::App.get_resource(params[:via_resource_class])
22
+ model_class_name = params[:via_relation_class] || resource.model_class
23
+
24
+ model_klass = ::Avo::BaseResource.valid_model_class model_class_name
23
25
 
24
- resource = ::Avo::App.get_resource_by_model_name model_klass
25
26
  model = model_klass.find params[:via_resource_id]
26
27
 
28
+ resource = ::Avo::App.get_resource_by_model_name model_klass if resource.blank?
29
+
27
30
  resource.dup.hydrate model: model
28
31
  end
29
32
 
@@ -2,8 +2,8 @@
2
2
  class: classes,
3
3
  style: style,
4
4
  data: data do %>
5
- <div class="h-full pt-4 md:pt-0 md:h-14 flex self-start items-center text-slate-800">
6
- <div class="<% if displayed_in_modal %> md:w-48 <% else %> md:w-64 px-6 md:px-6 <% end %> w-48 flex uppercase font-semibold text-gray-500 text-sm" data-slot="label">
5
+ <div class="h-full <% if stacked? %> md:pt-4 <% else %> md:pt-0 md:h-14 <% end %> pt-4 flex self-start items-center text-slate-800">
6
+ <div class="w-48 <% if compact? %> md:w-48 xl:w-64 <% else %> md:w-64 <% end %> px-6 flex uppercase font-semibold text-gray-500 text-sm" data-slot="label">
7
7
  <% if form.present? %>
8
8
  <%= form.label field.id, label %>
9
9
  <% else %>
@@ -12,17 +12,15 @@
12
12
  <% if on_edit? && field.is_required? %> <span class="text-red-600 ml-1">*</span> <% end %>
13
13
  </div>
14
14
  </div>
15
- <div class="flex-1 flex flex-row md:min-h-inherit py-2 <% unless displayed_in_modal %> px-6 <% end %>">
16
- <% if on_show? %>
17
- <div class="self-center <% if full_width %> w-full <% else %> w-full md:w-8/12 <% end %>" data-slot="value">
15
+ <div class="flex-1 flex flex-row md:min-h-inherit py-2 <% if stacked? %> pb-4 <% else %><% end %> px-6">
16
+ <div class="self-center <% if full_width? || compact? || stacked? %> w-full <% else %> md:w-8/12 <% end %>" data-slot="value">
17
+ <% if on_show? %>
18
18
  <% if field.value.blank? and dash_if_blank %>
19
19
 
20
20
  <% else %>
21
21
  <%= content %>
22
22
  <% end %>
23
- </div>
24
- <% elsif on_edit? %>
25
- <div class="self-center <% if displayed_in_modal or full_width or compact? %> w-full <% else %> w-full md:w-8/12 <% end %>" data-slot="value">
23
+ <% elsif on_edit? %>
26
24
  <%= content %>
27
25
  <% if record.present? and record.errors.include? field.id %>
28
26
  <div class="text-red-600 mt-2 text-sm"><%= record.errors.full_messages_for(field.id).to_sentence %></div>
@@ -30,8 +28,8 @@
30
28
  <% if help.present? %>
31
29
  <div class="text-gray-600 mt-2 text-sm"><%== help %></div>
32
30
  <% end %>
33
- </div>
34
- <% end %>
31
+ <% end %>
32
+ </div>
35
33
  </div>
36
34
  <% if params[:avo_debug].present? %>
37
35
  <!-- Raw value: -->
@@ -1,53 +1,47 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Avo::FieldWrapperComponent < ViewComponent::Base
4
- # attr_reader :classes
5
4
  attr_reader :dash_if_blank
6
- # attr_reader :data
7
- attr_reader :displayed_in_modal
8
- # attr_reader :help
5
+ attr_reader :compact
9
6
  attr_reader :field
10
7
  attr_reader :form
11
8
  attr_reader :full_width
12
- # attr_reader :label
13
9
  attr_reader :resource
14
- # attr_reader :record
15
- # attr_reader :style
16
10
  attr_reader :view
17
11
 
18
12
  def initialize(
19
- compact: false,
20
13
  dash_if_blank: true,
21
14
  data: {},
22
- displayed_in_modal: false,
15
+ compact: false,
23
16
  help: nil, # do we really need it?
24
17
  field: nil,
25
18
  form: nil,
26
19
  full_width: false,
27
20
  label: nil, # do we really need it?
28
21
  resource: nil,
22
+ stacked: false,
29
23
  style: "",
30
24
  view: :show,
31
25
  **args
32
26
  )
33
27
  @args = args
34
28
  @classes = args[:class].present? ? args[:class] : ""
35
- @compact = compact
36
29
  @dash_if_blank = dash_if_blank
37
30
  @data = data
38
- @displayed_in_modal = displayed_in_modal
31
+ @compact = compact
39
32
  @help = help
40
33
  @field = field
41
34
  @form = form
42
35
  @full_width = full_width
43
36
  @label = label
44
37
  @resource = resource
38
+ @stacked = stacked
45
39
  @style = style
46
40
  @view = view
47
41
  end
48
42
 
49
43
  def classes(extra_classes = "")
50
- "relative flex flex-col flex-grow pb-2 md:pb-0 leading-tight min-h-14 #{compact? ? "" : "md:flex-row md:items-center"} #{@classes || ""} #{extra_classes || ""} #{@field.get_html(:classes, view: view, element: :wrapper)}"
44
+ "relative flex flex-col flex-grow pb-2 md:pb-0 leading-tight min-h-14 #{stacked? ? "" : "md:flex-row md:items-center"} #{@classes || ""} #{extra_classes || ""} #{@field.get_html(:classes, view: view, element: :wrapper)}"
51
45
  end
52
46
 
53
47
  def style
@@ -96,7 +90,15 @@ class Avo::FieldWrapperComponent < ViewComponent::Base
96
90
  attributes
97
91
  end
98
92
 
93
+ def stacked?
94
+ @stacked
95
+ end
96
+
99
97
  def compact?
100
98
  @compact
101
99
  end
100
+
101
+ def full_width?
102
+ @full_width
103
+ end
102
104
  end
@@ -1,3 +1,3 @@
1
- <%= index_field_wrapper field: @field, resource: @resource, flush: true do %>
1
+ <%= index_field_wrapper **field_wrapper_args, flush: true do %>
2
2
  <%= render Avo::Fields::Common::BadgeViewerComponent.new value: @field.value, options: @field.options %>
3
3
  <% end %>
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Avo::Fields::BelongsToField::EditComponent < Avo::Fields::EditComponent
4
- def initialize(field: nil, resource: nil, index: 0, form: nil, displayed_in_modal: false)
5
- super field: field, resource: resource, index: index, form: form, displayed_in_modal: displayed_in_modal
4
+ def initialize(field: nil, resource: nil, index: 0, form: nil, compact: false)
5
+ super field: field, resource: resource, index: index, form: form, compact: compact
6
6
 
7
7
  @polymorphic_record = nil
8
8
  end
@@ -12,7 +12,7 @@ class Avo::Fields::BelongsToField::EditComponent < Avo::Fields::EditComponent
12
12
 
13
13
  # When visiting the record through it's association we keep the field disabled by default
14
14
  # We make an exception when the user deliberately instructs Avo to allow detaching in this scenario
15
- return !@field.allow_via_detaching if @field.target_resource.present? && @field.target_resource.model_class.name == params[:via_resource_class]
15
+ return !@field.allow_via_detaching if @field.target_resource.present? && visit_through_association?
16
16
  return !@field.allow_via_detaching if @field.id.to_s == params[:via_relation].to_s
17
17
 
18
18
  false
@@ -52,4 +52,10 @@ class Avo::Fields::BelongsToField::EditComponent < Avo::Fields::EditComponent
52
52
  def field_html_action
53
53
  @field.get_html(:data, view: @resource.view, element: :input).fetch(:action, nil)
54
54
  end
55
+
56
+ private
57
+
58
+ def visit_through_association?
59
+ @field.target_resource.class.to_s == params[:via_resource_class].to_s
60
+ end
55
61
  end
@@ -1,4 +1,4 @@
1
- <%= index_field_wrapper field: @field, resource: @resource do %>
1
+ <%= index_field_wrapper **field_wrapper_args do %>
2
2
  <%= link_to @field.label, helpers.resource_view_path(model: @field.value, resource: @field.target_resource)
3
3
  %>
4
4
  <% end %>
@@ -1,3 +1,3 @@
1
1
  <%= field_wrapper **field_wrapper_args do %>
2
- <%= link_to @field.label, resource_view_path %>
2
+ <%= link_to @field.label, resource_view_path, data: {turbo_frame: @field.target} %>
3
3
  <% end %>
@@ -5,7 +5,7 @@ class Avo::Fields::BelongsToField::ShowComponent < Avo::Fields::ShowComponent
5
5
  helpers.resource_view_path(
6
6
  model: @field.value,
7
7
  resource: @field.target_resource,
8
- via_resource_class: @resource.model_class,
8
+ via_resource_class: @resource.class.to_s,
9
9
  via_resource_id: @resource.model.id
10
10
  )
11
11
  end
@@ -1,3 +1,3 @@
1
- <%= index_field_wrapper field: @field, resource: @resource, dash_if_blank: false, center_content: true, flush: true do %>
1
+ <%= index_field_wrapper **field_wrapper_args, dash_if_blank: false, center_content: true, flush: true do %>
2
2
  <%= render Avo::Fields::Common::BooleanCheckComponent.new checked: @field.value %>
3
3
  <% end %>
@@ -1,3 +1,3 @@
1
- <%= field_wrapper **field_wrapper_args, dash_if_blank: false do %>
1
+ <%= field_wrapper **field_wrapper_args, dash_if_blank: false do %>
2
2
  <%= render Avo::Fields::Common::BooleanCheckComponent.new checked: @field.value %>
3
3
  <% end %>
@@ -1,3 +1,3 @@
1
- <%= index_field_wrapper field: @field, resource: @resource, dash_if_blank: false do %>
1
+ <%= index_field_wrapper **field_wrapper_args, dash_if_blank: false do %>
2
2
  <%= render Avo::Fields::Common::BooleanGroupComponent.new options: @field.options, value: @field.value %>
3
3
  <% end %>
@@ -1,3 +1,3 @@
1
- <%= field_wrapper **field_wrapper_args, dash_if_blank: false do %>
1
+ <%= field_wrapper **field_wrapper_args, dash_if_blank: false do %>
2
2
  <%= render Avo::Fields::Common::BooleanGroupComponent.new options: @field.options, value: @field.value %>
3
3
  <% end %>
@@ -1,4 +1,4 @@
1
- <%= field_wrapper **field_wrapper_args, full_width: true do %>
1
+ <%= field_wrapper **field_wrapper_args, full_width: true do %>
2
2
  <div data-controller="code-field" style="--height: <%= @field.height %>">
3
3
  <%= text_area_tag @field.id, @field.value,
4
4
  class: helpers.input_classes('w-full'),
@@ -1,10 +1,11 @@
1
1
  <div class="flex items-start py-1 leading-tight bg-gray-100 text-gray-500 text-xs">
2
2
  <div class="py-2 px-6 h-full w-full">
3
- <% if @value.present? %>
4
- <% if @as_html %>
5
- <%== @value %>
3
+ <% if empty %>
4
+ <% elsif value.present? %>
5
+ <% if as_html %>
6
+ <%== value %>
6
7
  <% else %>
7
- <div class="font-semibold uppercase"><%= @value %></div>
8
+ <div class="font-semibold uppercase"><%= value %></div>
8
9
  <% end %>
9
10
  <% else %>
10
11
 
@@ -1,8 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Avo::Fields::Common::HeadingComponent < ViewComponent::Base
4
- def initialize(value:, as_html:)
4
+ attr_reader :value
5
+ attr_reader :as_html
6
+ attr_reader :empty
7
+
8
+ def initialize(value:, as_html:, empty:)
5
9
  @value = value
6
10
  @as_html = as_html
11
+ @empty = empty
7
12
  end
8
13
  end
@@ -1,4 +1,4 @@
1
- <%= index_field_wrapper field: @field, resource: @resource do %>
1
+ <%= index_field_wrapper **field_wrapper_args do %>
2
2
  <% if @field.display_code %>
3
3
  <%= @field.value %>
4
4
  <% else %>
@@ -1,4 +1,4 @@
1
- <%= index_field_wrapper field: @field, resource: @resource do %>
1
+ <%= index_field_wrapper **field_wrapper_args do %>
2
2
  <%= content_tag :div, data: {
3
3
  controller: "date-field",
4
4
  date_field_view_value: @view,
@@ -1,4 +1,4 @@
1
- <%= index_field_wrapper field: @field, resource: @resource do %>
1
+ <%= index_field_wrapper **field_wrapper_args do %>
2
2
  <%= content_tag :div, data: {
3
3
  controller: "date-field",
4
4
  date_field_view_value: @view,
@@ -4,20 +4,22 @@ class Avo::Fields::EditComponent < ViewComponent::Base
4
4
  include Avo::ResourcesHelper
5
5
 
6
6
  attr_reader :compact
7
- attr_reader :displayed_in_modal
8
7
  attr_reader :field
9
8
  attr_reader :form
10
9
  attr_reader :index
10
+ attr_reader :multiple
11
11
  attr_reader :resource
12
+ attr_reader :stacked
12
13
  attr_reader :view
13
14
 
14
- def initialize(field: nil, resource: nil, index: 0, form: nil, displayed_in_modal: false, compact: false, **kwargs)
15
+ def initialize(field: nil, resource: nil, index: 0, form: nil, compact: false, stacked: false, multiple: false, **kwargs)
15
16
  @compact = compact
16
- @displayed_in_modal = displayed_in_modal
17
17
  @field = field
18
18
  @form = form
19
19
  @index = index
20
+ @multiple = multiple
20
21
  @resource = resource
22
+ @stacked = stacked
21
23
  @view = :edit
22
24
  end
23
25
 
@@ -32,11 +34,11 @@ class Avo::Fields::EditComponent < ViewComponent::Base
32
34
  def field_wrapper_args
33
35
  {
34
36
  compact: compact,
35
- displayed_in_modal: displayed_in_modal,
36
37
  field: field,
37
38
  form: form,
38
39
  index: index,
39
40
  resource: resource,
41
+ stacked: stacked,
40
42
  view: view
41
43
  }
42
44
  end
@@ -1,4 +1,4 @@
1
- <%= index_field_wrapper field: @field, resource: @resource, flush: true do %>
1
+ <%= index_field_wrapper **field_wrapper_args, flush: true do %>
2
2
  <% if @field.value.present? %>
3
3
  <%= link_to_if @field.link_to_resource.present?,
4
4
  image_tag(@field.value,
@@ -11,7 +11,8 @@
11
11
  data: @field.get_html(:data, view: view, element: :input),
12
12
  direct_upload: @field.direct_upload,
13
13
  disabled: @field.is_readonly?,
14
- style: @field.get_html(:style, view: view, element: :input)
14
+ style: @field.get_html(:style, view: view, element: :input),
15
+ class: "w-full"
15
16
  %>
16
17
  <% end %>
17
18
  <% end %>
@@ -1,4 +1,4 @@
1
- <%= index_field_wrapper field: @field, resource: @resource, flush: flush? do %>
1
+ <%= index_field_wrapper **field_wrapper_args, flush: flush? do %>
2
2
  <% if @field.value.present? %>
3
3
  <% if @field.value.attached? && @field.value.representable? && @field.is_image %>
4
4
  <%= link_to_if @field.link_to_resource, image_tag(helpers.main_app.url_for(@field.value), class: 'h-10'), resource_view_path, class: 'block' %>
@@ -9,7 +9,8 @@
9
9
  direct_upload: @field.direct_upload,
10
10
  disabled: @field.is_readonly?,
11
11
  multiple: true,
12
- style: @field.get_html(:style, view: view, element: :input)
12
+ style: @field.get_html(:style, view: view, element: :input),
13
+ class: "w-full"
13
14
  %>
14
15
  </div>
15
16
  <% end %>
@@ -1,3 +1,3 @@
1
- <%= index_field_wrapper field: @field, resource: @resource do %>
1
+ <%= index_field_wrapper **field_wrapper_args do %>
2
2
  <%= @field.value.attachments.length %> files
3
3
  <% end %>
@@ -1,3 +1,3 @@
1
- <%= field_wrapper **field_wrapper_args, full_width: true do %>
1
+ <%= field_wrapper **field_wrapper_args, full_width: true do %>
2
2
  <%= render Avo::Fields::Common::FilesListViewerComponent.new(field: @field, resource: @resource) if @field.value.present? %>
3
3
  <% end %>
@@ -1,4 +1,4 @@
1
- <%= index_field_wrapper field: @field, resource: @resource, flush: true do %>
1
+ <%= index_field_wrapper **field_wrapper_args, flush: true do %>
2
2
  <%= render Avo::Fields::Common::GravatarViewerComponent.new(
3
3
  md5: @field.md5,
4
4
  default: @field.default,
@@ -1,3 +1,3 @@
1
- <%= index_field_wrapper field: @field, resource: @resource do %>
1
+ <%= index_field_wrapper **field_wrapper_args do %>
2
2
  <%= link_to @field.label, helpers.resource_path(model: @field.value, resource: @field.target_resource) %>
3
3
  <% end %>