Class: Blacklight::Response::SpellcheckComponent
- Inherits:
 - 
      Component
      
        
- Object
 - ViewComponent::Base
 - Component
 - Blacklight::Response::SpellcheckComponent
 
 
- Defined in:
 - app/components/blacklight/response/spellcheck_component.rb
 
Overview
Render spellcheck results for a search query
Constant Summary
Constants inherited from Component
Search result helpers collapse
- 
  
    
      #show_spellcheck_suggestions?(response)  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    
Determine whether to display spellcheck suggestions.
 
Instance Method Summary collapse
- 
  
    
      #initialize(response:, options: nil)  ⇒ SpellcheckComponent 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of SpellcheckComponent.
 - #link_to_query(query) ⇒ Object
 - #render? ⇒ Boolean
 
Methods inherited from Component
Constructor Details
#initialize(response:, options: nil) ⇒ SpellcheckComponent
Returns a new instance of SpellcheckComponent.
      9 10 11 12 13  | 
    
      # File 'app/components/blacklight/response/spellcheck_component.rb', line 9 def initialize(response:, options: nil) @response = response @options = @options ||= (@response) end  | 
  
Instance Method Details
#link_to_query(query) ⇒ Object
      15 16 17 18 19  | 
    
      # File 'app/components/blacklight/response/spellcheck_component.rb', line 15 def link_to_query(query) p = helpers.search_state.to_h.except(:page, :action) p[:q] = query link_to(query, helpers.search_action_path(p)) end  | 
  
#render? ⇒ Boolean
      21 22 23  | 
    
      # File 'app/components/blacklight/response/spellcheck_component.rb', line 21 def render? Array(@options).any? && show_spellcheck_suggestions?(@response) end  | 
  
#show_spellcheck_suggestions?(response) ⇒ Boolean
Determine whether to display spellcheck suggestions
      31 32 33 34 35 36  | 
    
      # File 'app/components/blacklight/response/spellcheck_component.rb', line 31 def show_spellcheck_suggestions? response # The spelling response field may be missing from non solr repositories. response.total <= helpers.blacklight_config.spell_max && !response.spelling.nil? && response.spelling.words.any? end  |