Class: IronAdmin::Filters::DateRangeComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- IronAdmin::Filters::DateRangeComponent
- Defined in:
- app/components/iron_admin/filters/date_range_component.rb
Overview
Renders a date range filter with from/to inputs.
Instance Attribute Summary collapse
-
#from_value ⇒ Date?
readonly
Start date value.
-
#label ⇒ String
readonly
Filter label.
-
#name ⇒ Symbol
readonly
Filter name.
-
#to_value ⇒ Date?
readonly
End date value.
Instance Method Summary collapse
-
#from_field_name ⇒ String
private
Form field name for start date.
-
#initialize(name:, label: nil, from_value: nil, to_value: nil) ⇒ DateRangeComponent
constructor
A new instance of DateRangeComponent.
-
#input_classes ⇒ String
private
CSS classes for date input fields.
-
#label_classes ⇒ String
private
CSS classes for label elements.
-
#theme ⇒ IronAdmin::Configuration::Theme
private
Theme configuration.
-
#to_field_name ⇒ String
private
Form field name for end date.
Constructor Details
#initialize(name:, label: nil, from_value: nil, to_value: nil) ⇒ DateRangeComponent
Returns a new instance of DateRangeComponent.
23 24 25 26 27 28 |
# File 'app/components/iron_admin/filters/date_range_component.rb', line 23 def initialize(name:, label: nil, from_value: nil, to_value: nil) @name = name @label = label || name.to_s.humanize @from_value = from_value @to_value = to_value end |
Instance Attribute Details
#from_value ⇒ Date? (readonly)
Returns Start date value.
14 15 16 |
# File 'app/components/iron_admin/filters/date_range_component.rb', line 14 def from_value @from_value end |
#label ⇒ String (readonly)
Returns Filter label.
11 12 13 |
# File 'app/components/iron_admin/filters/date_range_component.rb', line 11 def label @label end |
#name ⇒ Symbol (readonly)
Returns Filter name.
8 9 10 |
# File 'app/components/iron_admin/filters/date_range_component.rb', line 8 def name @name end |
#to_value ⇒ Date? (readonly)
Returns End date value.
17 18 19 |
# File 'app/components/iron_admin/filters/date_range_component.rb', line 17 def to_value @to_value end |
Instance Method Details
#from_field_name ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns Form field name for start date.
38 39 40 |
# File 'app/components/iron_admin/filters/date_range_component.rb', line 38 def from_field_name "filters[#{name}_from]" end |
#input_classes ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns CSS classes for date input fields.
56 57 58 59 60 |
# File 'app/components/iron_admin/filters/date_range_component.rb', line 56 def input_classes "block w-full border px-3 py-2 text-sm shadow-sm outline-none " \ "transition duration-150 ease-in-out #{theme.border_radius} #{theme.input_border} " \ "#{theme.card_bg} #{theme.body_text} #{theme.input_focus}" end |
#label_classes ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns CSS classes for label elements.
50 51 52 |
# File 'app/components/iron_admin/filters/date_range_component.rb', line 50 def label_classes "block text-xs font-semibold uppercase tracking-wider #{theme.muted_text}" end |
#theme ⇒ IronAdmin::Configuration::Theme
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns Theme configuration.
32 33 34 |
# File 'app/components/iron_admin/filters/date_range_component.rb', line 32 def theme IronAdmin.configuration.theme end |
#to_field_name ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns Form field name for end date.
44 45 46 |
# File 'app/components/iron_admin/filters/date_range_component.rb', line 44 def to_field_name "filters[#{name}_to]" end |