Sha256: 2b0e4450a22765073703bef8a76d381422f9f511ef17c035824188ef37622292

Contents?: true

Size: 655 Bytes

Versions: 18

Compression:

Stored size: 655 Bytes

Contents

require_relative 'text_field'

module Avo
  module Fields
    class NumberField < TextField
      def initialize(name, **args, &block)
        @defaults = {
          sortable: true,
          component: 'number-field',
          computable: true,
        }

        super(name, **args, &block)

        @min = args[:min].present? ? args[:min].to_i : nil
        @max = args[:max].present? ? args[:max].to_i : nil
        @step = args[:step].present? ? args[:step].to_i : nil
      end

      def hydrate_field(fields, model, resource, view)
        {
          min: @min,
          max: @max,
          step: @step,
        }
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

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