avo 3.5.8 → 3.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a39429d6be1a1dfcd0f353896f3eec3cf894d03cdd3aa19ddb7353cf13535f9f
4
- data.tar.gz: 19d1c9bedadc87f54cc9601d11732706684b890097e712f4d462e46a86b4aca6
3
+ metadata.gz: 9bcdaff03547e43800f1385ad2d3d328aa3017d453652e34b71e8b6ace66ed25
4
+ data.tar.gz: 811b6c854c53e4e04cfa91d4b0e8dc3881e8dc7f37578844f4f75db256d6be2d
5
5
  SHA512:
6
- metadata.gz: 7af08e4b3b0682c3ddaa7a407e13ccd06de87aa2b3e28b2c62a99373714a668a4832ebf57f4afa7a91c5878bd8a8c87e175ac4077476384812ed3936f38af77a
7
- data.tar.gz: 228d061f6acfb8cce03d06ab8fe8b98178bb7aa3da1e7e717036aa4f4f347b075f27cb4770ae8adb09927f33cf48f884bf636fdc87ef974cd2c5928fff8fa4e8
6
+ metadata.gz: 550010a6c01e74234df0c8d379b56f3f7412ee654a8941e137eafc91ea6dac0b6c6430c597a6e2d4554fc5045501e6a5f026e856ec85a4e93379db5a895554f2
7
+ data.tar.gz: 284d0e648c29f6c4acbaccbccd24e915684e629278243f3bbed95f305a93b7b8ef9853c10ebddcd21af8cf9f00416c7a895bae466af7329aa6ff3d03a128d848
data/Gemfile CHANGED
@@ -75,6 +75,7 @@ group :development do
75
75
  gem "rubocop"
76
76
  gem "ripper-tags"
77
77
  gem "rubocop-shopify", require: false
78
+ gem "rubycritic", require: false
78
79
  end
79
80
 
80
81
  group :test do
@@ -152,7 +153,7 @@ gem "activestorage"
152
153
  # Required by Avo
153
154
  gem "sprockets-rails"
154
155
 
155
- # Avo file filed requires this gem
156
+ # Avo file field requires this gem
156
157
  # Use Active Storage variant
157
158
  gem "image_processing", "~> 1.12"
158
159
 
@@ -164,3 +165,8 @@ gem "prefixed_ids"
164
165
  gem "mapkick-rb", "~> 0.1.4"
165
166
 
166
167
  gem "pluggy", path: "./pluggy"
168
+
169
+ # Avo money field
170
+ # gem "avo-money_field", path: "./../avo-money_field"
171
+ gem "money-rails", "~> 1.12"
172
+ gem "avo-money_field"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- avo (3.5.8)
4
+ avo (3.6.1)
5
5
  actionview (>= 6.1)
6
6
  active_link_to
7
7
  activerecord (>= 6.1)
@@ -119,6 +119,8 @@ GEM
119
119
  rake
120
120
  thor (>= 0.14.0)
121
121
  ast (2.4.2)
122
+ avo-money_field (0.0.4)
123
+ money-rails (~> 1.12)
122
124
  awesome_print (1.9.2)
123
125
  aws-eventstream (1.3.0)
124
126
  aws-partitions (1.888.0)
@@ -136,6 +138,10 @@ GEM
136
138
  aws-sigv4 (~> 1.8)
137
139
  aws-sigv4 (1.8.0)
138
140
  aws-eventstream (~> 1, >= 1.0.2)
141
+ axiom-types (0.1.1)
142
+ descendants_tracker (~> 0.0.4)
143
+ ice_nine (~> 0.11.0)
144
+ thread_safe (~> 0.3, >= 0.3.1)
139
145
  backport (1.2.0)
140
146
  base64 (0.2.0)
141
147
  bcrypt (3.1.20)
@@ -147,7 +153,7 @@ GEM
147
153
  erubi (~> 1.4)
148
154
  parser (>= 2.4)
149
155
  smart_properties
150
- bigdecimal (3.1.6)
156
+ bigdecimal (3.1.7)
151
157
  bindex (0.8.1)
152
158
  bootsnap (1.18.3)
