form_props 0.0.5 → 0.0.6
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: 6f36ab347fd2b8b9d118ac1d4756f18b9934ff03b0016edfdbc61b1fa01d3a61
|
4
|
+
data.tar.gz: 823dfb6b47b5fc418e37cde6642ea3dafef38c74149f30b51dc8218647e5ccf9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4b854fba57f47c833142bb229c19447f5e2d19d12e1162c3c718a54c53ead2d4e5aa5cb084c48dee40b70b249aae1613017ec7c3116fbb149e4723075703632
|
7
|
+
data.tar.gz: df34fc8fea47afcc3d0e7c1492b7c8ef359bfc5f5c37507f98855e524dd13fac1e9dc81d5c09dbcbec615be3c857affd2e185671cecba4c21768516535b33604
|
@@ -139,6 +139,7 @@ module FormProps
|
|
139
139
|
|
140
140
|
def fields_for_with_nested_attributes(association_name, association, options, block)
|
141
141
|
name = "#{object_name}[#{association_name}_attributes]"
|
142
|
+
association_key = "#{association_name.to_s.camelize(:lower)}Attributes"
|
142
143
|
association = convert_to_model(association)
|
143
144
|
json = @template.instance_variable_get(:@__json)
|
144
145
|
|
@@ -151,7 +152,7 @@ module FormProps
|
|
151
152
|
if association.respond_to?(:to_ary)
|
152
153
|
explicit_child_index = options[:child_index]
|
153
154
|
|
154
|
-
json.set!(
|
155
|
+
json.set!(association_key) do
|
155
156
|
json.array! association do |child|
|
156
157
|
if explicit_child_index
|
157
158
|
options[:child_index] = explicit_child_index.call if explicit_child_index.respond_to?(:call)
|
@@ -163,7 +164,7 @@ module FormProps
|
|
163
164
|
end
|
164
165
|
end
|
165
166
|
elsif association
|
166
|
-
json.set!(
|
167
|
+
json.set!(association_key) do
|
167
168
|
fields_for_nested_model(name, association, options, block)
|
168
169
|
end
|
169
170
|
end
|
@@ -11,13 +11,15 @@ module FormProps
|
|
11
11
|
options = options.with_indifferent_access
|
12
12
|
|
13
13
|
@controlled = options.delete(:controlled)
|
14
|
+
@key = options.delete(:key)
|
15
|
+
|
14
16
|
super(object_name, method_name, template_object, options)
|
15
17
|
end
|
16
18
|
|
17
19
|
private
|
18
20
|
|
19
21
|
def sanitized_key
|
20
|
-
sanitized_method_name.camelize(:lower)
|
22
|
+
@key || sanitized_method_name.camelize(:lower)
|
21
23
|
end
|
22
24
|
|
23
25
|
def add_options(option_tags, options, value = nil)
|
@@ -22,8 +22,6 @@ module FormProps
|
|
22
22
|
@options[:value] = @tag_value
|
23
23
|
@options[:checked] = true if input_checked?(@options)
|
24
24
|
|
25
|
-
name_for_key = (sanitized_method_name + "_#{sanitized_value(@tag_value)}").camelize(:lower)
|
26
|
-
|
27
25
|
body_block = -> {
|
28
26
|
add_default_name_and_id_for_value(@tag_value, @options)
|
29
27
|
input_props(@options)
|
@@ -32,7 +30,7 @@ module FormProps
|
|
32
30
|
if flatten
|
33
31
|
body_block.call
|
34
32
|
else
|
35
|
-
json.set!(
|
33
|
+
json.set!(sanitized_key) do
|
36
34
|
body_block.call
|
37
35
|
end
|
38
36
|
end
|
@@ -40,6 +38,10 @@ module FormProps
|
|
40
38
|
|
41
39
|
private
|
42
40
|
|
41
|
+
def sanitized_key
|
42
|
+
@key || (sanitized_method_name + "_#{sanitized_value(@tag_value)}").camelize(:lower)
|
43
|
+
end
|
44
|
+
|
43
45
|
def checked?(value)
|
44
46
|
value.to_s == @tag_value.to_s
|
45
47
|
end
|
data/lib/form_props/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: form_props
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Johny Ho
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|