filterrific 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +16 -1
- data/{LICENSE → MIT-LICENSE} +1 -1
- data/README.md +118 -0
- data/Rakefile +9 -54
- data/doc/Overview diagram.graffle/data.plist +1012 -1296
- data/doc/development_notes/controller_api.txt +8 -1
- data/doc/meta.md +27 -0
- data/lib/filterrific.rb +3 -9
- data/lib/filterrific/action_view_extension.rb +15 -0
- data/lib/filterrific/active_record_extension.rb +71 -0
- data/lib/filterrific/engine.rb +26 -0
- data/lib/filterrific/param_set.rb +31 -22
- data/lib/filterrific/version.rb +3 -0
- data/spec/action_view_extension_spec.rb +16 -0
- data/spec/active_record_extension_spec.rb +85 -0
- data/spec/filterrific_spec.rb +5 -0
- data/spec/param_set_spec.rb +109 -0
- data/spec/spec_helper.rb +6 -0
- data/vendor/assets/images/filterrific-spinner.gif +0 -0
- data/vendor/assets/javascripts/filterrific-jquery.js +97 -0
- metadata +135 -86
- data/README.rdoc +0 -19
- data/VERSION +0 -1
- data/doc/Overview diagram.graffle/QuickLook/Preview.pdf +0 -0
- data/doc/Overview diagram.graffle/QuickLook/Thumbnail.tiff +0 -0
- data/doc/documentation.md +0 -34
- data/doc/ideas.txt +0 -107
- data/doc/todo.md +0 -21
- data/doc/workflow.md +0 -17
- data/filterrific.gemspec +0 -75
- data/lib/filterrific/model_mixin.rb +0 -48
- data/lib/filterrific/railtie.rb +0 -25
- data/lib/filterrific/view_helpers.rb +0 -35
- data/test/helper.rb +0 -10
- data/test/test_filterrific.rb +0 -7
data/doc/todo.md
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
To make it work on Rails 3.1:
|
2
|
-
|
3
|
-
* follow kaminari gem for recipe
|
4
|
-
* implement new model api
|
5
|
-
* leave view and controller as is
|
6
|
-
* bump version to 1.0.0 (not backwards compatible)
|
7
|
-
|
8
|
-
Later:
|
9
|
-
* build filterrific-recipes on github wiki
|
10
|
-
* update readme
|
11
|
-
* update view and controller apis
|
12
|
-
|
13
|
-
|
14
|
-
# Implementation Plan for Filterrific
|
15
|
-
|
16
|
-
## Version 0.1.0: Rebuild current Rails2 functionality
|
17
|
-
|
18
|
-
## Add DSL and scope generator
|
19
|
-
## Write specs (http://avdi.org/devblog/2011/04/07/rspec-is-for-the-literate/ also read comments about be_...!)
|
20
|
-
## Add Filterrific form builder
|
21
|
-
|
data/doc/workflow.md
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
# Workflow to Maintain This Gem
|
2
|
-
|
3
|
-
1. Update code and commit it.
|
4
|
-
2. Bump the version with one of the rake tasks:
|
5
|
-
* `rake version:bump:patch` 1.5.3 -> 1.5.4
|
6
|
-
* `rake version:bump:minor` 1.5.3 -> 1.6.0
|
7
|
-
* `rake version:bump:major` 1.5.3 -> 2.0.0
|
8
|
-
* `rake version:write MAJOR=2 MINOR=3 PATCH=6` 1.5.3 -> 2.3.6
|
9
|
-
3. Add entry to CHANGELOG:
|
10
|
-
* h1 for major release
|
11
|
-
* h2 for minor release
|
12
|
-
* h3 for patch release
|
13
|
-
4. Release it.
|
14
|
-
* `rake release`
|
15
|
-
* Optionally release it to Rubyforge: `rake rubyforge:release`
|
16
|
-
* Optionally release it to Gemcutter: `rake gemcutter:release`
|
17
|
-
5. Rinse and repeat
|
data/filterrific.gemspec
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = %q{filterrific}
|
8
|
-
s.version = "1.0.1"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Jo Hund"]
|
12
|
-
s.date = %q{2011-11-09}
|
13
|
-
s.description = %q{
|
14
|
-
The Rails User Interface solution for filtering your ActiveRecord lists:
|
15
|
-
|
16
|
-
* Built from the ground up for Rails3
|
17
|
-
* Build filter forms with ease
|
18
|
-
* Filter ActiveRecord lists using AR scopes
|
19
|
-
* Shuttle filter parameters from view to controller to model in a RESTful way
|
20
|
-
* Auto-generate scopes for AR associations (Planned)
|
21
|
-
* Form builder for filter UI forms (Planned)
|
22
|
-
}
|
23
|
-
s.email = %q{jhund@clearcove.ca}
|
24
|
-
s.extra_rdoc_files = [
|
25
|
-
"LICENSE",
|
26
|
-
"README.rdoc"
|
27
|
-
]
|
28
|
-
s.files = [
|
29
|
-
"CHANGELOG.md",
|
30
|
-
"LICENSE",
|
31
|
-
"README.rdoc",
|
32
|
-
"Rakefile",
|
33
|
-
"VERSION",
|
34
|
-
"doc/Overview diagram.graffle/QuickLook/Preview.pdf",
|
35
|
-
"doc/Overview diagram.graffle/QuickLook/Thumbnail.tiff",
|
36
|
-
"doc/Overview diagram.graffle/data.plist",
|
37
|
-
"doc/Overview diagram.graffle/image1.tiff",
|
38
|
-
"doc/development_notes/api_design.txt",
|
39
|
-
"doc/development_notes/controller_api.txt",
|
40
|
-
"doc/development_notes/model_api.rb",
|
41
|
-
"doc/development_notes/view_api.txt",
|
42
|
-
"doc/documentation.md",
|
43
|
-
"doc/ideas.txt",
|
44
|
-
"doc/todo.md",
|
45
|
-
"doc/workflow.md",
|
46
|
-
"filterrific.gemspec",
|
47
|
-
"lib/filterrific.rb",
|
48
|
-
"lib/filterrific/model_mixin.rb",
|
49
|
-
"lib/filterrific/param_set.rb",
|
50
|
-
"lib/filterrific/railtie.rb",
|
51
|
-
"lib/filterrific/view_helpers.rb",
|
52
|
-
"test/helper.rb",
|
53
|
-
"test/test_filterrific.rb"
|
54
|
-
]
|
55
|
-
s.homepage = %q{http://github.com/jhund/filterrific}
|
56
|
-
s.require_paths = ["lib"]
|
57
|
-
s.rubygems_version = %q{1.5.2}
|
58
|
-
s.summary = %q{The Rails User Interface solution for filtering your ActiveRecord lists.}
|
59
|
-
|
60
|
-
if s.respond_to? :specification_version then
|
61
|
-
s.specification_version = 3
|
62
|
-
|
63
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
64
|
-
s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
65
|
-
s.add_development_dependency(%q<yard>, [">= 0"])
|
66
|
-
else
|
67
|
-
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
68
|
-
s.add_dependency(%q<yard>, [">= 0"])
|
69
|
-
end
|
70
|
-
else
|
71
|
-
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
72
|
-
s.add_dependency(%q<yard>, [">= 0"])
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
@@ -1,48 +0,0 @@
|
|
1
|
-
module Filterrific::ModelMixin
|
2
|
-
|
3
|
-
def self.included(base)
|
4
|
-
base.send :extend, ClassMethods
|
5
|
-
end
|
6
|
-
|
7
|
-
module ClassMethods
|
8
|
-
|
9
|
-
# Adds filterrific behavior to class when called like so:
|
10
|
-
#
|
11
|
-
# filterrific(
|
12
|
-
# :defaults => { :sorted_by => "created_at_asc" },
|
13
|
-
# :scope_names => [:sorted_by, :search_query, :with_state]
|
14
|
-
# )
|
15
|
-
#
|
16
|
-
def filterrific(options = {})
|
17
|
-
# send :include, InstanceMethods
|
18
|
-
cattr_accessor :default_filterrific_params
|
19
|
-
cattr_accessor :filterrific_scope_names
|
20
|
-
self.default_filterrific_params = (options[:defaults] || {}).stringify_keys
|
21
|
-
self.filterrific_scope_names = (options[:scope_names] || []).map { |e| e.to_s }
|
22
|
-
end
|
23
|
-
|
24
|
-
# Returns AR relation based on given filterrific_param_set.
|
25
|
-
#
|
26
|
-
# ModelClass.filterrific_find(@filterrific_param_set)
|
27
|
-
#
|
28
|
-
def filterrific_find(filterrific_param_set)
|
29
|
-
unless filterrific_param_set.is_a?(Filterrific::ParamSet)
|
30
|
-
raise(ArgumentError, "Invalid Filterrific::ParamSet: #{ filterrific_param_set.inspect }")
|
31
|
-
end
|
32
|
-
|
33
|
-
# set initial ar_proxy to including class
|
34
|
-
ar_proxy = self
|
35
|
-
|
36
|
-
# apply filterrific params
|
37
|
-
self.filterrific_scope_names.each do |scope_name|
|
38
|
-
scope_param = filterrific_param_set.send(scope_name)
|
39
|
-
next if scope_param.blank? # skip blank scope_params
|
40
|
-
ar_proxy = ar_proxy.send(scope_name, scope_param)
|
41
|
-
end
|
42
|
-
|
43
|
-
ar_proxy
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
data/lib/filterrific/railtie.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'filterrific'
|
2
|
-
require 'rails'
|
3
|
-
|
4
|
-
module Filterrific
|
5
|
-
|
6
|
-
class Railtie < Rails::Railtie
|
7
|
-
|
8
|
-
initializer "filterrific.model_mixin" do |app|
|
9
|
-
require 'filterrific/model_mixin'
|
10
|
-
ActiveRecord::Base.send(:include, Filterrific::ModelMixin)
|
11
|
-
require 'filterrific/param_set'
|
12
|
-
end
|
13
|
-
|
14
|
-
initializer "filterrific.view_helpers" do |app|
|
15
|
-
require 'filterrific/view_helpers'
|
16
|
-
ActionView::Base.send(:include, Filterrific::ViewHelpers)
|
17
|
-
end
|
18
|
-
|
19
|
-
# to_prepare block is executed once in production and before each request in development
|
20
|
-
# config.to_prepare do
|
21
|
-
# end
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
module Filterrific::ViewHelpers
|
2
|
-
|
3
|
-
# renders javascript to observe filter form
|
4
|
-
def observe_list_options_filter(options = {})
|
5
|
-
# default options
|
6
|
-
options = {
|
7
|
-
:form_id => 'list_options_filter',
|
8
|
-
:method => :get,
|
9
|
-
:live_field_ids => [],
|
10
|
-
:url => url_for(:controller => controller.controller_path, :action => controller.action_name)
|
11
|
-
}.merge(options)
|
12
|
-
# observe the entire form regularly (triggers e.g. when a select option is clicked)
|
13
|
-
# observe_form(
|
14
|
-
# options[:form_id],
|
15
|
-
# :function => observer_ajax_javascript(options, 'value'),
|
16
|
-
# :frequency => 0.5
|
17
|
-
# )
|
18
|
-
end
|
19
|
-
|
20
|
-
def render_list_options_spinner
|
21
|
-
%(<span id="list_options_spinner" class="spinner" style="display:none;"> </span>)
|
22
|
-
end
|
23
|
-
|
24
|
-
private
|
25
|
-
|
26
|
-
def observer_ajax_javascript(options, parameters_to_be_submitted)
|
27
|
-
# options = {
|
28
|
-
# :with => parameters_to_be_submitted,
|
29
|
-
# :loading => "$('#list_options_spinner').show()",
|
30
|
-
# :complete => "$('#list_options_spinner').hide()"
|
31
|
-
# }.merge(options)
|
32
|
-
# remote_function(options)
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
data/test/helper.rb
DELETED