simple_form_extension 1.4.18 → 1.5.0

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
- SHA1:
3
- metadata.gz: 93cd36ca721b1ef45750cd496e120b4de0213843
4
- data.tar.gz: b148a00b9dd74be84423994f66ce08f828248794
2
+ SHA256:
3
+ metadata.gz: 38aa08ea4a8cf92f6fc0cc37e25626842ae034d35244b917f6043d3da61ec28f
4
+ data.tar.gz: 695288388ad82f16580b7bfd1bf04590e20d070fb82d1595e5c23ad732a7331a
5
5
  SHA512:
6
- metadata.gz: 2c822388163ade7cbda89576e6349e28d063613d5b1b868df9158193302cd2ddcbaeb38deae33d8d6bbdc380d0e8ce1730c252230d7a8510080c4bc51e04f95f
7
- data.tar.gz: 308a1c6b4c212da8e33820be2b6e830fca4273e029692ee14ad8cc18cd8cf691df51dfa58c65d0e579e81e4016868850fe89079c94909d3b917c59719155ab76
6
+ metadata.gz: c06e4eaa4ff32484bd0dea6e9fa5727dde895796d10a9a9996eb7cd8b18c953619ee16b0b2ff85250c6843353934ca3e4b57886ad49884d64d071f7a0f2b3aa6
7
+ data.tar.gz: e6a67846e389e65734d7cff721f692db9ddd3601b298af8c0faa443ad90a1d4acc697870689ac87be9d1078f9fd65782681f3fa941de53ab948c94b4f42f9702
data/README.md CHANGED
@@ -142,7 +142,7 @@ You can customize the name of the setter that will be called with the
142
142
  #### :selectize
143
143
 
144
144
  The selectize field allows you to create a powerful select field using the
145
- [Selectize](https://brianreavis.github.io/selectize.js/) javascript plugin.
145
+ [Selectize](https://selectize.github.io/selectize.js/) javascript plugin.
146
146
 
147
147
  ```ruby
148
148
  = form.input :items, as: :selectize, collection: Item.all
@@ -26,9 +26,10 @@ module SimpleFormExtension
26
26
  end
27
27
 
28
28
  def existing_file_name
29
- if object.try(:"#{ attribute_name }?")
29
+ if paperclip_attachment_attached?
30
30
  object.send(:"#{ attribute_name }_file_name").html_safe
31
- elsif (attachment = object.try(attribute_name)).try(:attached?)
31
+ elsif activestorage_attachment_attached?
32
+ attachment = object.send(attribute_name)
32
33
  attachment.filename.to_s
33
34
  end
34
35
  end
@@ -47,16 +48,25 @@ module SimpleFormExtension
47
48
  end
48
49
 
49
50
  def file_exists?
50
- @file_exists ||= object.try(:"#{ attribute_name }?") ||
51
- object.try(attribute_name).try(:attached?)
51
+ @file_exists ||= paperclip_attachment_attached? || activestorage_attachment_attached?
52
52
  end
53
53
 
54
54
  def file_url
55
- if object.try(:"#{ attribute_name }?")
55
+ if paperclip_attachment_attached?
56
56
  object.send(attribute_name)
57
- elsif object.try(attribute_name).try(:attached?)
58
- object.try(attribute_name).try(:service_url)
57
+ elsif activestorage_attachment_attached?
58
+ object.send(attribute_name).try(:service_url) || object.send(attribute_name).try(:url)
59
59
  end
60
60
  end
61
+
62
+ def paperclip_attachment_attached?
63
+ @paperclip_attachment_attached ||= object.try(:"#{ attribute_name }?")
64
+ end
65
+
66
+ def activestorage_attachment_attached?
67
+ @activestorage_attachment_attached ||=
68
+ object.try(attribute_name).try(:attached?) &&
69
+ object.try(attribute_name).blob
70
+ end
61
71
  end
62
72
  end
@@ -70,13 +70,13 @@ module SimpleFormExtension
70
70
  # preview thumbnail
71
71
  #
72
72
  def file_url
73
- if object.try(:"#{ attribute_name }?")
73
+ if paperclip_attachment_attached?
74
74
  object.send(attribute_name).url(image_style)
75
- elsif (attachment = object.try(attribute_name)).try(:attached?)
76
- if attachment.variable?
77
- attachment.variant(resize: "400x150>")
78
- elsif attachment.previewable?
79
- attachment.preview(resize: "400x150>")
75
+ elsif activestorage_attachment_attached?
76
+ attachment = object.send(attribute_name)
77
+
78
+ if attachment.representable?
79
+ attachment.representation(resize: "400x150>")
80
80
  else
81
81
  attachment.service_url
82
82
  end
@@ -1,3 +1,3 @@
1
1
  module SimpleFormExtension
2
- VERSION = "1.4.18"
2
+ VERSION = '1.5.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_form_extension
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.18
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Glyph-fr
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-10 00:00:00.000000000 Z
11
+ date: 2023-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -163,7 +163,7 @@ homepage: http://www.glyph.fr
163
163
  licenses:
164
164
  - MIT
165
165
  metadata: {}
166
- post_install_message:
166
+ post_install_message:
167
167
  rdoc_options: []
168
168
  require_paths:
169
169
  - lib
@@ -178,9 +178,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
178
178
  - !ruby/object:Gem::Version
179
179
  version: '0'
180
180
  requirements: []
181
- rubyforge_project:
182
- rubygems_version: 2.6.11
183
- signing_key:
181
+ rubygems_version: 3.3.7
182
+ signing_key:
184
183
  specification_version: 4
185
184
  summary: This gems adds custom common input types to simple form.
186
185
  test_files: []