Sha256: a1846ee9bfa922f3ad9c77975983af56af81ec1cb66b2dba744afe88b5c4fe6c

Contents?: true

Size: 833 Bytes

Versions: 15

Compression:

Stored size: 833 Bytes

Contents

# frozen_string_literal: true
class DatagridFilterCell < FormCellBase
  attribute :form, mandatory: true, description: 'A form object.'
  attribute :filter, mandatory: true, description: 'A Datagrid filter object.'
  attribute :width, description: 'The width of the component.'

  def show
    case options[:filter].type
    when :enum
      ui_component(:select, select_options)
    when :string
      options[:form].search_field(name_option, label: header_option)
    else
      raise 'Filter not supported'
    end
  end

  private

  def header_option
    options[:filter].header
  end

  def name_option
    options[:filter].name
  end

  def select_options
    options.slice(:form, :width).merge(
      name: name_option,
      select_options: options[:filter].options[:select].call,
      label: header_option
    )
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
ad2games-ui_components-2.3.0 app/cells/datagrid_filter/datagrid_filter_cell.rb
ad2games-ui_components-2.1.0 app/cells/datagrid_filter/datagrid_filter_cell.rb
ad2games-ui_components-2.0.14 app/cells/datagrid_filter/datagrid_filter_cell.rb
ad2games-ui_components-2.0.12 app/cells/datagrid_filter/datagrid_filter_cell.rb
ad2games-ui_components-2.0.11 app/cells/datagrid_filter/datagrid_filter_cell.rb
ad2games-ui_components-2.0.10 app/cells/datagrid_filter/datagrid_filter_cell.rb
ad2games-ui_components-2.0.9 app/cells/datagrid_filter/datagrid_filter_cell.rb
ad2games-ui_components-2.0.8 app/cells/datagrid_filter/datagrid_filter_cell.rb
ad2games-ui_components-2.0.7 app/cells/datagrid_filter/datagrid_filter_cell.rb
ad2games-ui_components-2.0.5 app/cells/datagrid_filter/datagrid_filter_cell.rb
ad2games-ui_components-2.0.4 app/cells/datagrid_filter/datagrid_filter_cell.rb
ad2games-ui_components-2.0.3 app/cells/datagrid_filter/datagrid_filter_cell.rb
ad2games-ui_components-2.0.2 app/cells/datagrid_filter/datagrid_filter_cell.rb
ad2games-ui_components-2.0.1 app/cells/datagrid_filter/datagrid_filter_cell.rb
ad2games-ui_components-2.0.0 app/cells/datagrid_filter/datagrid_filter_cell.rb