153
159
  msgpack (~> 1.2)
@@ -165,6 +171,8 @@ GEM
165
171
  regexp_parser (>= 1.5, < 3.0)
166
172
  xpath (~> 3.2)
167
173
  chartkick (5.0.5)
174
+ coercible (1.0.0)
175
+ descendants_tracker (~> 0.0.1)
168
176
  concurrent-ruby (1.2.3)
169
177
  connection_pool (2.4.1)
170
178
  countries (5.7.1)
@@ -183,6 +191,8 @@ GEM
183
191
  database_cleaner-core (~> 2.0.0)
184
192
  database_cleaner-core (2.0.1)
185
193
  date (3.3.4)
194
+ descendants_tracker (0.0.4)
195
+ thread_safe (~> 0.3, >= 0.3.1)
186
196
  devise (4.9.3)
187
197
  bcrypt (~> 3.0)
188
198
  orm_adapter (~> 0.1)
@@ -195,9 +205,34 @@ GEM
195
205
  dotenv-rails (2.8.1)
196
206
  dotenv (= 2.8.1)
197
207
  railties (>= 3.2)
198
- drb (2.2.0)
199
- ruby2_keywords
208
+ drb (2.2.1)
209
+ dry-configurable (1.1.0)
210
+ dry-core (~> 1.0, < 2)
211
+ zeitwerk (~> 2.6)
212
+ dry-core (1.0.1)
213
+ concurrent-ruby (~> 1.0)
214
+ zeitwerk (~> 2.6)
215
+ dry-inflector (1.0.0)
200
216
  dry-initializer (3.1.1)
217
+ dry-logic (1.5.0)
218
+ concurrent-ruby (~> 1.0)
219
+ dry-core (~> 1.0, < 2)
220
+ zeitwerk (~> 2.6)
221
+ dry-schema (1.13.3)
222
+ concurrent-ruby (~> 1.0)
223
+ dry-configurable (~> 1.0, >= 1.0.1)
224
+ dry-core (~> 1.0, < 2)
225
+ dry-initializer (~> 3.0)
226
+ dry-logic (>= 1.4, < 2)
227
+ dry-types (>= 1.7, < 2)
228
+ zeitwerk (~> 2.6)
229
+ dry-types (1.7.2)
230
+ bigdecimal (~> 3.0)
231
+ concurrent-ruby (~> 1.0)
232
+ dry-core (~> 1.0)
233
+ dry-inflector (~> 1.0)
234
+ dry-logic (~> 1.4)
235
+ zeitwerk (~> 2.6)
201
236
  e2mmap (0.1.0)
202
237
  erb-formatter (0.7.1)
203
238
  syntax_tree (~> 6.0)
@@ -215,6 +250,15 @@ GEM
215
250
  webrick (~> 1.7)
216
251
  websocket-driver (>= 0.6, < 0.8)
217
252
  ffi (1.16.3)
253
+ flay (2.13.2)
254
+ erubi (~> 1.10)
255
+ path_expander (~> 1.0)
256
+ ruby_parser (~> 3.0)
257
+ sexp_processor (~> 4.0)
258
+ flog (4.8.0)
259
+ path_expander (~> 1.0)
260
+ ruby_parser (~> 3.1, > 3.1.0)
261
+ sexp_processor (~> 4.8)
218
262
  friendly_id (5.5.1)
219
263
  activerecord (>= 4.0.0)
220
264
  fuubar (2.5.1)
@@ -238,7 +282,7 @@ GEM
238
282
  httparty (0.21.0)
239
283
  mini_mime (>= 1.0.0)
240
284
  multi_xml (>= 0.5.2)
241
- i18n (1.14.1)
285
+ i18n (1.14.4)
242
286
  concurrent-ruby (~> 1.0)
243
287
  i18n-tasks (1.0.13)
244
288
  activesupport (>= 4.0.2)
@@ -251,6 +295,7 @@ GEM
251
295
  rails-i18n
252
296
  rainbow (>= 2.2.2, < 4.0)
253
297
  terminal-table (>= 1.5.1)
