Module: Blacklight::ComponentHelperBehavior

Included in:
CatalogHelperBehavior
Defined in:
app/helpers/blacklight/component_helper_behavior.rb

Instance Method Summary collapse

Instance Method Details

#document_actions(document, options: {}) ⇒ Object



36
37
38
# File 'app/helpers/blacklight/component_helper_behavior.rb', line 36

def document_actions(document, options: {})
  filter_partials(blacklight_config.view_config(:show).document_actions, { document: document }.merge(options)).map { |_k, v| v }
end

#filter_partials(partials, options) ⇒ Object



40
41
42
# File 'app/helpers/blacklight/component_helper_behavior.rb', line 40

def filter_partials(partials, options)
  partials.select { |_, config| blacklight_configuration_context.evaluate_if_unless_configuration config, options }
end

#render_index_doc_actions(document, wrapping_class: "index-document-functions", component: Blacklight::Document::ActionsComponent) ⇒ String

Render “document actions” area for search results view (normally renders next to title in the list view)

Parameters:

  • document (SolrDocument)
  • wrapping_class (String) (defaults to: "index-document-functions")

    (“index-document-functions”)

  • component (Class) (defaults to: Blacklight::Document::ActionsComponent)

    (Blacklight::Document::ActionsComponent)

Returns:

  • (String)


13
14
15
16
17
# File 'app/helpers/blacklight/component_helper_behavior.rb', line 13

def render_index_doc_actions(document, wrapping_class: "index-document-functions", component: Blacklight::Document::ActionsComponent)
  actions = filter_partials(blacklight_config.view_config(document_index_view_type).document_actions, { document: document }).map { |_k, v| v }

  render(component.new(document: document, actions: actions, classes: wrapping_class))
end

#render_results_collection_tools(wrapping_class: "search-widgets", component: Blacklight::Document::ActionsComponent) ⇒ String

Render “collection actions” area for search results view (normally renders next to pagination at the top of the result set)

Parameters:

  • wrapping_class (String) (defaults to: "search-widgets")

    (“search-widgets”)

  • component (Class) (defaults to: Blacklight::Document::ActionsComponent)

    (Blacklight::Document::ActionsComponent)

Returns:

  • (String)


26
27
28
29
30
# File 'app/helpers/blacklight/component_helper_behavior.rb', line 26

def render_results_collection_tools(wrapping_class: "search-widgets", component: Blacklight::Document::ActionsComponent)
  actions = filter_partials(blacklight_config.view_config(document_index_view_type).collection_actions, {}).map { |_k, v| v }

  render(component.new(actions: actions, classes: wrapping_class))
end

#show_doc_actions?(document = @document, options = {}) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'app/helpers/blacklight/component_helper_behavior.rb', line 32

def show_doc_actions?(document = @document, options = {})
  filter_partials(blacklight_config.view_config(:show).document_actions, { document: document }.merge(options)).any?
end