Module: ArclightHelper

Includes:
Arclight::EadFormatHelpers, Arclight::FieldConfigHelpers, Blacklight::DocumentHelperBehavior, Blacklight::LayoutHelperBehavior
Defined in:
app/helpers/arclight_helper.rb

Overview

Generic Helpers used in Arclight

Instance Method Summary collapse

Methods included from Arclight::FieldConfigHelpers

#item_requestable?, #link_to_name_facet

Methods included from Arclight::EadFormatHelpers

#render_html_tags

Instance Method Details

#bookmarked?(document) ⇒ Boolean

Override of BL core https://github.com/projectblacklight/blacklight/blob/v8.1.0/app/helpers/blacklight/document_helper_behavior.rb#L55 Remove document_type check. It isn't a method on arclight documents Check if the document is in the user's bookmarks

Parameters:

  • document (Blacklight::Document)

Returns:

  • (Boolean)


101
102
103
# File 'app/helpers/arclight_helper.rb', line 101

def bookmarked?(document)
  current_bookmarks.any? { |x| x.document_id == document.id }
end

#collection_active? ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
# File 'app/helpers/arclight_helper.rb', line 41

def collection_active?
  search_state.filter('level').values == ['Collection']
end

#collection_active_class ⇒ Object



45
46
47
# File 'app/helpers/arclight_helper.rb', line 45

def collection_active_class
  'active' if collection_active?
end

#current_context_document ⇒ Object



105
106
107
# File 'app/helpers/arclight_helper.rb', line 105

def current_context_document
  @document
end

#document_or_parent_icon(document) ⇒ Object

determine which icon to show in search results header these icon names will need to be updated when the icons are determined



82
83
84
85
86
87
88
89
90
91
92
93
# File 'app/helpers/arclight_helper.rb', line 82

def document_or_parent_icon(document)
  case document.level&.downcase
  when 'collection'
    'collection'
  when 'file'
    'file'
  when 'series', 'subseries'
    'folder'
  else
    'container'
  end
end

#grouped? ⇒ Boolean

Returns:

  • (Boolean)


49
50
51
# File 'app/helpers/arclight_helper.rb', line 49

def grouped?
  respond_to?(:search_state) && search_state&.params_for_search&.dig('group') == 'true'
end

#on_repositories_index? ⇒ Boolean

Returns:

  • (Boolean)


61
62
63
# File 'app/helpers/arclight_helper.rb', line 61

def on_repositories_index?
  controller_name == 'repositories' && action_name == 'index'
end

#repositories_active_class ⇒ Object

the Repositories menu item is only active on the Repositories index page



66
67
68
# File 'app/helpers/arclight_helper.rb', line 66

def repositories_active_class
  'active' if on_repositories_index?
end

#repository_collections_path(repository) ⇒ Object



11
12
13
14
15
16
17
18
# File 'app/helpers/arclight_helper.rb', line 11

def repository_collections_path(repository)
  search_action_url(
    f: {
      repository: [repository.name],
      level: ['Collection']
    }
  )
end

#repository_faceted_on ⇒ Repository

If we have a facet on the repository, then return the Repository object for it

Returns:

  • (Repository)


73
74
75
76
77
78
# File 'app/helpers/arclight_helper.rb', line 73

def repository_faceted_on
  repos = search_state.filter('repository').values
  return unless repos.one?

  Arclight::Repository.find_by(name: repos.first)
end

#search_results_header_text ⇒ Object

Returns the i18n-ed string to be used as the h1 in search results



21
22
23
24
25
26
27
28
29
# File 'app/helpers/arclight_helper.rb', line 21

def search_results_header_text
  if (repo = repository_faceted_on).present?
    t('arclight.search.repository_header', repository: repo.name)
  elsif collection_active?
    t('arclight.search.collections_header')
  else
    t('blacklight.search.header')
  end
end

#search_with_group ⇒ Object



53
54
55
# File 'app/helpers/arclight_helper.rb', line 53

def search_with_group
  search_state.params_for_search.merge('group' => 'true').except('page')
end

#search_without_group ⇒ Object



57
58
59
# File 'app/helpers/arclight_helper.rb', line 57

def search_without_group
  search_state.params_for_search.except('group', 'page')
end

#show_content_classes ⇒ Object

Classes used for customized show page in arclight



33
34
35
# File 'app/helpers/arclight_helper.rb', line 33

def show_content_classes
  'col-12 col-lg-8 show-document order-2'
end

#show_sidebar_classes ⇒ Object



37
38
39
# File 'app/helpers/arclight_helper.rb', line 37

def show_sidebar_classes
  'col-lg-4 order-1 collection-sidebar'
end