298
+ ice_nine (0.11.2)
254
299
  image_processing (1.12.2)
255
300
  mini_magick (>= 4.9.5, < 5)
256
301
  ruby-vips (>= 2.0.17, < 3)
@@ -258,7 +303,7 @@ GEM
258
303
  activesupport (>= 3.0)
259
304
  nokogiri (>= 1.6)
260
305
  io-console (0.7.2)
261
- irb (1.11.2)
306
+ irb (1.12.0)
262
307
  rdoc
263
308
  reline (>= 0.4.2)
264
309
  iso (0.4.0)
@@ -296,7 +341,16 @@ GEM
296
341
  mini_magick (4.12.0)
297
342
  mini_mime (1.1.5)
298
343
  mini_portile2 (2.8.5)
299
- minitest (5.22.2)
344
+ minitest (5.22.3)
345
+ monetize (1.13.0)
346
+ money (~> 6.12)
347
+ money (6.19.0)
348
+ i18n (>= 0.6.4, <= 2)
349
+ money-rails (1.15.0)
350
+ activesupport (>= 3.0)
351
+ monetize (~> 1.9)
352
+ money (~> 6.13)
353
+ railties (>= 3.0)
300
354
  msgpack (1.7.2)
301
355
  multi_xml (0.6.0)
302
356
  mutex_m (0.2.0)
@@ -310,10 +364,10 @@ GEM
310
364
  net-smtp (0.4.0.1)
311
365
  net-protocol
312
366
  nio4r (2.7.0)
313
- nokogiri (1.16.2)
367
+ nokogiri (1.16.3)
314
368
  mini_portile2 (~> 2.8.2)
315
369
  racc (~> 1.4)
316
- nokogiri (1.16.2-x86_64-linux)
370
+ nokogiri (1.16.3-x86_64-linux)
317
371
  racc (~> 1.4)
318
372
  orm_adapter (0.5.0)
319
373
  pagy (7.0.6)
@@ -321,6 +375,7 @@ GEM
321
375
  parser (3.3.0.5)
322
376
  ast (~> 2.4.1)
323
377
  racc
378
+ path_expander (1.1.1)
324
379
  pg (1.5.4)
325
380
  prefixed_ids (1.6.1)
326
381
  hashids (>= 1.0.0, < 2.0.0)
@@ -332,7 +387,7 @@ GEM
332
387
  puma (6.4.2)
333
388
  nio4r (~> 2.0)
334
389
  racc (1.7.3)
335
- rack (3.0.9.1)
390
+ rack (3.0.10)
336
391
  rack-session (2.0.0)
337
392
  rack (>= 3.0.0)
338
393
  rack-test (2.1.0)
@@ -377,7 +432,7 @@ GEM
377
432
  thor (~> 1.0, >= 1.2.2)
378
433
  zeitwerk (~> 2.6)
379
434
  rainbow (3.1.1)
380
- rake (13.1.0)
435
+ rake (13.2.1)
381
436
  ransack (4.1.1)
382
437
  activerecord (>= 6.1.5)
383
438
  activesupport (>= 6.1.5)
@@ -392,8 +447,13 @@ GEM
392
447
  redis-client (>= 0.17.0)
393
448
  redis-client (0.19.1)
394
449
  connection_pool
450
+ reek (6.3.0)
451
+ dry-schema (~> 1.13.0)
452
+ parser (~> 3.3.0)
453
+ rainbow (>= 2.0, < 4.0)
454
+ rexml (~> 3.1)
395
455
  regexp_parser (2.9.0)
396
- reline (0.4.3)
456
+ reline (0.5.1)
397
457
  io-console (~> 0.5)
398
458
  responders (3.1.1)
399
459
  actionpack (>= 5.2)
@@ -442,7 +502,22 @@ GEM
442
502
  ruby-progressbar (1.13.0)
443
503
  ruby-vips (2.2.0)
444
504
  ffi (~> 1.12)
