Sha256: ed1019467887d0b16215d7746eedc7ae330921819b9145a283a7c773155a45eb

Contents?: true

Size: 903 Bytes

Versions: 9

Compression:

Stored size: 903 Bytes

Contents

module Effective
  module FormInputs
    class DateField < DatetimeField

      def input_html_options
        {
          class: ['form-control', 'effective_date_time_picker', 'effective_date', ('not-date-linked' if not_date_linked?)].compact.join(' '),
          pattern: pattern
        }
      end

      def input_js_options
        { format: format, showTodayButton: false, showClear: false, useCurrent: 'hour', disabledDates: disabled_dates.presence }.compact
      end

      def input_group_options
        { input_group: { class: 'input-group effective_date_time_picker_input_group' }, prepend: content_tag(:span, icon('calendar'), class: 'input-group-text') }
      end

      def datetime_to_s # ruby
        value&.strftime('%F')
      end

      def pattern # html
        '\d{4}(-\d{2})?(-\d{2})?'
      end

      def format # moment.js
        'YYYY-MM-DD'
      end

    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
effective_bootstrap-0.2.3 app/models/effective/form_inputs/date_field.rb
effective_bootstrap-0.2.2 app/models/effective/form_inputs/date_field.rb
effective_bootstrap-0.2.1 app/models/effective/form_inputs/date_field.rb
effective_bootstrap-0.2.0 app/models/effective/form_inputs/date_field.rb
effective_bootstrap-0.1.12 app/models/effective/form_inputs/date_field.rb
effective_bootstrap-0.1.11 app/models/effective/form_inputs/date_field.rb
effective_bootstrap-0.1.10 app/models/effective/form_inputs/date_field.rb
effective_bootstrap-0.1.9 app/models/effective/form_inputs/date_field.rb
effective_bootstrap-0.1.8 app/models/effective/form_inputs/date_field.rb