Sha256: f1734c592b50fc4cf61a9c731a7a089646fc5b9a3fb33ae7c7ecdc96315be295

Contents?: true

Size: 805 Bytes

Versions: 27

Compression:

Stored size: 805 Bytes

Contents

module Avo
  module Fields
    class TimeField < DateTimeField
      attr_reader :format
      attr_reader :picker_format

      def initialize(id, **args, &block)
        super(id, **args, &block)

        add_string_prop args, :picker_format, "H:i:S"
        add_string_prop args, :format, "TT"
      end

      def formatted_value
        return nil if value.nil?

        value.utc.to_time.iso8601
      end

      def edit_formatted_value
        return nil if value.nil?

        value.utc.iso8601
      end

      def fill_field(record, key, value, params)
        if value.in?(["", nil])
          record.send(:"#{id}=", value)

          return record
        end

        return record if value.blank?

        record.send(:"#{id}=", utc_time(value))

        record
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
avo-3.14.3 lib/avo/fields/time_field.rb
avo-3.14.2 lib/avo/fields/time_field.rb
avo-3.14.1 lib/avo/fields/time_field.rb
avo-3.14.0 lib/avo/fields/time_field.rb
avo-3.13.7 lib/avo/fields/time_field.rb
avo-3.13.6 lib/avo/fields/time_field.rb
avo-3.13.5 lib/avo/fields/time_field.rb
avo-3.13.4 lib/avo/fields/time_field.rb
avo-3.13.3 lib/avo/fields/time_field.rb
avo-3.13.2 lib/avo/fields/time_field.rb
avo-3.13.1 lib/avo/fields/time_field.rb
avo-3.13.0 lib/avo/fields/time_field.rb
avo-3.12.0 lib/avo/fields/time_field.rb
avo-3.11.10 lib/avo/fields/time_field.rb
avo-3.11.9 lib/avo/fields/time_field.rb
avo-3.11.8 lib/avo/fields/time_field.rb
avo-3.11.7 lib/avo/fields/time_field.rb
avo-3.11.6 lib/avo/fields/time_field.rb
avo-3.11.5 lib/avo/fields/time_field.rb
avo-3.11.4 lib/avo/fields/time_field.rb