Class: Blacklight::MetadataFieldComponent
- Inherits:
 - 
      Component
      
        
- Object
 - ViewComponent::Base
 - Component
 - Blacklight::MetadataFieldComponent
 
 
- Defined in:
 - app/components/blacklight/metadata_field_component.rb
 
Constant Summary
Constants inherited from Component
Instance Method Summary collapse
- 
  
    
      #index_field_label(label)  ⇒ String 
    
    
  
  
  
  
  
  
  
  
  
    
Render the index field label for a document.
 - 
  
    
      #initialize(field:, layout: nil, show: false, view_type: nil)  ⇒ MetadataFieldComponent 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of MetadataFieldComponent.
 - #label ⇒ Object
 - #render? ⇒ Boolean
 - 
  
    
      #render_field  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Override this method in a subclass to change the way this value is rendered.
 - 
  
    
      #show_field_label(label)  ⇒ String 
    
    
  
  
  
  
  
  
  
  
  
    
Render the show field label for a document.
 
Methods inherited from Component
Constructor Details
#initialize(field:, layout: nil, show: false, view_type: nil) ⇒ MetadataFieldComponent
Returns a new instance of MetadataFieldComponent.
      10 11 12 13 14 15  | 
    
      # File 'app/components/blacklight/metadata_field_component.rb', line 10 def initialize(field:, layout: nil, show: false, view_type: nil) @field = field @layout = layout || Blacklight::MetadataFieldLayoutComponent @view_type = view_type @show = show end  | 
  
Instance Method Details
#index_field_label(label) ⇒ String
Render the index field label for a document
Translations for index field labels should go under blacklight.search.fields They are picked up from there by a value “%#label” in blacklight.search.index.label
      40 41 42  | 
    
      # File 'app/components/blacklight/metadata_field_component.rb', line 40 def index_field_label label html_escape t(:"blacklight.search.index.#{@view_type}.label", default: :'blacklight.search.index.label', label: label) end  | 
  
#label ⇒ Object
      17 18 19 20 21 22 23  | 
    
      # File 'app/components/blacklight/metadata_field_component.rb', line 17 def label if @show show_field_label @field.label('show') else index_field_label @field.label end end  | 
  
#render? ⇒ Boolean
      25 26 27  | 
    
      # File 'app/components/blacklight/metadata_field_component.rb', line 25 def render? @field.render_field? end  | 
  
#render_field ⇒ Object
Override this method in a subclass to change the way this value is rendered
      30 31 32  | 
    
      # File 'app/components/blacklight/metadata_field_component.rb', line 30 def render_field @field.render end  | 
  
#show_field_label(label) ⇒ String
Render the show field label for a document
      48 49 50  | 
    
      # File 'app/components/blacklight/metadata_field_component.rb', line 48 def show_field_label label t(:'blacklight.search.show.label', label: label) end  |