Class: Blacklight::FacetFieldPresenter

Inherits:
Object
  • Object
show all
Defined in:
app/presenters/blacklight/facet_field_presenter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(facet_field, display_facet, view_context, search_state = view_context.search_state) ⇒ FacetFieldPresenter

Returns a new instance of FacetFieldPresenter.



10
11
12
13
14
15
# File 'app/presenters/blacklight/facet_field_presenter.rb', line 10

def initialize(facet_field, display_facet, view_context, search_state = view_context.search_state)
  @facet_field = facet_field
  @display_facet = display_facet
  @view_context = view_context
  @search_state = search_state
end

Instance Attribute Details

#display_facetObject (readonly)

Returns the value of attribute display_facet.



5
6
7
# File 'app/presenters/blacklight/facet_field_presenter.rb', line 5

def display_facet
  @display_facet
end

#facet_fieldObject (readonly)

Returns the value of attribute facet_field.



5
6
7
# File 'app/presenters/blacklight/facet_field_presenter.rb', line 5

def facet_field
  @facet_field
end

#search_stateObject (readonly)

Returns the value of attribute search_state.



5
6
7
# File 'app/presenters/blacklight/facet_field_presenter.rb', line 5

def search_state
  @search_state
end

#view_contextObject (readonly)

Returns the value of attribute view_context.



5
6
7
# File 'app/presenters/blacklight/facet_field_presenter.rb', line 5

def view_context
  @view_context
end

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


23
24
25
26
27
# File 'app/presenters/blacklight/facet_field_presenter.rb', line 23

def active?
  Deprecation.silence(Blacklight::FacetsHelperBehavior) do
    view_context.facet_field_in_params?(key)
  end
end

#collapsed?Boolean

Returns:

  • (Boolean)


17
18
19
20
21
# File 'app/presenters/blacklight/facet_field_presenter.rb', line 17

def collapsed?
  Deprecation.silence(Blacklight::FacetsHelperBehavior) do
    view_context.should_collapse_facet?(facet_field)
  end
end

#html_idObject

Deprecated.


49
50
51
52
53
# File 'app/presenters/blacklight/facet_field_presenter.rb', line 49

def html_id
  Deprecation.silence(Blacklight::FacetsHelperBehavior) do
    view_context.facet_field_id(facet_field)
  end
end

#in_modal?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'app/presenters/blacklight/facet_field_presenter.rb', line 29

def in_modal?
  search_state.params[:action] == "facet"
end

#labelObject



39
40
41
# File 'app/presenters/blacklight/facet_field_presenter.rb', line 39

def label
  view_context.facet_field_label(key)
end


33
34
35
36
37
# File 'app/presenters/blacklight/facet_field_presenter.rb', line 33

def modal_path
  return unless paginator

  view_context.search_facet_path(id: key) unless paginator&.last_page?
end

#paginatorObject



55
56
57
58
59
60
61
# File 'app/presenters/blacklight/facet_field_presenter.rb', line 55

def paginator
  return unless display_facet

  Deprecation.silence(Blacklight::Facet) do
    @paginator ||= view_context.facet_paginator(facet_field, display_facet)
  end
end

#valuesObject



43
44
45
# File 'app/presenters/blacklight/facet_field_presenter.rb', line 43

def values
  search_state&.filter(facet_field)&.values || []
end