Sha256: 9335f49a8844e78207d79d4b6f5cb9e39153572fc70bec1f3021a362784cc8dc

Contents?: true

Size: 1.24 KB

Versions: 9

Compression:

Stored size: 1.24 KB

Contents

module Headmin
  module Filter
    class OptionsView < 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

      def collection
        @collection || []
      end

      private

      def id
        "#{name}_value"
      end

      def name
        @name || attribute
      end

      def default_base_options
        {
          label: label,
          name: attribute,
          display_values: collection,
          filter: Headmin::Filter::Text.new(name, @params),
          allowed_operators: Headmin::Filter::Text::OPERATORS - %w[starts_with ends_with 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"
          },
          collection: collection,
          selected: selected,
          class: "form-select"
        }
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

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