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 } |
||||||
filter_class.available_operators.collect do |o| |
options.merge! :style => "display: none" if hide_select_box |
||||||
opts = {:value => h(o.to_s), :"data-arity" => o.arity} |
select_box = content_tag :select, options do |
||||||
opts[:selected] = "selected" if filter.operator.to_s == o.to_s |
filter_class.available_operators.collect do |o| |
||||||
content_tag(:option, opts) { h(l(o.label)) } |
opts = {:value => h(o.to_s), :"data-arity" => o.arity} |
||||||
end.join.html_safe |
opts[:selected] = "selected" if filter.operator.to_s == o.to_s |
||||||
end |
content_tag(:option, opts) { h(l(o.label)) } |
||||||
else |
end.join.html_safe |
||||||
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) |
|
||||||
end |
|
||||||
end |
end |
||||||
|
label = content_tag :label do |
||||||
|
l(filter_class.available_operators.first.label) |
||||||
|
end |
||||||
|
hide_select_box ? select_box + label : select_box |
||||||
end |
end |
||||||
end |
end |
||||||
end |
end |
||||||
|
Loading…
Reference in new issue