445
- ruby2_keywords (0.0.5)
505
+ ruby_parser (3.21.0)
506
+ racc (~> 1.5)
507
+ sexp_processor (~> 4.16)
508
+ rubycritic (4.9.0)
509
+ flay (~> 2.13)
510
+ flog (~> 4.7)
511
+ launchy (>= 2.5.2)
512
+ parser (>= 3.2.2.1)
513
+ rainbow (~> 3.1.1)
514
+ reek (~> 6.0, < 7.0)
515
+ rexml
516
+ ruby_parser (~> 3.20)
517
+ simplecov (>= 0.22.0)
518
+ tty-which (~> 0.5.0)
519
+ virtus (~> 2.0)
520
+ sexp_processor (4.17.1)
446
521
  simplecov (0.22.0)
447
522
  docile (~> 1.1)
448
523
  simplecov-html (~> 0.11)
@@ -501,9 +576,11 @@ GEM
501
576
  terminal-table (3.0.2)
502
577
  unicode-display_width (>= 1.1.1, < 3)
503
578
  test-prof (1.3.1)
504
- thor (1.3.0)
579
+ thor (1.3.1)
580
+ thread_safe (0.3.6)
505
581
  tilt (2.3.0)
506
582
  timeout (0.4.1)
583
+ tty-which (0.5.0)
507
584
  turbo-rails (2.0.1)
508
585
  actionpack (>= 6.0.0)
509
586
  activejob (>= 6.0.0)
@@ -518,6 +595,10 @@ GEM
518
595
  activesupport (>= 5.2.0, < 8.0)
519
596
  concurrent-ruby (~> 1.0)
520
597
  method_source (~> 1.0)
598
+ virtus (2.0.0)
599
+ axiom-types (~> 0.1)
600
+ coercible (~> 1.0)
601
+ descendants_tracker (~> 0.0, >= 0.0.3)
521
602
  warden (1.2.9)
522
603
  rack (>= 2.0.9)
523
604
  web-console (4.2.1)
@@ -552,6 +633,7 @@ DEPENDENCIES
552
633
  annotate
553
634
  appraisal
554
635
  avo!
636
+ avo-money_field
555
637
  awesome_print
556
638
  aws-sdk-s3
557
639
  bootsnap (>= 1.4.2)
@@ -585,6 +667,7 @@ DEPENDENCIES
585
667
  listen (>= 3.5.1)
586
668
  mapkick-rb (~> 0.1.4)
587
669
  meta-tags
670
+ money-rails (~> 1.12)
588
671
  net-smtp
589
672
  pg (>= 0.18, < 2.0)
590
673
  pluggy!
@@ -599,6 +682,7 @@ DEPENDENCIES
599
682
  rspec-retry (~> 0.6.2)
600
683
  rubocop
601
684
  rubocop-shopify
685
+ rubycritic
602
686
  simplecov
603
687
  simplecov-cobertura
604
688
  simplecov-lcov
@@ -1,5 +1,5 @@
1
1
  <% if @field.value %>
2
- <turbo-frame id="<%= @field.turbo_frame %>" src="<%= @field.frame_url %>" loading=<%= turbo_frame_loading %> target="_top" class="block">
2
+ <turbo-frame id="<%= @field.turbo_frame %>" src="<%= @field.frame_url %>" loading=<%= turbo_frame_loading %> target="_top" class="block">
3
3
  <%= render(Avo::LoadingComponent.new(title: @field.name)) %>
4
4
  </turbo-frame>
5
5
  <% else %>
@@ -10,7 +10,7 @@ class Avo::Fields::HasOneField::ShowComponent < Avo::Fields::ShowComponent
10
10
  if @field.present?
11
11
  reflection_resource = @field.target_resource
12
12
  if reflection_resource.present? && @resource.present?
13
- method_name = "attach_#{@field.id}?".to_sym
13
+ method_name = :"attach_#{@field.id}?"
14
14
 
15
15
  if @resource.authorization.has_method?(method_name, raise_exception: false)
16
16
  policy_result = @resource.authorization.authorize_action(method_name, raise_exception: false)
@@ -1,31 +1,33 @@
1
1
  <%= content_tag :div, data: data_attributes, class: classes do %>
2
2
  <% if render_header? %>
