Class: Blacklight::Document::PageHeaderComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/blacklight/document/page_header_component.rb

Overview

Render the start over and prev/next displays

Constant Summary

Constants inherited from Component

Component::EXCLUDE_VARIABLES

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Component

compiler, config, #inspect

Constructor Details

#initialize(document:, search_context:, search_session:) ⇒ PageHeaderComponent

Returns a new instance of PageHeaderComponent.



11
12
13
14
15
16
# File 'app/components/blacklight/document/page_header_component.rb', line 11

def initialize(document:, search_context:, search_session:)
  super
  @search_context = search_context
  @search_session = search_session
  @document = document
end

Instance Attribute Details

#blacklight_configObject (readonly)

Returns the value of attribute blacklight_config.



7
8
9
# File 'app/components/blacklight/document/page_header_component.rb', line 7

def blacklight_config
  @blacklight_config
end

#documentObject (readonly)

Returns the value of attribute document.



7
8
9
# File 'app/components/blacklight/document/page_header_component.rb', line 7

def document
  @document
end

#search_contextObject (readonly)

Returns the value of attribute search_context.



7
8
9
# File 'app/components/blacklight/document/page_header_component.rb', line 7

def search_context
  @search_context
end

#search_sessionObject (readonly)

Returns the value of attribute search_session.



7
8
9
# File 'app/components/blacklight/document/page_header_component.rb', line 7

def search_session
  @search_session
end

Instance Method Details

#action_component_tagObject



64
65
66
# File 'app/components/blacklight/document/page_header_component.rb', line 64

def action_component_tag
  'div'
end

#applied_params_componentObject



22
23
24
25
26
# File 'app/components/blacklight/document/page_header_component.rb', line 22

def applied_params_component
  return unless blacklight_config.track_search_session.applied_params_component

  blacklight_config.track_search_session.applied_params_component.new
end

#classesObject



68
69
70
# File 'app/components/blacklight/document/page_header_component.rb', line 68

def classes
  'd-inline-flex header-tools align-items-center col-12 col-md-6 ms-auto justify-content-md-end'
end

#default_action_component_renderObject



55
56
57
58
59
60
61
62
# File 'app/components/blacklight/document/page_header_component.rb', line 55

def default_action_component_render
  render Blacklight::Document::ActionsComponent.new(document: document,
                                                    tag: action_component_tag,
                                                    classes: classes,
                                                    link_classes: link_classes,
                                                    actions: header_actions,
                                                    url_opts: Blacklight::Parameters.sanitize(params.to_unsafe_h))
end

#has_header_tools?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'app/components/blacklight/document/page_header_component.rb', line 34

def has_header_tools?
  header_actions.any? || show_header_tools_component
end

#header_actionsObject



46
47
48
49
# File 'app/components/blacklight/document/page_header_component.rb', line 46

def header_actions
  actions = helpers.filter_partials(blacklight_config.view_config(:show).header_actions, { document: document })
  actions.map { |_k, v| v }
end

#header_container_classesObject



42
43
44
# File 'app/components/blacklight/document/page_header_component.rb', line 42

def header_container_classes
  has_header_tools? ? 'row pagination-search-widgets pb-2' : 'pagination-search-widgets'
end


72
73
74
# File 'app/components/blacklight/document/page_header_component.rb', line 72

def link_classes
  'btn btn-outline-primary ms-2'
end

#pagination_componentObject



28
29
30
31
32
# File 'app/components/blacklight/document/page_header_component.rb', line 28

def pagination_component
  return unless blacklight_config.track_search_session.item_pagination_component

  blacklight_config.track_search_session.item_pagination_component.new(search_context: search_context, search_session: search_session, current_document: document)
end

#pagination_container_classesObject



38
39
40
# File 'app/components/blacklight/document/page_header_component.rb', line 38

def pagination_container_classes
  has_header_tools? ? 'col-12 col-md-6 ms-auto' : ''
end

#render?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'app/components/blacklight/document/page_header_component.rb', line 18

def render?
  search_context.present? || search_session.present? || has_header_tools?
end

#render_header_toolsObject



76
77
78
79
80
81
82
# File 'app/components/blacklight/document/page_header_component.rb', line 76

def render_header_tools
  return unless has_header_tools?

  return render show_header_tools_component.new(document: document) if show_header_tools_component

  default_action_component_render
end

#show_header_tools_componentObject



51
52
53
# File 'app/components/blacklight/document/page_header_component.rb', line 51

def show_header_tools_component
  blacklight_config.view_config(:show).show_header_tools_component
end