Sha256: 5e2b2f3368a36b0e182c3ef3b6a5865bc9d95ba552c0be6f54bf8f852858b738

Contents?: true

Size: 1.08 KB

Versions: 8

Compression:

Stored size: 1.08 KB

Contents

module Headmin
  module Filter
    class FieldView < FilterView
      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
        "field_#{@name}".to_sym || attribute
      end

      def default_base_options
        {
          label: label,
          name: "field_#{attribute}".to_sym,
          filter: Headmin::Filter::Field.new(attribute.to_s.to_sym, @params),
          allowed_operators: Headmin::Filter::Field::OPERATORS - %w[in not_in]
        }
      end

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

Version data entries

8 entries across 8 versions & 1 rubygems

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