glib-web 3.16.0 → 3.16.2

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: 3b8f74c09536b2840e41346cfef87cfe84896e61b4985ee60d45f576ddaf772d
4
- data.tar.gz: f6f245a390e234a5910803043074638d9e55d72a4fc2c29eb07b570bee810bcb
3
+ metadata.gz: 6d5b87ed40b6899921ff69c27b36f7a7fdbd5bda372cc66e862fa118e5b3829e
4
+ data.tar.gz: d48ca7297c13cb43a969e274bf3090cd72bfed50dda1fa150de961db3cb53dfa
5
5
  SHA512:
6
- metadata.gz: 07e4d74b157ba6ca4ffd1021806ab589c54750ee308901edb249ecf5af6a2c97ea50c2a779c516ef905751a4bb255a2101e054dfda3de2431749bc4057f0a768
7
- data.tar.gz: d09d737aff6ddd5938e01d9ef4960ce0106a77cac80d5ca418d4ae8edddac79b9cd69da3d138f751e66f7aea4afa8b2a32a1b4c5d0ece72622739deb0902937b
6
+ metadata.gz: 93ec58c318c1568c69dcd7007b1cff9effd8a7048e885cf10df17c3065c7ad64d37220d8c30e9a44af01d592664f18d617832da3b88297e779893954f6aa95aa
7
+ data.tar.gz: 1aecb33728606c762df28283bfab3b21399748f27b9a709158a13859e8cd147031eee7cdfd71ada6d10f56fe13450f8f1615f175fb1648363fefbc03402dcec9
@@ -311,11 +311,13 @@ class Glib::JsonUi::ViewBuilder
311
311
  json.hint @hint if @hint
312
312
 
313
313
  if @prop && (form = page.current_form)
314
- model = form.instance_variable_get(:@model)
315
- @files ||= model.send(@prop).to_a.map { |file| { name: file.blob&.filename, signed_id: file.signed_id } }
314
+ association = form.nested_associations.last
315
+ context = association || form
316
316
 
317
- json.files @files if @files.present?
317
+ @files ||= context.field_value(@prop, collect_ids: false).to_a.map { |file| { name: file.blob&.filename, signed_id: file.signed_id } }
318
318
  end
319
+
320
+ json.files @files if @files.present?
319
321
  end
320
322
  end
321
323
 
@@ -34,8 +34,6 @@ class Glib::JsonUi::ViewBuilder
34
34
 
35
35
  def field_assert_respond_to(prop)
36
36
  self.class.field_assert_respond_to(@model, prop)
37
- # # Identify a prop being used on a nil model or incorrect model.
38
- # raise "Invalid property `#{prop}` on '#{@model.class}'" unless @model.respond_to?(prop)
39
37
  end
40
38
 
41
39
  def self.field_assert_respond_to(model, prop)
@@ -74,12 +72,12 @@ class Glib::JsonUi::ViewBuilder
74
72
  "#{name}[#{prop}]#{suffix}"
75
73
  end
76
74
 
77
- def field_value(prop)
78
- self.class.field_value(@model, prop)
75
+ def field_value(prop, collect_ids: true)
76
+ self.class.field_value(@model, prop, collect_ids: collect_ids)
79
77
  end
80
78
 
81
- def self.field_value(model, prop)
82
- if is_array_association?(model, prop)
79
+ def self.field_value(model, prop, collect_ids:)
80
+ if is_array_association?(model, prop) && collect_ids
83
81
  model.send(prop)&.map { |record| record.id }
84
82
  else
85
83
  model.send(prop)
@@ -384,8 +382,8 @@ class Glib::JsonUi::ViewBuilder
384
382
  @delegate_class.field_name(@model, prop, multiple, page)
385
383
  end
386
384
 
387
- def field_value(prop)
388
- @delegate_class.field_value(@model, prop)
385
+ def field_value(prop, collect_ids: true)
386
+ @delegate_class.field_value(@model, prop, collect_ids: collect_ids)
389
387
  end
390
388
 
391
389
  def field_label(prop, args)
@@ -41,7 +41,7 @@ page.form options.merge(childViews: ->(form) do
41
41
  name: 'user[multi][]',
42
42
  accepts: { fileType: 'image', maxFileSize: 5000 },
43
43
  directUploadUrl: rails_direct_uploads_url,
44
- uploadTitle: 'File added:',
44
+ uploadTitle: 'Files uploaded:',
45
45
  uploadFailedText: '(UPLOAD FAILED)',
46
46
  files: [
47
47
  { name: 'File (Example)', signed_id: ActiveStorage::Attachment.last&.signed_id }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glib-web
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.16.0
4
+ version: 3.16.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''