roda-component 0.1.21 → 0.1.22

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
  SHA1:
3
- metadata.gz: a16bb2b329a369806cff4a67ac5988eac549382c
4
- data.tar.gz: 4cf66e8d5cd2579d3949cb2629dc10eeef204dbd
3
+ metadata.gz: 2762210c34d25092f116906d5f179868ec7a015a
4
+ data.tar.gz: 90bfc66cfc6a1144f5c6deeeedfa19461efb7a6a
5
5
  SHA512:
6
- metadata.gz: dd5d13d7a64980b0b8e894b2eb34674a349cd492e44efd2d3bdf7816ff7720e9f0acbcda0738a06f17af2467c958d3cc631fcd30bb588c6c19724a8d9f7732cc
7
- data.tar.gz: 99af32ec110135bd65a7970600d62811490201879099baea649a6b2d40461c502a453b70d9d47b85a1b522c893d1497acf3d5bed3d6ad1aee0c7bd9a5dbaa094
6
+ metadata.gz: 438a6485163a5065b03ebf8e4438f362b4b73abfeda6652db9ddfbca3cdf2c2072ab0d58adf2762edcc4cd252fc1af3816307dc673fa61425c0cac0f6234b0ed
7
+ data.tar.gz: 7fc115845baaa1abfbd43458722b0160d885cb552e7153f290be24872a5c3a22ada9fc2428d9a7e9e767bac244371c41f34ab74ee9701763741554330691e58e
@@ -125,6 +125,28 @@ class Roda
125
125
  end
126
126
  end
127
127
 
128
+ def model_attributes data = attributes
129
+ hash = {}
130
+
131
+ data.each do |k, v|
132
+ if klass = _form[k.to_s.to_sym]
133
+ data = data[k]
134
+
135
+ f = klass.new data
136
+ k = "#{k}_attributes"
137
+ data = f.attributes
138
+
139
+ hash[k] = model_attributes data
140
+ elsif v.is_a? Hash
141
+ hash[k] = model_attributes data[k]
142
+ else
143
+ hash[k] = v
144
+ end
145
+ end
146
+
147
+ hash
148
+ end
149
+
128
150
  def slice(*keys)
129
151
  Hash.new.tap do |atts|
130
152
  keys.each do |att|
@@ -134,6 +156,7 @@ class Roda
134
156
  end
135
157
 
136
158
  def display_errors options = {}
159
+ dom = options.delete(:dom) || _dom
137
160
  d_errors = errors
138
161
 
139
162
  if override_errors = options[:override_errors]
@@ -164,11 +187,10 @@ class Roda
164
187
  i != 0 ? "[#{field}]" : field
165
188
  end.join
166
189
 
167
- field_error_dom = options.delete :tmpl
168
- field_error_dom = DOM.new('<span class="field-error"><span>') unless field_error_dom
190
+ field_error_dom = DOM.new(`#{options[:tmpl].dom}[0].outerHTML` || '<span class="field-error"><span>')
169
191
  field_error_dom.html _error_name(key, error)
170
192
 
171
- field = _dom.find("input[name='#{name}']")
193
+ field = dom.find("[name='#{name}']")
172
194
  field.before field_error_dom.dom
173
195
  end
174
196
  end
@@ -1,5 +1,5 @@
1
1
  class Roda
2
2
  class Component
3
- VERSION = "0.1.21"
3
+ VERSION = "0.1.22"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roda-component
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.21
4
+ version: 0.1.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - cj