Class: Geoblacklight::ViewerHelpTextComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/geoblacklight/viewer_help_text_component.rb

Overview

A component for rendering the help text for the viewer container

Instance Method Summary collapse

Constructor Details

#initialize(feature, key) ⇒ ViewerHelpTextComponent

Returns a new instance of ViewerHelpTextComponent.



8
9
10
11
12
# File 'app/components/geoblacklight/viewer_help_text_component.rb', line 8

def initialize(feature, key)
  @feature = feature
  @key = key
  super()
end

Instance Method Details

#display_textObject



36
37
38
39
40
# File 'app/components/geoblacklight/viewer_help_text_component.rb', line 36

def display_text
  return help_text_tag if help_text_exists?

  help_text_missing_tag
end

#help_text_exists?Boolean

Retrieve i18n value

Returns:

  • (Boolean)


15
16
17
# File 'app/components/geoblacklight/viewer_help_text_component.rb', line 15

def help_text_exists?
  I18n.exists?("geoblacklight.help_text.#{@feature}.#{@key}", helpers.locale)
end

#help_text_missing_tagObject



32
33
34
# File 'app/components/geoblacklight/viewer_help_text_component.rb', line 32

def help_text_missing_tag
  tag.span class: "help-text translation-missing"
end

#help_text_tagObject



23
24
25
26
27
28
29
30
# File 'app/components/geoblacklight/viewer_help_text_component.rb', line 23

def help_text_tag
  help_text = help_text_value
  tag.h2 class: "help-text viewer_protocol h6" do
    tag.a data: {bs_toggle: "popover", bs_title: help_text[:title], bs_content: help_text[:content]} do
      help_text[:title]
    end
  end
end

#help_text_valueObject



19
20
21
# File 'app/components/geoblacklight/viewer_help_text_component.rb', line 19

def help_text_value
  I18n.t("geoblacklight.help_text.#{@feature}.#{@key}")
end

#render?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'app/components/geoblacklight/viewer_help_text_component.rb', line 42

def render?
  Settings&.HELP_TEXT&.public_send(@feature)&.include?(@key)
end