simple_form-polymorphic_associations 0.0.2 → 0.0.4
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a66629243386a0ec87cbebee5cc282a84369ce2c35782c9f250d0e6f3d8b870f
|
4
|
+
data.tar.gz: f441759360c45c16677e9387c7787676b7986a5cd50f372b9437c57b0867d8f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c857cd4b2b97e18dc5fcc35308931798ed918de3d2358e72b58cd493474c963c10ace1c28f26bdbcfab97b25e3a50fd108b7114241187557332eb6e54487feaa
|
7
|
+
data.tar.gz: 179263afafb4328101147694ee8c948b2203fb6cb70ad6b6cd84f36fcec2dba3e70687fd5e7eac05340be2a8a45c9f484c3f694466136643ff00a98690043497
|
@@ -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
|
@@ -30,7 +30,7 @@ module SimpleFormPolymorphicAssociations
|
|
30
30
|
def polymorphic_select(record, label_method, options)
|
31
31
|
select record.class.model_name.human, from: options[:from].gsub(/_id]$/, "_type]")
|
32
32
|
first(".select2-container", minimum: 1).click
|
33
|
-
find(".select2-search--dropdown input.select2-search__field").send_keys(
|
33
|
+
find(".select2-search--dropdown input.select2-search__field").send_keys(record.send(label_method))
|
34
34
|
sleep(1)
|
35
35
|
find(".select2-search--dropdown input.select2-search__field").send_keys(:enter)
|
36
36
|
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.4
|
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-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: simple_form
|