Restructured the MultiChoice Widget's render method a little.

pull/6827/head
Markus Kahl 14 years ago
parent ec5eb6a5a0
commit a1b886a64a
  1. 29
      lib/widget/filters/multi_choice.rb

@ -3,26 +3,17 @@ class Widget::Filters::MultiChoice < Widget::Filters::Base
def render def render
content_tag :td do content_tag :td do
content_tag :div, :id => "#{filter_class.underscore_name}_arg_1", :class => "filter_values" do content_tag :div, :id => "#{filter_class.underscore_name}_arg_1", :class => "filter_values" do
content = '' choices = filter_class.available_values.each_with_index.map do |(label, value), i|
available_values = filter_class.available_values radio_button = tag :input,
available_values.each_with_index do |(label, value), i| :type => "radio", :name => "#{filter_class.underscore_name}_arg_1_val",
label = content_tag :label, :id => "#{filter_class.underscore_name}_radio_option_#{i}",
:for => "#{filter_class.underscore_name}_radio_option_#{i}", :class => "#{filter_class.underscore_name}_radio_option",
:'data-filter-name' => filter_class.underscore_name do :value => value
radio_button = content_tag :input, content_tag :label, radio_button + label,
:type => 'radio', :for => "#{filter_class.underscore_name}_radio_option_#{i}",
:name => "#{filter_class.underscore_name}_arg_1_val", :'data-filter-name' => filter_class.underscore_name
:id => "#{filter_class.underscore_name}_radio_option_#{i}",
:class => "#{filter_class.underscore_name}_radio_option",
:value => value do
''
end
radio_button + label
end
br = (i == available_values.size - 1) ? '' : content_tag(:br) {}
content += (label + br)
end end
content.html_safe choices.join(content_tag(:br)).html_safe
end end
end end
end end

Loading…
Cancel
Save