Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Somatics Filter aims to enable record filtering in the admin panel. It is easy-to-use, database- and platform-independent. Somatics Filter is now compatible with Rails 2 and Rails 3

  1. Installation

    # Rails 2:
    # In environment.rb, add
    config.gem 'searchlogic'
    
    # Rails 3:
    # In Gemfile
    gem 'meta_search'
    
    script/plugin install git://github.com/timcharper/calendar_date_select.git
    script/plugin install git://github.com/inspiresynergy/somatics_filter.git
  2. Specify available filters in model

    # We have the model
    Post(id: integer, title: string, content: text, date: date, show: boolean, state: string)
    
    # Add filter is easy (Add to post.rb)
    has_filter :id, :integer
    has_filter :title, :string
    has_filter :content, :text
    has_filter :date, :date
    has_filter :show, :boolean
    has_filter :state, :list, :values => ['Draft', 'Posted', 'Closed']
    
  3. Accept and apply query in controller

    # In PostsController
    def index
      @posts = Post.apply_query(params).paginate(:page => params[:page])
      # Some other codes
    end
    
  4. Render the filter form in view

    # In index.html.erb
    <%= somatics_filter_for :post %>
  5. Enjoy!

# Supported Filter Types: :integer, :float, :string, :text, :boolean, :list, :date, :custom

# List Filter: Allow User to select the matching value
has_filter :state, :list, :values => ['New', 'Drafted', 'Published']

# Default Filter: Filters that are set as default
has_filter :id, :integer, :default => true

# Set the Default Operator and Value
has_filter :name, :string, :default_operator => 'contains', :default_value => 'test'

# Custom Filter: Apply the named scope defined
scope :available, where(:state => 'available')
has_filter :available, :custom

SomaticsFilter depends on the use of searchlogic/meta_search and calandar_date_select.

SomaticsFilter can be used with SomaticsGenerator which handles all the front-end code generations. The only things needed to do is setting the available filters.

SomaticsFilter is developed by Inspire Synergy – Benjamin Wong, Gary Or and a whole bunch of cool contributors.

Copyright © 2010 Inspire Synergy Limited, released under the MIT license

About

Rewrite of redmine_filter

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages