Sha256: efd554b4b0b23899052d375a2b7bf0149d67cce055e3a77293167bc1eaae456c

Contents?: true

Size: 848 Bytes

Versions: 1

Compression:

Stored size: 848 Bytes

Contents

class SomeSearchPanel < Netzke::Basepack::FormPanel
  def config
    orig = super
    {
      :model => "User",
      :title => "Some Search Panel",
      :items => [{:name => :first_name.like}, {:name => :created_at.gt}]
    }.deep_merge orig
  end

  def normalize_field(f)
    f = if f.is_a?(Symbol) || f.is_a?(String) 
      {:name => f.to_s, :operator => default_operator}
    else 
      search_condition = f[:name]
      if search_condition.is_a?(MetaWhere::Column)
        {:name => search_condition.column, :operator => search_condition.method}
      else
        {:name => search_condition.to_s, :operator => default_operator}
      end
    end
    
    f[:disabled] = primary_key_attr?(f)
    
    f = super(f)

    f.merge(:name => [f[:name], "__", f[:operator]].join)
  end
  
  private
    def default_operator
      "gt"
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
netzke-basepack-0.6.0 test/rails_app/app/components/some_search_panel.rb