Class: Arclight::DocumentComponentsHierarchyComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/arclight/document_components_hierarchy_component.rb

Overview

Display a document’s constituent components with appropriate lazy-loading to keep the page load time reasonable.

Instance Method Summary collapse

Constructor Details

#initialize(document: nil, target_index: -1,, minimum_pagination_size: 20, left_outer_window: 3, maximum_left_gap: 10, window: 10) ⇒ DocumentComponentsHierarchyComponent

rubocop:disable Metrics/ParameterLists



8
9
10
11
12
13
14
15
16
17
# File 'app/components/arclight/document_components_hierarchy_component.rb', line 8

def initialize(document: nil, target_index: -1, minimum_pagination_size: 20, left_outer_window: 3, maximum_left_gap: 10, window: 10)
  super

  @document = document
  @target_index = target_index&.to_i || -1
  @minimum_pagination_size = minimum_pagination_size
  @left_outer_window = left_outer_window
  @maximum_left_gap = maximum_left_gap
  @window = window
end

Instance Method Details

#hierarchy_path(**kwargs) ⇒ Object



24
25
26
# File 'app/components/arclight/document_components_hierarchy_component.rb', line 24

def hierarchy_path(**kwargs)
  helpers.hierarchy_solr_document_path(id: @document.id, hierarchy: true, nest_path: params[:nest_path], **kwargs)
end

#paginate?Boolean

rubocop:enable Metrics/ParameterLists

Returns:

  • (Boolean)


20
21
22
# File 'app/components/arclight/document_components_hierarchy_component.rb', line 20

def paginate?
  @document.number_of_children > @minimum_pagination_size
end