Sha256: 42e177e5f55a39e90b29bde53f97e04561defd833fb4dc6a1226055192393e73

Contents?: true

Size: 1.18 KB

Versions: 10

Compression:

Stored size: 1.18 KB

Contents

module Headmin
  module Filter
    class FlatpickrView < ViewModel
      def base_options
        keys = %i[name label form]
        options = to_h.slice(*keys)
        default_base_options.merge(options)
      end

      def input_options
        keys = %i[form]
        options = to_h.slice(*keys)
        default_input_options.merge(options)
      end

      private

      def id
        "#{name}_value"
      end

      def name
        @name || attribute
      end

      def label
        @label || I18n.t("attributes.#{attribute}", default: name.to_s)
      end

      def default_base_options
        {
          label: label,
          name: attribute,
          filter: Headmin::Filter::Date.new(name, @params),
          allowed_operators: Headmin::Filter::Date::OPERATORS - %w[in not_in between not_between]
        }
      end

      def default_input_options
        {
          label: false,
          wrapper: false,
          name: nil,
          id: id,
          data: {
            action: "change->filter#updateHiddenValue",
            filter_target: "value",
            filter_row_target: "original"
          },
          class: "form-control"
        }
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
headmin-0.6.3 app/models/headmin/filter/flatpickr_view.rb
headmin-0.6.2 app/models/headmin/filter/flatpickr_view.rb
headmin-0.6.1 app/models/headmin/filter/flatpickr_view.rb
headmin-0.6.0 app/models/headmin/filter/flatpickr_view.rb
headmin-0.5.9 app/models/headmin/filter/flatpickr_view.rb
headmin-0.5.8 app/models/headmin/filter/flatpickr_view.rb
headmin-0.5.7 app/models/headmin/filter/flatpickr_view.rb
headmin-0.5.6 app/models/headmin/filter/flatpickr_view.rb
headmin-0.5.5 app/models/headmin/filter/flatpickr_view.rb
headmin-0.5.4 app/models/headmin/filter/flatpickr_view.rb