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/spec/spec_helper.rb
ADDED
Binary file
|
@@ -0,0 +1,97 @@
|
|
1
|
+
/**
|
2
|
+
* Javascript behaviors for Filterrific.
|
3
|
+
* http://filterrific.clearcove.ca
|
4
|
+
*
|
5
|
+
* Requires jQuery 1.7.0 or later.
|
6
|
+
*
|
7
|
+
* Released under the MIT license
|
8
|
+
*
|
9
|
+
*/
|
10
|
+
|
11
|
+
|
12
|
+
//
|
13
|
+
// Embed jquery.observe_field.js to observe Filterrific filter inputs
|
14
|
+
//
|
15
|
+
// Copied from https://github.com/splendeo/jquery.observe_field
|
16
|
+
//
|
17
|
+
(function($) {
|
18
|
+
$.fn.observe_field = function(frequency, callback) {
|
19
|
+
frequency = frequency * 1000; // translate to milliseconds
|
20
|
+
return this.each(function(){
|
21
|
+
var $this = $(this);
|
22
|
+
var prev = $this.val();
|
23
|
+
var check = function() {
|
24
|
+
if(removed()){ // if removed clear the interval and don't fire the callback
|
25
|
+
if(ti) clearInterval(ti);
|
26
|
+
return;
|
27
|
+
}
|
28
|
+
var val = $this.val();
|
29
|
+
if(prev != val){
|
30
|
+
prev = val;
|
31
|
+
$this.map(callback); // invokes the callback on $this
|
32
|
+
}
|
33
|
+
};
|
34
|
+
var removed = function() {
|
35
|
+
return $this.closest('html').length == 0
|
36
|
+
};
|
37
|
+
var reset = function() {
|
38
|
+
if(ti){
|
39
|
+
clearInterval(ti);
|
40
|
+
ti = setInterval(check, frequency);
|
41
|
+
}
|
42
|
+
};
|
43
|
+
check();
|
44
|
+
var ti = setInterval(check, frequency); // invoke check periodically
|
45
|
+
// reset counter after user interaction
|
46
|
+
$this.bind('keyup click mousemove', reset); //mousemove is for selects
|
47
|
+
});
|
48
|
+
};
|
49
|
+
})(jQuery);
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
// Create global Filterrific namespace
|
55
|
+
if (typeof Filterrific === 'undefined') {
|
56
|
+
var Filterrific = {};
|
57
|
+
}
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
// Define function to submit Filterrific filter form
|
62
|
+
Filterrific.submitFilterForm = function(){
|
63
|
+
var form = $(this).parents("form"),
|
64
|
+
url = form.attr("action");
|
65
|
+
// turn on spinner
|
66
|
+
$('.filterrific_spinner').show();
|
67
|
+
// Submit ajax request
|
68
|
+
$.ajax({
|
69
|
+
url: url,
|
70
|
+
data: form.serialize(),
|
71
|
+
type: 'GET',
|
72
|
+
dataType: 'script'
|
73
|
+
}).done(function( msg ) {
|
74
|
+
$('.filterrific_spinner').hide();
|
75
|
+
});
|
76
|
+
};
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
// Initialize Filterrific event observers
|
81
|
+
(function($) {
|
82
|
+
|
83
|
+
// Add change event handler to all Filterrific filter inputs.
|
84
|
+
$(document).on(
|
85
|
+
"change",
|
86
|
+
"#filterrific_filter :input",
|
87
|
+
Filterrific.submitFilterForm
|
88
|
+
);
|
89
|
+
|
90
|
+
// Add periodic observer to selected inputs.
|
91
|
+
// Use this for text fields you want to observe for change, e.g., a search input.
|
92
|
+
$("#filterrific_filter :input.js-periodically-observed").observe_field(
|
93
|
+
0.5,
|
94
|
+
Filterrific.submitFilterForm
|
95
|
+
);
|
96
|
+
|
97
|
+
})(jQuery);
|
metadata
CHANGED
@@ -1,119 +1,168 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: filterrific
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.0
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 0
|
9
|
-
- 1
|
10
|
-
version: 1.0.1
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Jo Hund
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
12
|
+
date: 2013-05-08 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rails
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.0.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.0.0
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: sqlite3
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: bundler
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 1.0.0
|
54
|
+
type: :development
|
23
55
|
prerelease: false
|
24
|
-
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
57
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.0.0
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rake
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
33
70
|
type: :development
|
34
|
-
version_requirements: *id001
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: yard
|
37
71
|
prerelease: false
|
38
|
-
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: sqlite3
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
39
81
|
none: false
|
40
|
-
requirements:
|
41
|
-
- -
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
|
44
|
-
segments:
|
45
|
-
- 0
|
46
|
-
version: "0"
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
47
86
|
type: :development
|
48
|
-
|
49
|
-
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: rspec-rails
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
description: ! "\n The Rails User Interface solution for filtering your ActiveRecord
|
111
|
+
lists:\n\n * Built from the ground up for Rails3 or higher\n * Build filter
|
112
|
+
forms with ease\n * Filter ActiveRecord lists using AR scopes\n * Shuttle
|
113
|
+
filter parameters from view to controller to model\n "
|
50
114
|
email: jhund@clearcove.ca
|
51
115
|
executables: []
|
52
|
-
|
53
116
|
extensions: []
|
54
|
-
|
55
|
-
|
56
|
-
- LICENSE
|
57
|
-
- README.rdoc
|
58
|
-
files:
|
117
|
+
extra_rdoc_files: []
|
118
|
+
files:
|
59
119
|
- CHANGELOG.md
|
60
|
-
- LICENSE
|
61
|
-
- README.rdoc
|
120
|
+
- MIT-LICENSE
|
62
121
|
- Rakefile
|
63
|
-
-
|
64
|
-
- doc/Overview diagram.graffle/QuickLook/Preview.pdf
|
65
|
-
- doc/Overview diagram.graffle/QuickLook/Thumbnail.tiff
|
66
|
-
- doc/Overview diagram.graffle/data.plist
|
67
|
-
- doc/Overview diagram.graffle/image1.tiff
|
122
|
+
- README.md
|
68
123
|
- doc/development_notes/api_design.txt
|
69
124
|
- doc/development_notes/controller_api.txt
|
70
125
|
- doc/development_notes/model_api.rb
|
71
126
|
- doc/development_notes/view_api.txt
|
72
|
-
- doc/
|
73
|
-
- doc/
|
74
|
-
- doc/
|
75
|
-
-
|
76
|
-
- filterrific.
|
77
|
-
- lib/filterrific.rb
|
78
|
-
- lib/filterrific/model_mixin.rb
|
127
|
+
- doc/meta.md
|
128
|
+
- doc/Overview diagram.graffle/data.plist
|
129
|
+
- doc/Overview diagram.graffle/image1.tiff
|
130
|
+
- lib/filterrific/action_view_extension.rb
|
131
|
+
- lib/filterrific/active_record_extension.rb
|
132
|
+
- lib/filterrific/engine.rb
|
79
133
|
- lib/filterrific/param_set.rb
|
80
|
-
- lib/filterrific/
|
81
|
-
- lib/filterrific
|
82
|
-
-
|
83
|
-
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
134
|
+
- lib/filterrific/version.rb
|
135
|
+
- lib/filterrific.rb
|
136
|
+
- spec/action_view_extension_spec.rb
|
137
|
+
- spec/active_record_extension_spec.rb
|
138
|
+
- spec/filterrific_spec.rb
|
139
|
+
- spec/param_set_spec.rb
|
140
|
+
- spec/spec_helper.rb
|
141
|
+
- vendor/assets/images/filterrific-spinner.gif
|
142
|
+
- vendor/assets/javascripts/filterrific-jquery.js
|
143
|
+
homepage: http://filterrific.clearcove.ca
|
144
|
+
licenses:
|
145
|
+
- MIT
|
88
146
|
post_install_message:
|
89
147
|
rdoc_options: []
|
90
|
-
|
91
|
-
require_paths:
|
148
|
+
require_paths:
|
92
149
|
- lib
|
93
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
150
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
151
|
none: false
|
95
|
-
requirements:
|
96
|
-
- -
|
97
|
-
- !ruby/object:Gem::Version
|
98
|
-
|
99
|
-
|
100
|
-
- 0
|
101
|
-
version: "0"
|
102
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
|
+
requirements:
|
153
|
+
- - ! '>='
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
version: '0'
|
156
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
157
|
none: false
|
104
|
-
requirements:
|
105
|
-
- -
|
106
|
-
- !ruby/object:Gem::Version
|
107
|
-
|
108
|
-
segments:
|
109
|
-
- 0
|
110
|
-
version: "0"
|
158
|
+
requirements:
|
159
|
+
- - ! '>='
|
160
|
+
- !ruby/object:Gem::Version
|
161
|
+
version: '0'
|
111
162
|
requirements: []
|
112
|
-
|
113
163
|
rubyforge_project:
|
114
|
-
rubygems_version: 1.
|
164
|
+
rubygems_version: 1.8.25
|
115
165
|
signing_key:
|
116
166
|
specification_version: 3
|
117
|
-
summary:
|
167
|
+
summary: A Rails engine plugin for filtering ActiveRecord ActiveRecord lists.
|
118
168
|
test_files: []
|
119
|
-
|
data/README.rdoc
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
= Filterrific
|
2
|
-
|
3
|
-
Add filter controls to your ActiveRecord lists and persist filter settings via session or DB.
|
4
|
-
|
5
|
-
MIT licensed.
|
6
|
-
|
7
|
-
== Note on Patches/Pull Requests
|
8
|
-
|
9
|
-
* Fork the project.
|
10
|
-
* Make your feature addition or bug fix.
|
11
|
-
* Add tests for it. This is important so I don't break it in a
|
12
|
-
future version unintentionally.
|
13
|
-
* Commit, do not mess with rakefile, version, or history.
|
14
|
-
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
15
|
-
* Send me a pull request. Bonus points for topic branches.
|
16
|
-
|
17
|
-
== Copyright
|
18
|
-
|
19
|
-
Copyright (c) 2010 Jo Hund. See (MIT) LICENSE for details.
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
1.0.1
|
Binary file
|
Binary file
|
data/doc/documentation.md
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
# Filterrific Documentation
|
2
|
-
|
3
|
-
## Word list
|
4
|
-
|
5
|
-
* Filterrific - the gem
|
6
|
-
* Filterrific::Param - individual element of a *FilterrificParamSet*.
|
7
|
-
Defines how the AR list should be filtered. Managed via instance of *FilterrificParamSet* class.
|
8
|
-
* Filterrific::ScopeNames - List of *Scope* names that are available to *Filterrific*.
|
9
|
-
* Filterrific::ParamSet - Container for *FilterrificParams*
|
10
|
-
* Filterrific::Form - a HTML form used to define *FilterrificParams*
|
11
|
-
* Scope - An ActiveRecord scope (formerly known as named_scope)
|
12
|
-
|
13
|
-
## Brain dump
|
14
|
-
|
15
|
-
* Scenarios
|
16
|
-
* Saved search (persist FilterrificParamSet in DB)
|
17
|
-
* Will paginate/kaminari integration
|
18
|
-
* Session persistence
|
19
|
-
* Interface for JS client side app to get collections of data via JSON REST
|
20
|
-
* integrate with PG fulltext search (pg_search)
|
21
|
-
* Defining Scopes
|
22
|
-
* Belongs_to
|
23
|
-
* Has_many
|
24
|
-
* Sorting
|
25
|
-
* Full text search (Postgres, Like, regex, Sphinx?)
|
26
|
-
* Filterrific form inputs
|
27
|
-
* checkboxes
|
28
|
-
* multi selects
|
29
|
-
|
30
|
-
## Requirements
|
31
|
-
|
32
|
-
* Rails3 (or 3.1?)
|
33
|
-
|
34
|
-
|
data/doc/ideas.txt
DELETED
@@ -1,107 +0,0 @@
|
|
1
|
-
20110418: Look at this when building API: https://github.com/ryan-allen/lispy
|
2
|
-
|
3
|
-
|
4
|
-
20110414 Related project:
|
5
|
-
|
6
|
-
* https://github.com/plataformatec/has_scope
|
7
|
-
|
8
|
-
20110221 Promotion:
|
9
|
-
|
10
|
-
* railscasts (even ask for review/feedback)
|
11
|
-
* railsinside
|
12
|
-
* ruby toolbox
|
13
|
-
|
14
|
-
|
15
|
-
20110205: figuring out best prefix for namespacing filterrific
|
16
|
-
|
17
|
-
balance between shortness and expression:
|
18
|
-
|
19
|
-
f
|
20
|
-
fc
|
21
|
-
ft
|
22
|
-
frc
|
23
|
-
ftf
|
24
|
-
fifc
|
25
|
-
flfc
|
26
|
-
frfc
|
27
|
-
ftfc
|
28
|
-
ftrfc
|
29
|
-
fltrfc
|
30
|
-
filtrfc
|
31
|
-
filterrific
|
32
|
-
|
33
|
-
20110112: see if I can learn something here:
|
34
|
-
http://www.idolhands.com/ruby-on-rails/guides-tips-and-tutorials/add-filters-to-views-using-named-scopes-in-rails
|
35
|
-
|
36
|
-
|
37
|
-
20101227: get inspiration from this project: https://github.com/neerajdotname/admin_data
|
38
|
-
look especially at their query builder in the heroku demo project (add conditions like Finder search)
|
39
|
-
|
40
|
-
|
41
|
-
Glean specific code from these projects:
|
42
|
-
|
43
|
-
20100224 CVIMS
|
44
|
-
201001 cando
|
45
|
-
201001 PTS
|
46
|
-
201001 Quentin-rails-backend
|
47
|
-
stratadocs (list starts with self as AR proxy)
|
48
|
-
|
49
|
-
|
50
|
-
view
|
51
|
-
(skip these for now?)
|
52
|
-
apply all relevant options from formtastic
|
53
|
-
integrate with formtastic?
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
SAVED SEARCHES
|
63
|
-
==============
|
64
|
-
|
65
|
-
See cando for implementation
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
CONTENT FOR README
|
71
|
-
==================
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
This Rails engine makes it super simple to add filtering to your rails list views.
|
77
|
-
|
78
|
-
Some of the features:
|
79
|
-
---------------------
|
80
|
-
|
81
|
-
* RESTful
|
82
|
-
* conditions, sorting, maybe grouping?
|
83
|
-
* works with pagination
|
84
|
-
* settings can be persisted in session or via database for saved searches
|
85
|
-
* works with ActiveRecord
|
86
|
-
* gets along well with will_paginate
|
87
|
-
|
88
|
-
Possibilities:
|
89
|
-
-------------
|
90
|
-
|
91
|
-
* integrate with thinking_sphinx
|
92
|
-
* integrate with formtastic
|
93
|
-
* integrate with will_paginate
|
94
|
-
* integrate with make_resourceful
|
95
|
-
|
96
|
-
Here is how it works:
|
97
|
-
---------------------
|
98
|
-
|
99
|
-
Filterrific relies heavily on scopes. Each filter dimension has its own scope. Filterrific makes it
|
100
|
-
easy to shuttle user settings to your controllers and models for queries, and back to the views.
|
101
|
-
|
102
|
-
|
103
|
-
Related projects
|
104
|
-
================
|
105
|
-
|
106
|
-
* http://github.com/plataformatec/has_scope
|
107
|
-
|