blob: 16081b6602e0be870190af011963f88bd9025cfa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
module SearchHelper
def link_with_search(name, search, html_options = {})
is_current = (@q and search.all? { |k,v| @q.send(k) == v })
if is_current
html_options[:class] = [html_options[:class], "current"].compact.join(" ")
end
link_to name, params.deep_merge("q" => search,:page => 1), html_options
end
def filter_item_class q, key
active = false
if q.present? && q[key].present?
val = q[key]
if val.is_a?(Array)
active = val.any? &:present?
elsif val.is_a?(Hash)
active = val.values.any? {|v| v.present? && v != "false" }
else
active = true
end
end
active ? 'active' : 'inactive'
end
end
|