Module: Refinuri::Helpers

Included in:
Refinuri
Defined in:
lib/refinuri/helpers.rb

Instance Method Summary collapse

Instance Method Details



3
4
5
6
7
# File 'lib/refinuri/helpers.rb', line 3

def filter_with_link(name, filters, options = nil, html_options = nil)
  options = options || params
  options[:filters] = @filters.merge!(filters).to_url
  link_to(name,options,html_options)
end

TODO needs to get cleaned up



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/refinuri/helpers.rb', line 10

def toggle_filter_with_link(name, toggle_filter, options = nil, html_options = nil)
  options = options || params

  key_to_toggle = toggle_filter.first[0]
  if @filters.filters[key_to_toggle]
    crud = case @filters.filters[key_to_toggle].value
      when Array then (@filters.filters[key_to_toggle].value.include?(toggle_filter.first[1]) ? :delete : :update)
      else :delete
    end
  else
    crud = :update
  end

  options[:filters] = @filters.merge!({ crud => toggle_filter }).to_url
  link_to(name,options,html_options)
end