3
- <div data-target="panel-header" class="flex-1 flex flex-col xl:flex-row justify-between mb-4">
4
- <div class="overflow-hidden flex flex-col">
5
- <% if display_breadcrumbs? %>
6
- <div class="breadcrumbs truncate mb-2">
7
- <%= helpers.render_avo_breadcrumbs(separator: helpers.svg('chevron-right', class: 'inline-block h-3 stroke-current relative top-[-1px] ml-1' )) if Avo.configuration.display_breadcrumbs %>
8
- </div>
9
- <% end %>
10
- <div class="text-2xl tracking-normal font-semibold text-gray-800 truncate items-center flex flex-1" data-target="title">
11
- <span><%= @name %></span>
12
- <% if @reloadable %>
13
- <%= button_tag data: { controller: "panel-refresh", action: "click->panel-refresh#refresh" } do %>
14
- <%= svg "heroicons/outline/arrow-path", class: "ml-2 text-2xl h-6 " %>
3
+ <div data-target="panel-header" class="mb-4">
4
+ <% if display_breadcrumbs? %>
5
+ <div class="breadcrumbs mb-2">
6
+ <%= helpers.render_avo_breadcrumbs(separator: helpers.svg('chevron-right', class: 'inline-block h-3 stroke-current relative top-[-1px] ml-1' )) if Avo.configuration.display_breadcrumbs %>
7
+ </div>
8
+ <% end %>
9
+ <div class="flex-1 flex flex-col xl:flex-row justify-between gap-1">
10
+ <div class="overflow-hidden flex flex-col">
11
+ <div class="text-2xl tracking-normal font-semibold text-gray-800 items-center flex flex-1" data-target="title">
12
+ <span><%= @name %></span>
13
+ <% if @reloadable %>
14
+ <%= button_tag data: { controller: "panel-refresh", action: "click->panel-refresh#refresh" } do %>
15
+ <%= svg "heroicons/outline/arrow-path", class: "ml-2 text-2xl h-6 " %>
16
+ <% end %>
15
17
  <% end %>
18
+ </div>
19
+ <% if description.present? %>
20
+ <div class="text-sm tracking-normal font-medium text-gray-600" data-target="description">
21
+ <%== description %>
22
+ </div>
16
23
  <% end %>
17
24
  </div>
18
- <% if description.present? %>
19
- <div class="text-sm tracking-normal font-medium text-gray-600" data-target="description">
20
- <%== description %>
25
+ <% if tools.present? %>
26
+ <div class="flex-1 w-full flex flex-col sm:flex-row xl:justify-end sm:items-end gap-2 mt-4 xl:mt-0" data-target="panel-tools">
27
+ <%= tools %>
21
28
  </div>
22
29
  <% end %>
23
30
  </div>
24
- <% if tools.present? %>
25
- <div class="flex-1 w-full flex flex-wrap flex-col sm:flex-row xl:justify-end sm:items-end gap-2 mt-4 xl:mt-0" data-target="panel-tools">
26
- <%= tools %>
27
- </div>
28
- <% end %>
29
31
  </div>
30
32
  <% end %>
31
33
  <% if body? %>
@@ -12,6 +12,8 @@ module Avo
12
12
  before_action :set_action, only: [:show, :handle]
13
13
  before_action :verify_authorization, only: [:show, :handle]
14
14
 
15
+ layout "avo/blank"
16
+
15
17
  def show
16
18
  # Se the view to :new so the default value gets prefilled
17
19
  @view = Avo::ViewInquirer.new("new")
@@ -51,6 +51,10 @@ module Avo
51
51
  super
52
52
  end
53
53
 
54
+ def hello
55
+ puts "Nobody tested me :("
56
+ end
57
+
54
58
  private
55
59
 
56
60
  # Get the pluralized resource name for this request
@@ -142,7 +146,13 @@ module Avo
142
146
  end
143
147
 
144
148
  def set_record
145
- @record = @resource.find_record(params[:id], query: model_scope, params: params)
149
+ id = if @resource.model_class.primary_key.is_a?(Array) && params.respond_to?(:extract_value)
150
+ params.extract_value(:id)
151
+ else
152
+ params[:id]
153
+ end
154
+
155
+ @record = @resource.find_record(id, query: model_scope, params:)
146
156
  @resource.hydrate(record: @record)
