Class: RubyUI::DataTableSearch
- Defined in:
- lib/ruby_ui/data_table/data_table_search.rb
Constant Summary
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(path:, name: "search", value: nil, frame_id: nil, placeholder: "Search...", debounce: 300, preserved_params: {}, **attrs) ⇒ DataTableSearch
constructor
A new instance of DataTableSearch.
- #view_template ⇒ Object
Constructor Details
#initialize(path:, name: "search", value: nil, frame_id: nil, placeholder: "Search...", debounce: 300, preserved_params: {}, **attrs) ⇒ DataTableSearch
Returns a new instance of DataTableSearch.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/ruby_ui/data_table/data_table_search.rb', line 5 def initialize(path:, name: "search", value: nil, frame_id: nil, placeholder: "Search...", debounce: 300, preserved_params: {}, **attrs) @path = path @name = name @value = value @frame_id = frame_id @placeholder = placeholder @debounce = debounce @preserved_params = preserved_params super(**attrs) end |
Instance Method Details
#view_template ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/ruby_ui/data_table/data_table_search.rb', line 16 def view_template form_attrs = {method: "get", action: @path} form_attrs[:data] = form_data form(**attrs.merge(form_attrs)) do render RubyUI::Input.new( type: :search, name: @name, value: @value, placeholder: @placeholder, autocomplete: "off" ) @preserved_params.each do |k, v| next if v.nil? || (v.respond_to?(:empty?) && v.empty?) next if k.to_s == @name input(type: "hidden", name: k.to_s, value: v.to_s) end end end |