filterrific 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG.md CHANGED
@@ -1,10 +1,23 @@
1
- ## 1.1.0
1
+ ## 1.2.0
2
+
3
+ * Added simple wrapper for Filterrific::ParamSet.new so that it can be
4
+ instantiated with Filterrific.new instead of Filterrific::ParamSet.new.
5
+ * Overrode ActionView's form_for to add filterrific magic when applied to a
6
+ Filterrific object.
7
+ * Fixed bug with javascript periodic observer, changed css selector class to
8
+ avoid conflicts.
9
+ * Moved observe_form_field jquery plugin into filterrific namespace to avoid
10
+ conflicts.
11
+
12
+
2
13
 
3
- * major refactor
4
- * added specs
5
- * tied in Rails asset pipeline
6
- * added gh-pages branch for documentation
7
14
 
15
+ ## 1.1.0
16
+
17
+ * Major refactor
18
+ * Added specs
19
+ * Tied in Rails asset pipeline
20
+ * Added gh-pages branch for documentation
8
21
 
9
22
 
10
23
  ### 1.0.1
@@ -13,10 +26,11 @@
13
26
 
14
27
 
15
28
 
29
+
16
30
  # 1.0.0
17
31
 
18
32
  * Support for Rails 3.1
19
- * new model api
33
+ * New model api
20
34
 
21
35
 
22
36
 
@@ -25,7 +39,6 @@
25
39
  * Replicate functionality of Rails 2.3 version
26
40
 
27
41
 
28
-
29
42
  ### 0.0.1, released 2010-07-30
30
43
 
31
44
  * Initial setup
data/README.md CHANGED
@@ -1,81 +1,14 @@
1
1
  Filterrific
2
2
  ===========
3
3
 
4
- User configurable filtering of ActiveRecord lists for your Rails app.
5
-
6
- Filterrific is a collection of extensions for ActiveRecord and ActionView
7
- that allow a developer to add user configurable filtering to ActiveRecord lists.
8
-
9
- It comes with the following features:
10
-
11
- * Let your app's users search, filter and sort lists of ActiveRecord objects.
12
- * Add as many AND filter dimensions as you want.
13
- * Persist filter settings in session or DB (for saved searches).
14
- * Integrates with pagination.
15
- * Filters can be reset to default settings.
16
- * Relies on ActiveRecord scopes for building DB queries.
17
- * Comes with the plumbing to shuttle filter settings from a filter UI to
18
- the controller and ActiveRecord.
19
- * Can be used for JSON/XML/HTML response formats.
20
-
21
-
22
- <div style="margin: 3em 0;">
23
- <blockquote>
24
- <p>
25
- I couldn't live without Filterrific. It makes it super easy to add
26
- user configurable reporting to my client projects.
27
- </p>
28
- <small>Jeff Ward, Animikii</small>
29
- </blockquote>
30
- </div>
31
-
32
-
33
- ### Example app 1
34
-
35
- ---
36
-
37
- <img src="http://filterrific.clearcove.ca/images/screenshot_c.png" alt="Filterrific in action"/>
38
- <em>
39
- Example app 1: Filtering a list of members, with saved searches,
40
- pagination and filter reset. List at the left, filters to the right.
41
- </em>
42
-
43
- ---
44
-
45
- ### Example app 2
46
-
47
- ---
48
-
49
- <img src="http://filterrific.clearcove.ca/images/screenshot_q.png" alt="Filterrific in action"/>
50
- <em>
51
- Example app 2: Filtering a list of questions. Filters above, list below.
52
- </em>
53
-
54
- ---
55
-
56
- ### Details
57
-
58
- * Filterrific takes care of shuttling filter settings from your view
59
- to ActiveRecord queries, and of returning matching records back to the view.
60
- You are responsible to implement the aspects that are specific
61
- to your application:
62
- * define the required scopes
63
- * style your filter form and record lists
64
- * You use 3 APIs to integrate Filterrific into your app: Model, View and Controller.
4
+ Filterrific is a Rails Engine plugin that makes it easy to add filtering,
5
+ searching, and sorting to your ActiveRecord lists.
65
6
 
