Module: Worthwhile::CatalogHelper

Defined in:
app/helpers/worthwhile/catalog_helper.rb

Instance Method Summary collapse

Instance Method Details

#all_type_tab(label = t('worthwhile.catalog.index.type_tabs.all')) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/helpers/worthwhile/catalog_helper.rb', line 17

def all_type_tab(label = t('worthwhile.catalog.index.type_tabs.all'))
  if params[:f] && params[:f][type_field]
    facet_solr_field = facet_configuration_for_field(type_field)
    new_params = remove_facet_params(type_field, params[:f][type_field].first)

    # Delete any request params from facet-specific action, needed
    # to redir to index action properly.
    new_params.except! *Blacklight::Solr::FacetPaginator.request_keys.values
    path = search_action_path(new_params)
    (:li, link_to(label, path))
  else
    (:li, link_to(label, '#'), class: "active")
  end
end

#type_tab(label, key = label) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'app/helpers/worthwhile/catalog_helper.rb', line 2

def type_tab(label, key=label)
  if params[:f] && params[:f][type_field] == [key]
    (:li, link_to(label, "#"), class: "active")
  else
    facet_solr_field = facet_configuration_for_field(type_field)
    path = search_action_path(add_facet_params_and_redirect(type_field, key))
    # local_params = params.dup
    # local_facet_params = local_params[:f] || {}.with_indifferent_access
    # local_params[:f] = local_facet_params.select{|k,_| k != type_field }
    # puts "local #{local_params}"
    # path = add_facet_params(type_field, key, local_params)
    (:li, link_to(label, path))
  end
end