Class: Uchi::Ui::SearchForm

Inherits:
ViewComponent::Base
  • Object
show all
Includes:
RoutesHelper
Defined in:
app/components/uchi/ui/search_form.rb

Overview

Renders the global search form shown in the application layout.

Based on Flowbite's Simple search input (https://flowbite.com/docs/forms/search-input/#simple-search-input)

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from RoutesHelper

#uchi_path_to

Constructor Details

#initialize(query: nil) ⇒ SearchForm

Returns a new instance of SearchForm.



14
15
16
17
# File 'app/components/uchi/ui/search_form.rb', line 14

def initialize(query: nil)
  super()
  @query = query
end

Instance Attribute Details

#query ⇒ Object (readonly)

Returns the value of attribute query.



12
13
14
# File 'app/components/uchi/ui/search_form.rb', line 12

def query
  @query
end

Instance Method Details

#label ⇒ Object



19
20
21
# File 'app/components/uchi/ui/search_form.rb', line 19

def label
  Uchi::I18n.translate("search.label", default: "Search")
end

#path ⇒ Object



23
24
25
# File 'app/components/uchi/ui/search_form.rb', line 23

def path
  uchi_path_to(:search)
end

#render? ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
# File 'app/components/uchi/ui/search_form.rb', line 27

def render?
  Uchi::Repository.any_searchable?
end