Class: RubyUI::DataTablePerPageSelect
- Defined in:
- lib/generators/ruby_cms/templates/components/ruby_ui/data_table/data_table_per_page_select.rb
Constant Summary
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(path:, name: "per_page", value: nil, frame_id: nil, options: [ 5, 10, 25, 50 ], **attrs) ⇒ DataTablePerPageSelect
constructor
A new instance of DataTablePerPageSelect.
- #view_template ⇒ Object
Constructor Details
#initialize(path:, name: "per_page", value: nil, frame_id: nil, options: [ 5, 10, 25, 50 ], **attrs) ⇒ DataTablePerPageSelect
Returns a new instance of DataTablePerPageSelect.
5 6 7 8 9 10 11 12 |
# File 'lib/generators/ruby_cms/templates/components/ruby_ui/data_table/data_table_per_page_select.rb', line 5 def initialize(path:, name: "per_page", value: nil, frame_id: nil, options: [ 5, 10, 25, 50 ], **attrs) @path = path @name = name @value = value @frame_id = frame_id @options = super(**attrs) end |
Instance Method Details
#view_template ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/generators/ruby_cms/templates/components/ruby_ui/data_table/data_table_per_page_select.rb', line 14 def view_template form_attrs = { action: @path, method: "get" } form_attrs[:data] = { turbo_frame: @frame_id } if @frame_id form(**attrs.merge(form_attrs)) do render RubyUI::NativeSelect.new(name: @name, onchange: safe("this.form.requestSubmit()")) do @options.each do |opt| option_attrs = { value: opt.to_s } option_attrs[:selected] = true if opt.to_s == @value.to_s option(**option_attrs) { plain opt.to_s } end end end end |