Class: Voom::Presenters::DSL::Components::DateField

Inherits:
DatetimeBase show all
Defined in:
lib/voom/presenters/dsl/components/date_field.rb

Constant Summary collapse

DEFAULT_HINT =
'Enter date as MM/DD/YYYY'
DEFAULT_ERROR =
"Invalid date. #{DEFAULT_HINT}"

Constants inherited from TextField

TextField::VALID_CASE_TYPES

Instance Attribute Summary collapse

Attributes inherited from DatetimeBase

#picker

Attributes inherited from TextField

#auto_complete, #behavior, #case_type, #full_width, #required

Attributes inherited from Input

#dirtyable, #disabled, #name

Attributes inherited from EventBase

#event_parent_id

Attributes included from Mixins::Event

#events

Attributes inherited from Base

#attributes, #css_class, #draggable, #drop_zone, #id, #tag, #type

Instance Method Summary collapse

Methods inherited from DatetimeBase

#clear_icon

Methods inherited from TextField

#hint, #icon, #label, #pattern, #value

Methods included from Mixins::Tooltips

#tooltip

Methods included from Mixins::Event

#event

Methods inherited from Base

#expand!

Methods included from Pluggable

#include_plugins, #plugin, #plugin_module

Methods included from Mixins::YieldTo

#yield_to

Methods included from Serializer

#to_hash

Methods included from Lockable

#locked?

Constructor Details

#initialize(**attribs_, &block) ⇒ DateField

Returns a new instance of DateField.



13
14
15
16
17
18
19
20
21
22
# File 'lib/voom/presenters/dsl/components/date_field.rb', line 13

def initialize(**attribs_, &block)
  super(type: :date, **attribs_, &block)
  merge_config(:min_date)
  merge_config(:max_date)
  unless @picker
    @hint ||= DEFAULT_HINT
    @validation_error ||= DEFAULT_ERROR
  end
  expand!
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



11
12
13
# File 'lib/voom/presenters/dsl/components/date_field.rb', line 11

def config
  @config
end

Instance Method Details

#validation_error(error = nil) ⇒ Object



24
25
26
27
# File 'lib/voom/presenters/dsl/components/date_field.rb', line 24

def validation_error(error=nil)
  return @validation_error if locked?
  @validation_error ||= error
end