avo 1.6.4.pre.1 → 1.7.3
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.
- checksums.yaml +4 -4
- data/Gemfile +3 -1
- data/Gemfile.lock +90 -69
- data/README.md +2 -2
- data/app/components/avo/edit/field_wrapper_component.html.erb +1 -1
- data/app/components/avo/edit/field_wrapper_component.rb +6 -1
- data/app/components/avo/fields/belongs_to_field/edit_component.html.erb +65 -15
- data/app/components/avo/fields/belongs_to_field/edit_component.rb +1 -1
- data/app/components/avo/fields/common/badge_viewer_component.html.erb +1 -1
- data/app/components/avo/fields/common/multiple_file_viewer_component.html.erb +1 -1
- data/app/components/avo/fields/common/single_file_viewer_component.html.erb +1 -1
- data/app/components/avo/fields/file_field/index_component.html.erb +1 -1
- data/app/components/avo/fields/trix_field/edit_component.html.erb +3 -0
- data/app/components/avo/index/grid_item_component.html.erb +4 -6
- data/app/components/avo/views/resource_index_component.html.erb +48 -46
- data/app/components/avo/views/resource_index_component.rb +1 -1
- data/app/controllers/avo/application_controller.rb +11 -9
- data/app/controllers/avo/base_controller.rb +21 -0
- data/app/controllers/avo/search_controller.rb +3 -1
- data/app/packs/js/controllers/fields/belongs_to_field_controller.js +65 -0
- data/app/packs/js/controllers/fields/trix_field_controller.js +16 -0
- data/app/views/avo/actions/show.html.erb +1 -1
- data/app/views/avo/attachments/show.html.erb +1 -1
- data/app/views/avo/base/_actions.html.erb +2 -2
- data/app/views/avo/home/index.html.erb +2 -2
- data/app/views/avo/partials/_javascript.html.erb +1 -1
- data/app/views/avo/partials/_resource_search.html.erb +1 -1
- data/app/views/avo/relations/new.html.erb +1 -1
- data/app/views/avo/sidebar/_sidebar.html.erb +1 -1
- data/db/factories.rb +4 -0
- data/lib/avo/app.rb +3 -1
- data/lib/avo/base_resource.rb +40 -43
- data/lib/avo/configuration.rb +7 -1
- data/lib/avo/fields/base_field.rb +5 -3
- data/lib/avo/fields/belongs_to_field.rb +96 -12
- data/lib/avo/fields/boolean_group_field.rb +1 -1
- data/lib/avo/fields/date_time_field.rb +1 -1
- data/lib/avo/fields/file_field.rb +0 -8
- data/lib/avo/fields/files_field.rb +1 -1
- data/lib/avo/fields/has_and_belongs_to_many_field.rb +4 -4
- data/lib/avo/fields/has_many_field.rb +4 -4
- data/lib/avo/fields/has_one_field.rb +5 -5
- data/lib/avo/fields/key_value_field.rb +1 -1
- data/lib/avo/fields/trix_field.rb +6 -0
- data/lib/avo/fields_collector.rb +0 -2
- data/lib/avo/version.rb +1 -1
- data/lib/generators/avo/field_generator.rb +1 -1
- data/lib/generators/avo/install_generator.rb +1 -1
- data/lib/generators/avo/templates/initializer/avo.tt +1 -0
- data/lib/generators/avo/templates/tool/sidebar_item.tt +1 -1
- data/public/avo-packs/css/application-797341b7.css.map +1 -1
- data/public/avo-packs/css/application-797341b7.css.map.br +0 -0
- data/public/avo-packs/css/application-797341b7.css.map.gz +0 -0
- data/public/avo-packs/js/application-651ed7b9bc727c83f673.js +26 -0
- data/public/avo-packs/js/{application-b444cbf11135b4b23654.js.LICENSE.txt → application-651ed7b9bc727c83f673.js.LICENSE.txt} +0 -0
- data/public/avo-packs/js/application-651ed7b9bc727c83f673.js.br +0 -0
- data/public/avo-packs/js/application-651ed7b9bc727c83f673.js.gz +0 -0
- data/public/avo-packs/js/application-651ed7b9bc727c83f673.js.map +1 -0
- data/public/avo-packs/js/application-651ed7b9bc727c83f673.js.map.br +0 -0
- data/public/avo-packs/js/application-651ed7b9bc727c83f673.js.map.gz +0 -0
- data/public/avo-packs/manifest.json +8 -8
- metadata +12 -11
- data/public/avo-packs/js/application-b444cbf11135b4b23654.js +0 -26
- data/public/avo-packs/js/application-b444cbf11135b4b23654.js.br +0 -0
- data/public/avo-packs/js/application-b444cbf11135b4b23654.js.gz +0 -0
- data/public/avo-packs/js/application-b444cbf11135b4b23654.js.map +0 -1
- data/public/avo-packs/js/application-b444cbf11135b4b23654.js.map.br +0 -0
- data/public/avo-packs/js/application-b444cbf11135b4b23654.js.map.gz +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e90b67895c63939d8d29c9cb2a97c2e71abbe4ac6565d0cdc39557ce021b560
|
4
|
+
data.tar.gz: d7a52031956d7ff25f6d5c4ddc5a357d3bcf370401774ad72c9a49cfb1751873
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a80c3bd1e341a5b17604a066424a3a2485ad89b221cc48c3ca01becfdd516374fc6fa8cc97b2e702e50adceac20771618667b7ed57e5c57848fa973ad38d083
|
7
|
+
data.tar.gz: ca6453169ce93d46c1b9664d4306f97c9eaa5e9619512f4ace6db5084ce1100f3168ff4345a22a6d4ca0d4743c5201a7e792816acc949c31338dbabd9e1d6924
|
data/Gemfile
CHANGED
@@ -26,7 +26,7 @@ gem "pundit"
|
|
26
26
|
# Dependencies for dummy_app
|
27
27
|
#
|
28
28
|
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
|
29
|
-
gem "rails", "~> 6.
|
29
|
+
gem "rails", "~> 6.1.0"
|
30
30
|
# Use postgresql as the database for Active Record
|
31
31
|
gem "pg", ">= 0.18", "< 2.0"
|
32
32
|
# Use Puma as the app server
|
@@ -128,3 +128,5 @@ gem 'breadcrumbs_on_rails'
|
|
128
128
|
gem 'manifester'
|
129
129
|
|
130
130
|
gem 'ransack'
|
131
|
+
|
132
|
+
gem "aws-sdk-s3", require: false
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
avo (1.
|
4
|
+
avo (1.7.3)
|
5
5
|
active_link_to
|
6
6
|
addressable
|
7
7
|
breadcrumbs_on_rails
|
@@ -21,38 +21,40 @@ PATH
|
|
21
21
|
GEM
|
22
22
|
remote: https://rubygems.org/
|
23
23
|
specs:
|
24
|
-
actioncable (6.
|
25
|
-
actionpack (= 6.
|
24
|
+
actioncable (6.1.3.2)
|
25
|
+
actionpack (= 6.1.3.2)
|
26
|
+
activesupport (= 6.1.3.2)
|
26
27
|
nio4r (~> 2.0)
|
27
28
|
websocket-driver (>= 0.6.1)
|
28
|
-
actionmailbox (6.
|
29
|
-
actionpack (= 6.
|
30
|
-
activejob (= 6.
|
31
|
-
activerecord (= 6.
|
32
|
-
activestorage (= 6.
|
33
|
-
activesupport (= 6.
|
29
|
+
actionmailbox (6.1.3.2)
|
30
|
+
actionpack (= 6.1.3.2)
|
31
|
+
activejob (= 6.1.3.2)
|
32
|
+
activerecord (= 6.1.3.2)
|
33
|
+
activestorage (= 6.1.3.2)
|
34
|
+
activesupport (= 6.1.3.2)
|
34
35
|
mail (>= 2.7.1)
|
35
|
-
actionmailer (6.
|
36
|
-
actionpack (= 6.
|
37
|
-
actionview (= 6.
|
38
|
-
activejob (= 6.
|
36
|
+
actionmailer (6.1.3.2)
|
37
|
+
actionpack (= 6.1.3.2)
|
38
|
+
actionview (= 6.1.3.2)
|
39
|
+
activejob (= 6.1.3.2)
|
40
|
+
activesupport (= 6.1.3.2)
|
39
41
|
mail (~> 2.5, >= 2.5.4)
|
40
42
|
rails-dom-testing (~> 2.0)
|
41
|
-
actionpack (6.
|
42
|
-
actionview (= 6.
|
43
|
-
activesupport (= 6.
|
44
|
-
rack (~> 2.0, >= 2.0.
|
43
|
+
actionpack (6.1.3.2)
|
44
|
+
actionview (= 6.1.3.2)
|
45
|
+
activesupport (= 6.1.3.2)
|
46
|
+
rack (~> 2.0, >= 2.0.9)
|
45
47
|
rack-test (>= 0.6.3)
|
46
48
|
rails-dom-testing (~> 2.0)
|
47
49
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
48
|
-
actiontext (6.
|
49
|
-
actionpack (= 6.
|
50
|
-
activerecord (= 6.
|
51
|
-
activestorage (= 6.
|
52
|
-
activesupport (= 6.
|
50
|
+
actiontext (6.1.3.2)
|
51
|
+
actionpack (= 6.1.3.2)
|
52
|
+
activerecord (= 6.1.3.2)
|
53
|
+
activestorage (= 6.1.3.2)
|
54
|
+
activesupport (= 6.1.3.2)
|
53
55
|
nokogiri (>= 1.8.5)
|
54
|
-
actionview (6.
|
55
|
-
activesupport (= 6.
|
56
|
+
actionview (6.1.3.2)
|
57
|
+
activesupport (= 6.1.3.2)
|
56
58
|
builder (~> 3.1)
|
57
59
|
erubi (~> 1.4)
|
58
60
|
rails-dom-testing (~> 2.0)
|
@@ -60,25 +62,27 @@ GEM
|
|
60
62
|
active_link_to (1.0.5)
|
61
63
|
actionpack
|
62
64
|
addressable
|
63
|
-
activejob (6.
|
64
|
-
activesupport (= 6.
|
65
|
+
activejob (6.1.3.2)
|
66
|
+
activesupport (= 6.1.3.2)
|
65
67
|
globalid (>= 0.3.6)
|
66
|
-
activemodel (6.
|
67
|
-
activesupport (= 6.
|
68
|
-
activerecord (6.
|
69
|
-
activemodel (= 6.
|
70
|
-
activesupport (= 6.
|
71
|
-
activestorage (6.
|
72
|
-
actionpack (= 6.
|
73
|
-
activejob (= 6.
|
74
|
-
activerecord (= 6.
|
68
|
+
activemodel (6.1.3.2)
|
69
|
+
activesupport (= 6.1.3.2)
|
70
|
+
activerecord (6.1.3.2)
|
71
|
+
activemodel (= 6.1.3.2)
|
72
|
+
activesupport (= 6.1.3.2)
|
73
|
+
activestorage (6.1.3.2)
|
74
|
+
actionpack (= 6.1.3.2)
|
75
|
+
activejob (= 6.1.3.2)
|
76
|
+
activerecord (= 6.1.3.2)
|
77
|
+
activesupport (= 6.1.3.2)
|
75
78
|
marcel (~> 1.0.0)
|
76
|
-
|
79
|
+
mini_mime (~> 1.0.2)
|
80
|
+
activesupport (6.1.3.2)
|
77
81
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
78
|
-
i18n (>=
|
79
|
-
minitest (
|
80
|
-
tzinfo (~>
|
81
|
-
zeitwerk (~> 2.
|
82
|
+
i18n (>= 1.6, < 2)
|
83
|
+
minitest (>= 5.1)
|
84
|
+
tzinfo (~> 2.0)
|
85
|
+
zeitwerk (~> 2.3)
|
82
86
|
addressable (2.7.0)
|
83
87
|
public_suffix (>= 2.0.2, < 5.0)
|
84
88
|
appraisal (2.4.0)
|
@@ -86,6 +90,22 @@ GEM
|
|
86
90
|
rake
|
87
91
|
thor (>= 0.14.0)
|
88
92
|
ast (2.4.2)
|
93
|
+
aws-eventstream (1.1.1)
|
94
|
+
aws-partitions (1.465.0)
|
95
|
+
aws-sdk-core (3.114.1)
|
96
|
+
aws-eventstream (~> 1, >= 1.0.2)
|
97
|
+
aws-partitions (~> 1, >= 1.239.0)
|
98
|
+
aws-sigv4 (~> 1.1)
|
99
|
+
jmespath (~> 1.0)
|
100
|
+
aws-sdk-kms (1.43.0)
|
101
|
+
aws-sdk-core (~> 3, >= 3.112.0)
|
102
|
+
aws-sigv4 (~> 1.1)
|
103
|
+
aws-sdk-s3 (1.95.1)
|
104
|
+
aws-sdk-core (~> 3, >= 3.112.0)
|
105
|
+
aws-sdk-kms (~> 1)
|
106
|
+
aws-sigv4 (~> 1.1)
|
107
|
+
aws-sigv4 (1.2.3)
|
108
|
+
aws-eventstream (~> 1, >= 1.0.2)
|
89
109
|
bcrypt (3.1.16)
|
90
110
|
bindex (0.8.1)
|
91
111
|
bootsnap (1.7.3)
|
@@ -157,6 +177,7 @@ GEM
|
|
157
177
|
i18n
|
158
178
|
jbuilder (2.10.1)
|
159
179
|
activesupport (>= 5.0.0)
|
180
|
+
jmespath (1.4.0)
|
160
181
|
launchy (2.5.0)
|
161
182
|
addressable (~> 2.7)
|
162
183
|
listen (3.5.1)
|
@@ -178,16 +199,16 @@ GEM
|
|
178
199
|
mime-types-data (~> 3.2015)
|
179
200
|
mime-types-data (3.2021.0225)
|
180
201
|
mini_magick (4.11.0)
|
181
|
-
mini_mime (1.
|
182
|
-
mini_portile2 (2.5.
|
202
|
+
mini_mime (1.0.3)
|
203
|
+
mini_portile2 (2.5.3)
|
183
204
|
minitest (5.14.4)
|
184
205
|
msgpack (1.4.2)
|
185
206
|
multi_xml (0.6.0)
|
186
207
|
nio4r (2.5.7)
|
187
|
-
nokogiri (1.11.
|
208
|
+
nokogiri (1.11.7)
|
188
209
|
mini_portile2 (~> 2.5.0)
|
189
210
|
racc (~> 1.4)
|
190
|
-
nokogiri (1.11.
|
211
|
+
nokogiri (1.11.7-x86_64-linux)
|
191
212
|
racc (~> 1.4)
|
192
213
|
orm_adapter (0.5.0)
|
193
214
|
pagy (3.13.0)
|
@@ -206,20 +227,20 @@ GEM
|
|
206
227
|
rack
|
207
228
|
rack-test (1.1.0)
|
208
229
|
rack (>= 1.0, < 3)
|
209
|
-
rails (6.
|
210
|
-
actioncable (= 6.
|
211
|
-
actionmailbox (= 6.
|
212
|
-
actionmailer (= 6.
|
213
|
-
actionpack (= 6.
|
214
|
-
actiontext (= 6.
|
215
|
-
actionview (= 6.
|
216
|
-
activejob (= 6.
|
217
|
-
activemodel (= 6.
|
218
|
-
activerecord (= 6.
|
219
|
-
activestorage (= 6.
|
220
|
-
activesupport (= 6.
|
221
|
-
bundler (>= 1.
|
222
|
-
railties (= 6.
|
230
|
+
rails (6.1.3.2)
|
231
|
+
actioncable (= 6.1.3.2)
|
232
|
+
actionmailbox (= 6.1.3.2)
|
233
|
+
actionmailer (= 6.1.3.2)
|
234
|
+
actionpack (= 6.1.3.2)
|
235
|
+
actiontext (= 6.1.3.2)
|
236
|
+
actionview (= 6.1.3.2)
|
237
|
+
activejob (= 6.1.3.2)
|
238
|
+
activemodel (= 6.1.3.2)
|
239
|
+
activerecord (= 6.1.3.2)
|
240
|
+
activestorage (= 6.1.3.2)
|
241
|
+
activesupport (= 6.1.3.2)
|
242
|
+
bundler (>= 1.15.0)
|
243
|
+
railties (= 6.1.3.2)
|
223
244
|
sprockets-rails (>= 2.0.0)
|
224
245
|
rails-controller-testing (1.0.5)
|
225
246
|
actionpack (>= 5.0.1.rc1)
|
@@ -230,12 +251,12 @@ GEM
|
|
230
251
|
nokogiri (>= 1.6)
|
231
252
|
rails-html-sanitizer (1.3.0)
|
232
253
|
loofah (~> 2.3)
|
233
|
-
railties (6.
|
234
|
-
actionpack (= 6.
|
235
|
-
activesupport (= 6.
|
254
|
+
railties (6.1.3.2)
|
255
|
+
actionpack (= 6.1.3.2)
|
256
|
+
activesupport (= 6.1.3.2)
|
236
257
|
method_source
|
237
258
|
rake (>= 0.8.7)
|
238
|
-
thor (
|
259
|
+
thor (~> 1.0)
|
239
260
|
rainbow (3.0.0)
|
240
261
|
rake (13.0.3)
|
241
262
|
ransack (2.4.2)
|
@@ -325,19 +346,18 @@ GEM
|
|
325
346
|
rails (>= 6.0.0)
|
326
347
|
test-prof (0.12.2)
|
327
348
|
thor (1.1.0)
|
328
|
-
thread_safe (0.3.6)
|
329
349
|
tilt (2.0.10)
|
330
350
|
turbo-rails (0.5.9)
|
331
351
|
rails (>= 6.0.0)
|
332
|
-
tzinfo (
|
333
|
-
|
352
|
+
tzinfo (2.0.4)
|
353
|
+
concurrent-ruby (~> 1.0)
|
334
354
|
unicode-display_width (2.0.0)
|
335
355
|
unicode_utils (1.4.0)
|
336
|
-
view_component (2.
|
356
|
+
view_component (2.33.0)
|
337
357
|
activesupport (>= 5.0.0, < 7.0)
|
338
358
|
warden (1.2.9)
|
339
359
|
rack (>= 2.0.9)
|
340
|
-
web-console (4.0
|
360
|
+
web-console (4.1.0)
|
341
361
|
actionview (>= 6.0.0)
|
342
362
|
activemodel (>= 6.0.0)
|
343
363
|
bindex (>= 0.4.0)
|
@@ -355,7 +375,7 @@ GEM
|
|
355
375
|
rack-proxy (>= 0.6.1)
|
356
376
|
railties (>= 5.2)
|
357
377
|
semantic_range (>= 2.3.0)
|
358
|
-
websocket-driver (0.7.
|
378
|
+
websocket-driver (0.7.4)
|
359
379
|
websocket-extensions (>= 0.1.0)
|
360
380
|
websocket-extensions (0.1.5)
|
361
381
|
xpath (3.2.0)
|
@@ -371,6 +391,7 @@ DEPENDENCIES
|
|
371
391
|
addressable
|
372
392
|
appraisal
|
373
393
|
avo!
|
394
|
+
aws-sdk-s3
|
374
395
|
bootsnap (>= 1.4.2)
|
375
396
|
breadcrumbs_on_rails
|
376
397
|
bump
|
@@ -396,7 +417,7 @@ DEPENDENCIES
|
|
396
417
|
pg (>= 0.18, < 2.0)
|
397
418
|
puma (~> 5.3.1)
|
398
419
|
pundit
|
399
|
-
rails (~> 6.
|
420
|
+
rails (~> 6.1.0)
|
400
421
|
rails-controller-testing
|
401
422
|
ransack
|
402
423
|
rspec-rails (~> 4.0.0)
|
data/README.md
CHANGED
@@ -56,6 +56,6 @@ $ bundle install
|
|
56
56
|
|
57
57
|
Please read [CONTRIBUTING.MD](./CONTRIBUTING.MD)
|
58
58
|
|
59
|
-
# Upgrade
|
59
|
+
# Upgrade Guide
|
60
60
|
|
61
|
-
Please read the [UPGRADE_GUIDE.MD](https://docs.avohq.io/0
|
61
|
+
Please read the [UPGRADE_GUIDE.MD](https://docs.avohq.io/1.0/upgrade.html)
|
@@ -1,7 +1,7 @@
|
|
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
2
|
<div class="h-16 flex self-start items-center text-blue-gray-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
|
-
<%= @form.label @field.id,
|
4
|
+
<%= @form.label @field.id, label %> <% if @field.required %> <span class="text-red-600">*</span> <% end %>
|
5
5
|
</div>
|
6
6
|
</div>
|
7
7
|
<div class="flex-1 flex flex-row min-h-inherit">
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class Avo::Edit::FieldWrapperComponent < ViewComponent::Base
|
4
|
-
def initialize(field: nil, dash_if_blank: true, full_width: false, displayed_in_modal: false, form: nil, resource: {}, **args)
|
4
|
+
def initialize(field: nil, dash_if_blank: true, full_width: false, displayed_in_modal: false, form: nil, resource: {}, label: nil, **args)
|
5
5
|
@field = field
|
6
6
|
@dash_if_blank = dash_if_blank
|
7
7
|
@classes = args[:class].present? ? args[:class] : ""
|
@@ -11,9 +11,14 @@ class Avo::Edit::FieldWrapperComponent < ViewComponent::Base
|
|
11
11
|
@resource = resource
|
12
12
|
@model = resource.present? ? resource.model : nil
|
13
13
|
@full_width = full_width
|
14
|
+
@label = label
|
14
15
|
|
15
16
|
if (@index != 0) || @displayed_in_modal
|
16
17
|
@classes += " border-t"
|
17
18
|
end
|
18
19
|
end
|
20
|
+
|
21
|
+
def label
|
22
|
+
@label || @field.name
|
23
|
+
end
|
19
24
|
end
|
@@ -1,18 +1,68 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
1
|
+
<% if @field.types.present? %>
|
2
|
+
<div data-controller="belongs-to-field">
|
3
|
+
<%= edit_field_wrapper field: @field, index: @index, form: @form, resource: @resource, displayed_in_modal: @displayed_in_modal do %>
|
4
|
+
<%= @form.select "#{@field.foreign_key}_type", @field.types.map { |type| [type.to_s.underscore.humanize, type.to_s] },
|
5
|
+
{
|
6
|
+
include_blank: @field.placeholder,
|
7
|
+
},
|
8
|
+
{
|
9
|
+
class: helpers.input_classes('w-full', has_error: @field.model_errors.include?(@field.id)),
|
10
|
+
disabled: disabled,
|
11
|
+
'data-belongs-to-field-target': "select",
|
12
|
+
'data-action': 'change->belongs-to-field#changedType'
|
13
|
+
}
|
14
|
+
%>
|
15
|
+
<%
|
16
|
+
# If the select field is disabled, no value will be sent. It's how HTML works.
|
17
|
+
# Thus the extra hidden field to actually send the related id to the server.
|
18
|
+
if disabled
|
19
|
+
%>
|
20
|
+
<%= @form.hidden_field "#{@field.foreign_key}_type" %>
|
21
|
+
<% end %>
|
22
|
+
<% end %>
|
23
|
+
<% @field.types.each do |type| %>
|
24
|
+
<div class="hidden"
|
25
|
+
data-belongs-to-field-target="type"
|
26
|
+
data-type="<%= type %>"
|
27
|
+
>
|
28
|
+
<%= edit_field_wrapper field: @field, index: @index, form: @form, resource: @resource, displayed_in_modal: @displayed_in_modal, label: type.to_s.underscore.humanize do %>
|
29
|
+
<%= @form.select "#{@field.foreign_key}_id", @field.values_for_type(type),
|
30
|
+
{
|
31
|
+
include_blank: @field.placeholder,
|
32
|
+
},
|
33
|
+
{
|
34
|
+
class: helpers.input_classes('w-full', has_error: @field.model_errors.include?(@field.id)),
|
35
|
+
disabled: disabled
|
36
|
+
}
|
37
|
+
%>
|
38
|
+
<%
|
39
|
+
# If the select field is disabled, no value will be sent. It's how HTML works.
|
40
|
+
# Thus the extra hidden field to actually send the related id to the server.
|
41
|
+
if disabled
|
42
|
+
%>
|
43
|
+
<%= @form.hidden_field "#{@field.foreign_key}_id" %>
|
44
|
+
<% end %>
|
45
|
+
<% end %>
|
46
|
+
</div>
|
47
|
+
<% end %>
|
48
|
+
</div>
|
49
|
+
<% else %>
|
50
|
+
<%= edit_field_wrapper field: @field, index: @index, form: @form, resource: @resource, displayed_in_modal: @displayed_in_modal do %>
|
51
|
+
<%= @form.select @field.foreign_key, @field.options.map { |o| [o[:label], o[:value]] },
|
52
|
+
{
|
53
|
+
include_blank: @field.placeholder,
|
54
|
+
},
|
55
|
+
{
|
56
|
+
class: helpers.input_classes('w-full', has_error: @field.model_errors.include?(@field.id)),
|
57
|
+
disabled: disabled
|
58
|
+
}
|
59
|
+
%>
|
60
|
+
<%
|
61
|
+
# If the select field is disabled, no value will be sent. It's how HTML works.
|
62
|
+
# Thus the extra hidden field to actually send the related id to the server.
|
63
|
+
if disabled
|
10
64
|
%>
|
11
|
-
|
12
|
-
|
13
|
-
# Thus the extra hidden field to actually send the related id to the server.
|
14
|
-
if disabled
|
15
|
-
%>
|
16
|
-
<%= @form.hidden_field @field.foreign_key %>
|
65
|
+
<%= @form.hidden_field @field.foreign_key %>
|
66
|
+
<% end %>
|
17
67
|
<% end %>
|
18
68
|
<% end %>
|
@@ -3,7 +3,7 @@
|
|
3
3
|
class Avo::Fields::BelongsToField::EditComponent < Avo::Fields::EditComponent
|
4
4
|
def disabled
|
5
5
|
return true if @field.readonly
|
6
|
-
return true if @field.target_resource.model_class.name == params[:via_resource_class]
|
6
|
+
return true if @field.target_resource.present? && @field.target_resource.model_class.name == params[:via_resource_class]
|
7
7
|
return true if @field.id.to_s == params[:via_relation].to_s
|
8
8
|
|
9
9
|
false
|
@@ -17,7 +17,7 @@
|
|
17
17
|
<%= a_link helpers.main_app.url_for(@file), color: 'indigo', download: true, class: 'text-center', size: :xs do %>
|
18
18
|
<%= helpers.svg 'download' %> <span class="hidden lg:block lg:flex-1"><%= t('avo.download_file') %></span>
|
19
19
|
<% end %>
|
20
|
-
<%= a_link "#{Avo.
|
20
|
+
<%= a_link "#{Avo::App.root_path}/resources/#{@resource.model.model_name.route_key}/#{@resource.model.id
|
21
21
|
}/active_storage_attachments/#{@id}/#{@file.id}", color: :red, variant: :outlined, size: :xs, class: 'text-center', 'data-turbo-frame': 'destroy_attachment_form', data: { confirm: t('avo.are_you_sure')} do %>
|
22
22
|
<%= helpers.svg 'trash' %> <span class="hidden lg:block lg:flex-1"><%= t 'avo.delete_file', item: @file.filename %></span>
|
23
23
|
<% end %>
|