165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
|
# File 'lib/action_web_service/scaffolding.rb', line 165
def method_parameter_input_fields(method, type, field_name_base, idx, was_structured=false)
if type.array?
return content_tag('em', "Typed array input fields not supported yet (#{type.name})")
end
if type.structured?
return content_tag('em', "Nested structural types not supported yet (#{type.name})") if was_structured
parameters = ""
type.each_member do |member_name, member_type|
label = method_parameter_label(member_name, member_type)
nested_content = method_parameter_input_fields(
method,
member_type,
"#{field_name_base}[#{idx}][#{member_name}]",
idx,
true)
if member_type.custom?
parameters << content_tag('li', label)
parameters << content_tag('ul', nested_content.html_safe)
else
parameters << content_tag('li', (label + ' ' + nested_content).html_safe)
end
end
content_tag('ul', parameters.html_safe)
else
field_name_base = "#{field_name_base}[#{idx}]" unless was_structured
case type.type
when :int
text_field_tag "#{field_name_base}"
when :string
text_field_tag "#{field_name_base}"
when :base64
text_area_tag "#{field_name_base}", nil, :size => "40x5"
when :bool
radio_button_tag("#{field_name_base}", "true") + " True" +
radio_button_tag("#{field_name_base}", "false") + "False"
when :float
text_field_tag "#{field_name_base}"
when :time, :datetime
time = Time.now
i = 0
%w|year month day hour minute second|.map do |name|
i += 1
send("select_#{name}", time, :prefix => "#{field_name_base}[#{i}]", :discard_type => true)
end.join
when :date
date = Date.today
i = 0
%w|year month day|.map do |name|
i += 1
send("select_#{name}", date, :prefix => "#{field_name_base}[#{i}]", :discard_type => true)
end.join
end
end
end
|