Class: Uchi::Ui::Index::RecordsTable::SearchForm
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Uchi::Ui::Index::RecordsTable::SearchForm
- Defined in:
- app/components/uchi/ui/index/records_table/search_form.rb
Overview
Renders a search for the records table.
Based on Flowbites Simple search input (https://flowbite.com/docs/forms/search-input/#simple-search-input)
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#repository ⇒ Object
readonly
Returns the value of attribute repository.
Instance Method Summary collapse
-
#initialize(params:, repository:) ⇒ SearchForm
constructor
A new instance of SearchForm.
- #query ⇒ Object
- #scope ⇒ Object
- #scoped? ⇒ Boolean
- #sort_by ⇒ Object
- #sort_by? ⇒ Boolean
- #sort_direction ⇒ Object
- #sort_direction? ⇒ Boolean
Constructor Details
#initialize(params:, repository:) ⇒ SearchForm
Returns a new instance of SearchForm.
12 13 14 15 16 |
# File 'app/components/uchi/ui/index/records_table/search_form.rb', line 12 def initialize(params:, repository:) super() @params = params @repository = repository end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
10 11 12 |
# File 'app/components/uchi/ui/index/records_table/search_form.rb', line 10 def params @params end |
#repository ⇒ Object (readonly)
Returns the value of attribute repository.
10 11 12 |
# File 'app/components/uchi/ui/index/records_table/search_form.rb', line 10 def repository @repository end |
Instance Method Details
#query ⇒ Object
18 19 20 |
# File 'app/components/uchi/ui/index/records_table/search_form.rb', line 18 def query params[:query] end |
#scope ⇒ Object
22 23 24 |
# File 'app/components/uchi/ui/index/records_table/search_form.rb', line 22 def scope params[:scope] end |
#scoped? ⇒ Boolean
26 27 28 |
# File 'app/components/uchi/ui/index/records_table/search_form.rb', line 26 def scoped? scope.present? end |
#sort_by ⇒ Object
30 31 32 |
# File 'app/components/uchi/ui/index/records_table/search_form.rb', line 30 def sort_by params.dig(:sort, :by) end |
#sort_by? ⇒ Boolean
34 35 36 |
# File 'app/components/uchi/ui/index/records_table/search_form.rb', line 34 def sort_by? sort_by.present? end |
#sort_direction ⇒ Object
38 39 40 |
# File 'app/components/uchi/ui/index/records_table/search_form.rb', line 38 def sort_direction params.dig(:sort, :direction) end |
#sort_direction? ⇒ Boolean
42 43 44 |
# File 'app/components/uchi/ui/index/records_table/search_form.rb', line 42 def sort_direction? sort_direction.present? end |