Class: Blacklight::SearchContextComponent
- Inherits:
-
Component
- Object
- ViewComponent::Base
- Component
- Blacklight::SearchContextComponent
show all
- Defined in:
- app/components/blacklight/search_context_component.rb
Constant Summary
Constants inherited
from Component
Component::EXCLUDE_VARIABLES
Instance Method Summary
collapse
Methods inherited from Component
compiler, config, #inspect
Constructor Details
#initialize(search_context:, search_session:) ⇒ SearchContextComponent
Returns a new instance of SearchContextComponent.
7
8
9
10
|
# File 'app/components/blacklight/search_context_component.rb', line 7
def initialize(search_context:, search_session:)
@search_context = search_context
@search_session = search_session
end
|
Instance Method Details
#item_page_entry_info ⇒ String
Displays “showing X of Y items” message.
20
21
22
23
24
|
# File 'app/components/blacklight/search_context_component.rb', line 20
def item_page_entry_info
t('blacklight.search.entry_pagination_info.other', current: number_with_delimiter(count),
total: number_with_delimiter(total),
count: total).html_safe
end
|
#link_to_next_document(next_document = nil, classes: 'next', **link_opts) ⇒ Object
34
35
36
37
38
39
40
|
# File 'app/components/blacklight/search_context_component.rb', line 34
def link_to_next_document(next_document = nil, classes: 'next', **link_opts)
next_document ||= @search_context[:next]
link_opts = session_tracking_params(next_document, count + 1, per_page: per_page, search_id: search_id).merge(class: classes, rel: 'next').merge(link_opts)
link_to_unless next_document.nil?, raw(t('views.pagination.next')), url_for_document(next_document), link_opts do
tag.span raw(t('views.pagination.next')), class: 'next'
end
end
|
#link_to_previous_document(previous_document = nil, classes: 'previous', **link_opts) ⇒ Object
26
27
28
29
30
31
32
|
# File 'app/components/blacklight/search_context_component.rb', line 26
def link_to_previous_document(previous_document = nil, classes: 'previous', **link_opts)
previous_document ||= @search_context[:prev]
link_opts = session_tracking_params(previous_document, count - 1, per_page: per_page, search_id: search_id).merge(class: classes, rel: 'prev').merge(link_opts)
link_to_unless previous_document.nil?, raw(t('views.pagination.previous')), url_for_document(previous_document), link_opts do
tag.span raw(t('views.pagination.previous')), class: 'previous'
end
end
|
#render? ⇒ Boolean
12
13
14
|
# File 'app/components/blacklight/search_context_component.rb', line 12
def render?
@search_context.present? && (@search_context[:prev] || @search_context[:next])
end
|