Class: Alchemy::Admin::Filters::Datepicker

Inherits:
Base
  • Object
show all
Defined in:
app/models/alchemy/admin/filters/datepicker.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#name, #resource_name

Instance Method Summary collapse

Methods inherited from Base

#applied_filter_component

Constructor Details

#initialize(name:, resource_name:, input_type: :datetime) ⇒ Datepicker

Creates a resource filter that displays as a datepicker.

Examples:

Alchemy::Admin::Filters::Datepicker.new(
name: :created_at_lt,
resource_name: :events,
mode: :single,
default: "2023-01-01"

Parameters:

  • name (String)

    The name of the filter.

  • resource_name (String)

    The name of the resource.

  • input_type (Symbol) (defaults to: :datetime)

    The input type of the datepicker. Can be :date, :datetime, or :time.



18
19
20
21
# File 'app/models/alchemy/admin/filters/datepicker.rb', line 18

def initialize(name:, resource_name:, input_type: :datetime)
  super(name:, resource_name:)
  @input_type = input_type
end

Instance Attribute Details

#input_typeObject (readonly)

Returns the value of attribute input_type.



7
8
9
# File 'app/models/alchemy/admin/filters/datepicker.rb', line 7

def input_type
  @input_type
end

Instance Method Details

#input_component(params, _query) ⇒ Alchemy::Admin::Resource::DatepickerFilter

Returns a datepicker filter component.

Parameters:

  • params (Hash)

    The search filter params.

  • query (Ransack::Search)

    The current search query.

Returns:



27
28
29
30
31
32
33
34
# File 'app/models/alchemy/admin/filters/datepicker.rb', line 27

def input_component(params, _query)
  Alchemy::Admin::Resource::DatepickerFilter.new(
    name:,
    label: translated_name,
    input_type: @input_type,
    params:
  )
end