# coding: utf-8 module Lolita module Configuration # Lolita::Configuration::Filter is for filtering data in list view. # By now it supports these field types: # - Array # - Boolean # # To use it, call "filter" method in list block, filter method accepts field names # as arguments. You can pass block and configure each field. Field configuration is just like in tab configuration. # # === Examples # # # this will build country select field and is_deleted checkbox # list do # filter :country, :is_deleted # end # # # For example you have text field "status" with values opened,closed,rejected # list do # filter do # field :status, :array, :values=> %w(open closed rejected) # field :is_deleted, :title => "Deleted" # end # end # class Filter include Lolita::Builder attr_reader :dbi def initialize(dbi,*args,&block) @dbi = dbi @fields=Lolita::Configuration::Fields.new set_attributes(*args) self.instance_eval(&block) if block_given? end def field *args, &block field=Lolita::Configuration::Factory::Field.create(self.dbi,*args,&block) field @fields<fields as Array. # Each array element can be Lolita::Configuration::Field object or # Hash, that will be passed to #field method. def fields=(fields) if fields.is_a?(Array) fields.each{|field_attr| if field_attr.is_a?(Lolita::Configuration::Field) @fields<