simple_form-polymorphic_associations 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0beb264dc98808fcc7bfa4a1ab6ec2bc5219663398877f1487731cf9059ee31b
|
|
4
|
+
data.tar.gz: 86032e0623b65c0a3dd998cc7b5c6b84fc062fba9337139820bf3b85e524f8a6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '01261180fcd1e963563626f04bf25e4018e2b0d42b0a5474f827c37bed3f3e96a0959be69951094aaefa17423f71852fe1e8dbb066722124cb5e7ad76841aae0'
|
|
7
|
+
data.tar.gz: e25ca8e8f9a4631fee36fb20fdc9816096ee7b3a67b9fd13e038694a1bd82a442d41980248bb88325011391b9901e87748a730d551d6a4f6d67bfc170b5b782f
|
|
@@ -46,13 +46,16 @@ class PolymorphicAssociationInput < SimpleForm::Inputs::Base
|
|
|
46
46
|
def input(wrapper_options = nil)
|
|
47
47
|
ActiveSupport::SafeBuffer.new.tap do |o|
|
|
48
48
|
collection = options[:classes].keys.collect { |c| [c.model_name.human, c] }
|
|
49
|
-
|
|
50
|
-
value_method = :to_s
|
|
49
|
+
instance_label_method = options.delete(:instance_label_method) || :to_s
|
|
51
50
|
o << @builder.select("#{attribute_name}_type", collection, { include_blank: true }, { class: 'form-control select required polymorphic-association-class-select' })
|
|
52
51
|
options[:classes].each do |klass, url|
|
|
53
52
|
o << "<a class=\"polymorphic-association-autocomplete-link\" data-class=\"#{klass}\" href=\"#{url}\" ></a>".html_safe
|
|
54
53
|
end
|
|
55
|
-
|
|
54
|
+
id_select_collection = []
|
|
55
|
+
if selected_record = object.send(attribute_name).presence
|
|
56
|
+
id_select_collection << [selected_record.send(instance_label_method), selected_record.id]
|
|
57
|
+
end
|
|
58
|
+
o << @builder.select("#{attribute_name}_id", id_select_collection, {}, { class: 'form-control select required polymorphic-association-resource-select' })
|
|
56
59
|
end
|
|
57
60
|
end
|
|
58
61
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: simple_form-polymorphic_associations
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Roberto Vasquez Angel
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2023-11-
|
|
11
|
+
date: 2023-11-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: simple_form
|
|
@@ -63,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
63
63
|
- !ruby/object:Gem::Version
|
|
64
64
|
version: '0'
|
|
65
65
|
requirements: []
|
|
66
|
-
rubygems_version: 3.
|
|
66
|
+
rubygems_version: 3.3.26
|
|
67
67
|
signing_key:
|
|
68
68
|
specification_version: 4
|
|
69
69
|
summary: Simple Form polymorphic associations.
|