parent
312df4ce16
commit
5828192245
@ -1,28 +1,24 @@ |
|||||||
class Widget::Filters::Operators < Widget::Filters::Base |
class Widget::Filters::Operators < Widget::Filters::Base |
||||||
def render |
def render |
||||||
content_tag :td, :width => 100 do |
content_tag :td, :width => 100 do |
||||||
if filter_class.available_operators.count > 1 |
hide_select_box = filter_class.available_operators.count == 1 |
||||||
content_tag :select, :class => "select-small filters-select filter_operator", |
options = {:class => "select-small filters-select filter_operator", |
||||||
:style => "vertical-align: top", # FIXME: put into CSS |
:style => "vertical-align: top", # FIXME: put into CSS |
||||||
:id => "operators[#{filter_class.underscore_name}]", |
:id => "operators[#{filter_class.underscore_name}]", |
||||||
:name => "operators[#{filter_class.underscore_name}]", |
:name => "operators[#{filter_class.underscore_name}]", |
||||||
:"data-filter-name" => filter_class.underscore_name do |
:"data-filter-name" => filter_class.underscore_name } |
||||||
|
options.merge! :style => "display: none" if hide_select_box |
||||||
|
select_box = content_tag :select, options do |
||||||
filter_class.available_operators.collect do |o| |
filter_class.available_operators.collect do |o| |
||||||
opts = {:value => h(o.to_s), :"data-arity" => o.arity} |
opts = {:value => h(o.to_s), :"data-arity" => o.arity} |
||||||
opts[:selected] = "selected" if filter.operator.to_s == o.to_s |
opts[:selected] = "selected" if filter.operator.to_s == o.to_s |
||||||
content_tag(:option, opts) { h(l(o.label)) } |
content_tag(:option, opts) { h(l(o.label)) } |
||||||
end.join.html_safe |
end.join.html_safe |
||||||
end |
end |
||||||
else |
label = content_tag :label do |
||||||
content_tag :select, :class => "select-small filters-select filter_operator", |
|
||||||
:style => "display: none", # FIXME: put into CSS |
|
||||||
:id => "operators[#{filter_class.underscore_name}]", |
|
||||||
:name => "operators[#{filter_class.underscore_name}]", |
|
||||||
:"data-filter-name" => filter_class.underscore_name |
|
||||||
content_tag :label do |
|
||||||
l(filter_class.available_operators.first.label) |
l(filter_class.available_operators.first.label) |
||||||
end |
end |
||||||
end |
hide_select_box ? select_box + label : select_box |
||||||
end |
end |
||||||
end |
end |
||||||
end |
end |
||||||
|
Loading…
Reference in new issue