66
7
  Make sure to go to the fantastic [Filterrific documentation](http://filterrific.clearcove.ca)
67
8
  to find out more!
68
9
 
69
10
 
70
11
 
71
- ### Dependencies
72
-
73
- * Rails and ActiveRecord 3.x and 4
74
- * PostgreSQL or MySQL
75
- * Ruby 1.8.7 or greater
76
- * jQuery and Asset pipeline for form observers and spinner
77
-
78
-
79
12
  ### Installation
80
13
 
81
14
  `gem install filterrific`
@@ -102,17 +35,6 @@ or with bundler in your Gemfile:
102
35
 
103
36
 
104
37
 
105
- ### Note on Patches/Pull Requests
106
-
107
- * Fork the project.
108
- * Make your feature addition or bug fix.
109
- * Add tests for it. This is important so I don't break it in a future version unintentionally.
110
- * Commit, do not mess with rakefile, version, or history.
111
- (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)
112
- * Send me a pull request. Bonus points for topic branches.
113
-
114
-
115
-
116
38
  ### Copyright
117
39
 
118
40
  Copyright (c) 2010 - 2013 Jo Hund. See [(MIT) LICENSE](https://github.com/jhund/filterrific/blob/master/MIT-LICENSE) for details.
data/doc/meta.md CHANGED
@@ -9,7 +9,7 @@ Steps for an update
9
9
  -------------------
10
10
 
11
11
  1. Update code and commit it.
12
- 2. Add entry to CHANGELOG:
12
+ 2. Add entry to CHANGELOG and commit it:
13
13
  * h1 for major release
14
14
  * h2 for minor release
15
15
  * h3 for patch release
data/lib/filterrific.rb CHANGED
@@ -2,4 +2,10 @@ require 'filterrific/version'
2
2
  require 'filterrific/engine'
3
3
 
4
4
  module Filterrific
5
+
6
+ # Wrapper around Filterrific::ParamSet initialization
7
+ def self.new(a_resource_class, filterrific_params = {})
8
+ Filterrific::ParamSet.new(a_resource_class, filterrific_params)
9
+ end
10
+
5
11
  end
@@ -3,6 +3,18 @@
3
3
  #
4
4
  module Filterrific::ActionViewExtension
5
5
 
6
+ # Sets all options on form_for to defaults if called with Filterrific object
7
+ def form_for(record, options = {}, &block)
8
+ if record.is_a?(Filterrific::ParamSet)
9
+ options[:as] ||= :filterrific
10
+ options[:html] ||= {}
11
+ options[:html][:method] ||= :get
12
+ options[:html][:id] ||= :filterrific_filter
13
+ options[:url] ||= url_for
14
+ end
15
+ super
16
+ end
17
+
6
18
  # Renders a spinner while the list is being updated
7
19
  def render_filterrific_spinner
8
20
  %(
@@ -1,3 +1,3 @@
1
1
  module Filterrific
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.0"
3
3
  end
@@ -9,13 +9,42 @@
9
9
  */
10
10
 
11
11
 
12
+
13
+ // Create global Filterrific namespace
14
+ if (typeof Filterrific === 'undefined') {
15
+ var Filterrific = {};
16
+ }
17
+
18
+
19
+
20
+ // Define function to submit Filterrific filter form
21
+ Filterrific.submitFilterForm = function(){
22
+ var form = $(this).parents("form"),
23
+ url = form.attr("action");
24
+ // turn on spinner
25
+ $('.filterrific_spinner').show();
26
+ // Submit ajax request
27
+ $.ajax({
28
+ url: url,
29
+ data: form.serialize(),
30
+ type: 'GET',
31
+ dataType: 'script'
32
+ }).done(function( msg ) {
33
+ $('.filterrific_spinner').hide();
34
+ });
35
+ };
36
+
37
+
38
+
12
39
  //
13
40
  // Embed jquery.observe_field.js to observe Filterrific filter inputs
14
41
  //
15
42
  // Copied from https://github.com/splendeo/jquery.observe_field
43
+ // Wrap in immediately invoked function for compatibility with other js libraries
16
44
  //
17
45
  (function($) {
18
- $.fn.observe_field = function(frequency, callback) {
46
+
47
+ $.fn.filterrific_observe_field = function(frequency, callback) {
19
48
  frequency = frequency * 1000; // translate to milliseconds
20
49
  return this.each(function(){
21
50
  var $this = $(this);
@@ -50,36 +79,8 @@
50
79
 
51
80
 
52
81
 
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
-
82
+ // Initialize event observers on document ready
83
+ jQuery(function($){
83
84
  // Add change event handler to all Filterrific filter inputs.
84
85
  $(document).on(
85
86
  "change",
@@ -89,9 +90,8 @@ Filterrific.submitFilterForm = function(){
89
90
 
90
91
  // Add periodic observer to selected inputs.
91
92
  // 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
+ $(".filterrific-periodically-observed").filterrific_observe_field(
93
94
  0.5,
94
95
  Filterrific.submitFilterForm
95
96
  );
96
-
97
- })(jQuery);
97
+ });
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: filterrific
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-08 00:00:00.000000000 Z
12
+ date: 2013-05-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -107,10 +107,8 @@ dependencies:
107
107
  - - ! '>='
108
108
  - !ruby/object:Gem::Version
109
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 "
110
+ description: Filterrific is a Rails Engine plugin that makes it easy to add filtering,
111
+ searching, and sorting to your ActiveRecord lists.
114
112
  email: jhund@clearcove.ca
115
113
  executables: []
116
114
  extensions: []
@@ -164,5 +162,5 @@ rubyforge_project:
164
162
  rubygems_version: 1.8.25
165
163
  signing_key:
166
164
  specification_version: 3
167
- summary: A Rails engine plugin for filtering ActiveRecord ActiveRecord lists.
165
+ summary: A Rails engine plugin for filtering ActiveRecord lists.
168
166
  test_files: []