147
157
  end
148
158
 
@@ -16,6 +16,8 @@ module Avo
16
16
  before_action :authorize_attach_action, only: :new
17
17
  before_action :authorize_detach_action, only: :destroy
18
18
 
19
+ layout "avo/blank"
20
+
19
21
  def index
20
22
  @parent_resource = @resource.dup
21
23
  @resource = @related_resource
@@ -63,7 +65,7 @@ module Avo
63
65
  if reflection_class == "HasManyReflection"
64
66
  @record.send(association_name) << @attachment_record
65
67
  else
66
- @record.send("#{association_name}=", @attachment_record)
68
+ @record.send(:"#{association_name}=", @attachment_record)
67
69
  end
68
70
 
69
71
  respond_to do |format|
@@ -516,7 +516,7 @@ module Avo
516
516
  redirect_path_from_resource_option(:after_update_path) || resource_view_response_path
517
517
  end
518
518
 
519
- # Needs a different name, otwherwise, in some places, this can be called instead helpers.resource_view_path
519
+ # Requires a different/special name, otherwise, in some places, this can be called instead helpers.resource_view_path
520
520
  def resource_view_response_path
521
521
  helpers.resource_view_path(record: @record, resource: @resource)
522
522
  end
@@ -81,7 +81,7 @@ module Avo
81
81
  rescue
82
82
  end
83
83
 
84
- avo.resources_associations_index_path(parent_record.model_name.route_key, record.id, **existing_params, **args)
84
+ avo.resources_associations_index_path(parent_record.model_name.route_key, record.to_param, **existing_params, **args)
85
85
  end
86
86
 
87
87
  def resource_view_path(**args)
@@ -41,7 +41,7 @@
41
41
  </div>
42
42
 
43
43
  <% c.with_controls do %>
44
- <%= a_button 'data-action': 'click->modal#close', size: :sm, style: :outline, color: :gray do %>
44
+ <%= a_button 'data-action': 'click->modal#close', type: :button, size: :sm, style: :outline, color: :gray do %>
45
45
  <%= t('avo.cancel') %>
46
46
  <% end %>
47
47
  <%= a_button type: :submit, style: :primary, color: :green, size: :sm do %>
@@ -0,0 +1,9 @@
1
+ <%= turbo_frame_tag :alerts, class: "fixed inset-0 bottom-0 flex flex-col space-y-4 items-end justify-right px-4 py-6 sm:p-6 justify-end z-[100] pointer-events-none" do %>
2
+ <%= render Avo::FlashAlertsComponent.new flashes: flash %>
3
+ <% # In case we have other general error messages %>
4
+ <% if @errors.present? %>
5
+ <% @errors.each do |message| %>
6
+ <%= render Avo::AlertComponent.new :error, message %>
7
+ <% end %>
8
+ <% end %>
9
+ <% end %>
@@ -0,0 +1 @@
1
+ <%= turbo_frame_tag 'attach_modal' %>
@@ -51,17 +51,9 @@
51
51
  </div>
52
52
  </div>
53
53
  <%= turbo_frame_tag Avo::ACTIONS_TURBO_FRAME_ID, data: {turbo_temporary: 1} %>
54
- <%= turbo_frame_tag 'attach_modal' %>
55
- <%= turbo_frame_tag 'alerts', class: "fixed inset-0 bottom-0 flex flex-col space-y-4 items-end justify-right px-4 py-6 sm:p-6 justify-end z-[100] pointer-events-none" do %>
56
- <%= render Avo::FlashAlertsComponent.new flashes: flash %>
57
- <% # In case we have other general error messages %>
58
- <% if @errors.present? %>
59
- <% @errors.each do |message| %>
60
- <%= render Avo::AlertComponent.new :error, message %>
61
- <% end %>
62
- <% end %>
63
- <% end %>
64
- <%= render partial: "avo/partials/scripts" %>
54
+ <%= render partial: 'avo/partials/attach_modal' %>
55
+ <%= render partial: 'avo/partials/alerts' %>
56
+ <%= render partial: 'avo/partials/scripts' %>
65
57
  <!-- Avo version: <%= Avo::VERSION %> -->
