Module: Arclight::FieldConfigHelpers

Extended by:
ActiveSupport::Concern
Includes:
ActionView::Helpers::OutputSafetyHelper, ActionView::Helpers::TagHelper
Included in:
CatalogController
Defined in:
app/controllers/concerns/arclight/field_config_helpers.rb

Overview

A module to add configuration helpers for certain fields used by Arclight

Instance Method Summary collapse

Instance Method Details

#before_you_visit_note_present(_, document) ⇒ Object



49
50
51
# File 'app/controllers/concerns/arclight/field_config_helpers.rb', line 49

def before_you_visit_note_present(_, document)
  document.repository_config && document.repository_config.visit_note.present?
end

#context_sidebar_containers_request(args) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
# File 'app/controllers/concerns/arclight/field_config_helpers.rb', line 58

def context_sidebar_containers_request(args)
  document = args[:document]
  presenter = Arclight::ShowPresenter.new(document, view_context)
  ApplicationController.renderer.render(
    'arclight/requests/_google_form',
    layout: false,
    locals: {
      google_form: Arclight::Requests::GoogleForm.new(document, presenter, solr_document_url(document))
    }
  )
end

#context_sidebar_repository(args) ⇒ Object



40
41
42
43
44
45
46
47
# File 'app/controllers/concerns/arclight/field_config_helpers.rb', line 40

def context_sidebar_repository(args)
  document = args[:document]
  ApplicationController.renderer.render(
    'arclight/repositories/_in_person_repository',
    layout: false,
    locals: { repository: document.repository_config }
  )
end

#context_sidebar_visit_note(args) ⇒ Object



53
54
55
56
# File 'app/controllers/concerns/arclight/field_config_helpers.rb', line 53

def context_sidebar_visit_note(args)
  document = args[:document]
  document.repository_config.visit_note
end

#item_requestable?(_, options) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
32
# File 'app/controllers/concerns/arclight/field_config_helpers.rb', line 29

def item_requestable?(_, options)
  document = options[:document]
  request_config_present('', document) && document.containers.present?
end


74
75
76
77
78
79
80
81
82
83
84
# File 'app/controllers/concerns/arclight/field_config_helpers.rb', line 74

def link_to_name_facet(args)
  options = args[:config].try(:separator_options) || {}
  values = args[:value] || []

  values.map do |value|
    view_context.link_to(
      value,
      view_context.search_action_path(f: { names_ssim: [value] })
    )
  end.to_sentence(options).html_safe
end

#paragraph_separator(args) ⇒ Object



70
71
72
# File 'app/controllers/concerns/arclight/field_config_helpers.rb', line 70

def paragraph_separator(args)
  safe_join(args[:value].map { |paragraph| (:p, paragraph) })
end

#repository_config_present(_, document) ⇒ Object



25
26
27
# File 'app/controllers/concerns/arclight/field_config_helpers.rb', line 25

def repository_config_present(_, document)
  document.repository_config.present?
end

#request_config_present(var, document) ⇒ Object



34
35
36
37
38
# File 'app/controllers/concerns/arclight/field_config_helpers.rb', line 34

def request_config_present(var, document)
  repository_config_present(var, document) &&
    document.repository_config.google_request_url.present? &&
    document.repository_config.google_request_mappings.present?
end