Class: Geoblacklight::ViewerHelpTextComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Geoblacklight::ViewerHelpTextComponent
- 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
- #display_text ⇒ Object
-
#help_text_exists? ⇒ Boolean
Retrieve i18n value.
- #help_text_missing_tag ⇒ Object
- #help_text_tag ⇒ Object
- #help_text_value ⇒ Object
-
#initialize(feature, key) ⇒ ViewerHelpTextComponent
constructor
A new instance of ViewerHelpTextComponent.
- #render? ⇒ Boolean
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_text ⇒ Object
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
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_tag ⇒ Object
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_tag ⇒ Object
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_value ⇒ Object
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
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 |