Sha256: f38e64d3c35dd753293f56c0f079c2bd63987c4224e5734e3c7ae2fce07e0d39

Contents?: true

Size: 1015 Bytes

Versions: 18

Compression:

Stored size: 1015 Bytes

Contents

require_relative 'date_field'

module Avo
  module Fields
    class DatetimeField < DateField
      def initialize(name, **args, &block)
        @defaults = {
          sortable: true,
          component: 'datetime-field',
        }

        super(name, **args, &block)

        @picker_format = args[:picker_format].present? ? args[:picker_format] : 'Y-m-d H:i:S'
        @format = args[:format].present? ? args[:format] : 'YYYY-MM-DD hh:mm:ss A'
        @time_24hr = args[:time_24hr].present? ? args[:time_24hr] : false
        @timezone = args[:timezone].present? ? args[:timezone] : Rails.application.config.time_zone
      end

      def hydrate_field(fields, model, resource, view)
        {
          first_day_of_week: @first_day_of_week,
          picker_format: @picker_format,
          format: @format,
          placeholder: @placeholder,
          enable_time: true,
          time_24hr: @time_24hr,
          timezone: @timezone,
          relative: @relative,
        }
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
avo-0.4.10 lib/avo/app/fields/datetime_field.rb
avo-0.4.9 lib/avo/app/fields/datetime_field.rb
avo-0.4.8 lib/avo/app/fields/datetime_field.rb
avo-0.4.7 lib/avo/app/fields/datetime_field.rb
avo-0.4.6 lib/avo/app/fields/datetime_field.rb
avo-0.4.5 lib/avo/app/fields/datetime_field.rb
avo-0.4.4 lib/avo/app/fields/datetime_field.rb
avo-0.4.3 lib/avo/app/fields/datetime_field.rb
avo-0.4.2 lib/avo/app/fields/datetime_field.rb
avo-0.4.1 lib/avo/app/fields/datetime_field.rb
avo-0.3.2 lib/avo/app/fields/datetime_field.rb
avo-0.3.1 lib/avo/app/fields/datetime_field.rb
avo-0.2.5 lib/avo/app/fields/datetime_field.rb
avo-0.2.4 lib/avo/app/fields/datetime_field.rb
avo-0.2.3 lib/avo/app/fields/datetime_field.rb
avo-0.2.2 lib/avo/app/fields/datetime_field.rb
avo-0.2.1 lib/avo/app/fields/datetime_field.rb
avo-0.2.0 lib/avo/app/fields/datetime_field.rb