filterrific 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,6 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ RSpec.configure do |config|
5
+ # Nothing to do
6
+ end
@@ -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
- hash: 21
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
- date: 2011-11-09 00:00:00 -08:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- name: thoughtbot-shoulda
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
- requirement: &id001 !ruby/object:Gem::Requirement
56
+ version_requirements: !ruby/object:Gem::Requirement
25
57
  none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 3
30
- segments:
31
- - 0
32
- version: "0"
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
- requirement: &id002 !ruby/object:Gem::Requirement
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
- hash: 3
44
- segments:
45
- - 0
46
- version: "0"
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
47
86
  type: :development
48
- version_requirements: *id002
49
- description: "\n The Rails User Interface solution for filtering your ActiveRecord lists:\n\n * Built from the ground up for Rails3\n * Build filter forms with ease\n * Filter ActiveRecord lists using AR scopes\n * Shuttle filter parameters from view to controller to model in a RESTful way\n * Auto-generate scopes for AR associations (Planned)\n * Form builder for filter UI forms (Planned)\n "
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
- extra_rdoc_files:
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
- - VERSION
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/documentation.md
73
- - doc/ideas.txt
74
- - doc/todo.md
75
- - doc/workflow.md
76
- - filterrific.gemspec
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/railtie.rb
81
- - lib/filterrific/view_helpers.rb
82
- - test/helper.rb
83
- - test/test_filterrific.rb
84
- has_rdoc: true
85
- homepage: http://github.com/jhund/filterrific
86
- licenses: []
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
- hash: 3
99
- segments:
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
- hash: 3
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.5.2
164
+ rubygems_version: 1.8.25
115
165
  signing_key:
116
166
  specification_version: 3
117
- summary: The Rails User Interface solution for filtering your ActiveRecord lists.
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
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
-