66
58
  <!-- Environment: <%= Rails.env %> -->
67
59
  <!-- License ID: <%= Avo.license.id %> -->
@@ -3,5 +3,6 @@
3
3
  <html>
4
4
  <body>
5
5
  <%= yield.force_encoding('UTF-8') %>
6
+ <%= render partial: 'avo/partials/alerts' %>
6
7
  </body>
7
8
  </html>
@@ -274,7 +274,7 @@ module Avo
274
274
  item.is_heading? ||
275
275
  item.is_a?(Avo::Fields::LocationField)
276
276
 
277
- item.resource.record.respond_to?("#{item.id}=")
277
+ item.resource.record.respond_to?(:"#{item.id}=")
278
278
  end
279
279
  .select do |item|
280
280
  # Check if the user is authorized to view it.
@@ -267,10 +267,10 @@ module Avo
267
267
 
268
268
  # Used by Avo to fill the record with the default value on :new and :edit views
269
269
  def assign_value(record:, value:)
270
- id = type == "belongs_to" ? foreign_key : database_id
270
+ id = (type == "belongs_to") ? foreign_key : database_id
271
271
 
272
272
  if record.send(id).nil?
273
- record.send("#{id}=", value)
273
+ record.send(:"#{id}=", value)
274
274
  end
275
275
  end
276
276
 
@@ -29,7 +29,7 @@ module Avo
29
29
  view: view
30
30
  ).handle
31
31
 
32
- component_class = custom_components.dig("#{view}_component".to_sym) || "#{view_component_namespace}::#{view.to_s.camelize}Component"
32
+ component_class = custom_components.dig(:"#{view}_component") || "#{view_component_namespace}::#{view.to_s.camelize}Component"
33
33
  component_class.to_s.constantize
34
34
  rescue
35
35
  unless Rails.env.test?
@@ -44,12 +44,20 @@ module Avo
44
44
  end
45
45
  end
46
46
 
47
- def load_field(method_name, klass)
47
+ def load_field(name, klass)
48
+ return if field_exists?(name)
49
+
48
50
  fields.push(
49
- name: method_name.to_s,
51
+ name: name.to_s,
50
52
  class: klass
51
53
  )
52
54
  end
55
+
56
+ private
57
+
58
+ def field_exists?(name)
59
+ fields.pluck(:name).map(&:to_sym).include?(name.to_sym)
60
+ end
53
61
  end
54
62
  end
55
63
  end
@@ -83,7 +83,7 @@ module Avo
83
83
  def component_for_view(view = Avo::ViewInquirer.new("index"))
84
84
  view = Avo::ViewInquirer.new("show") if view.in? %w[new create update edit]
85
85
 
86
- super view
86
+ super(view)
87
87
  end
88
88
 
89
89
  def authorized?
@@ -33,7 +33,7 @@ module Avo
33
33
  related_record = related_resource.find_record value
34
34
  end
35
35
 
36
- model.public_send("#{key}=", related_record)
36
+ model.public_send(:"#{key}=", related_record)
37
37
 
38
38
  model
39
39
  end
data/lib/avo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "3.5.8" unless const_defined?(:VERSION)
2
+ VERSION = "3.6.1" unless const_defined?(:VERSION)
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avo
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.8
4
+ version: 3.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Marin
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2024-04-05 00:00:00.000000000 Z
13
+ date: 2024-04-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord
@@ -2126,6 +2126,8 @@ files:
2126
2126
  - app/views/avo/home/_resources.html.erb
2127
2127
  - app/views/avo/home/failed_to_load.html.erb
2128
2128
  - app/views/avo/home/index.html.erb
2129
+ - app/views/avo/partials/_alerts.html.erb
2130
+ - app/views/avo/partials/_attach_modal.html.erb
2129
2131
  - app/views/avo/partials/_branding.html.erb
2130
2132
  - app/views/avo/partials/_custom_tools_alert.html.erb
2131
2133
  - app/views/avo/partials/_footer.html.erb