g_named_scope_filters 1.0.5 → 1.0.6
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/History.txt +5 -1
- data/VERSION +1 -1
- data/g_named_scope_filters.gemspec +3 -3
- data/lib/g_named_scope_filters.rb +1 -1
- data/lib/g_named_scope_filters/view_helpers.rb +19 -17
- metadata +36 -17
data/History.txt
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
== 1.0.5 2010-07-19
|
2
|
+
|
3
|
+
* Fixed bug with the all filter selection when no all filter parameter name is specified.
|
4
|
+
|
1
5
|
== 1.0.5 2009-11-19
|
2
6
|
|
3
7
|
* Added options to control 'All' filter display, parameter and label.
|
@@ -6,7 +10,7 @@
|
|
6
10
|
|
7
11
|
== 1.0.4 2009-10-11
|
8
12
|
|
9
|
-
* Added ability to pass in record counts for the filters to override the control's way of calculating
|
13
|
+
* Added ability to pass in record counts for the filters to override the control's way of calculating
|
10
14
|
the available record counts.
|
11
15
|
|
12
16
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.6
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{g_named_scope_filters}
|
8
|
-
s.version = "1.0.
|
8
|
+
s.version = "1.0.6"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["C. Jason Harrelson (midas)"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2010-07-19}
|
13
13
|
s.description = %q{A UI component that generates an unordered list of filters that use named scopes within an ActiveRecord model to filter a list. It is not tied to a table or list specifically as it simply manipulates the url, resulting in a manipulation of any collection (list, table, etc.) it may be coupled with.}
|
14
14
|
s.email = %q{jason@lookforwardenterprises.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -34,7 +34,7 @@ Gem::Specification.new do |s|
|
|
34
34
|
s.homepage = %q{http://github.com/midas/g_named_scope_filters}
|
35
35
|
s.rdoc_options = ["--charset=UTF-8"]
|
36
36
|
s.require_paths = ["lib"]
|
37
|
-
s.rubygems_version = %q{1.3.
|
37
|
+
s.rubygems_version = %q{1.3.6}
|
38
38
|
s.summary = %q{A UI component that generates an unordered list of filters that use named scopes within an ActiveRecord model to filter a list.}
|
39
39
|
s.test_files = [
|
40
40
|
"spec/g_named_scope_filters_spec.rb",
|
@@ -1,15 +1,15 @@
|
|
1
1
|
module GNamedScopeFilters
|
2
2
|
module ViewHelpers
|
3
|
-
|
3
|
+
|
4
4
|
# Guilded component. This is an unordered list of filters that use named scopes within an ActiveRecord model
|
5
|
-
# to filter a list. It is not tied to a table or list specifically as it simply manipulates the url, resulting
|
5
|
+
# to filter a list. It is not tied to a table or list specifically as it simply manipulates the url, resulting
|
6
6
|
# in a manipulation of a list or table.
|
7
|
-
#
|
7
|
+
#
|
8
8
|
# === Parameters
|
9
9
|
# :ar_obj_col_or_class:: The ActiveRecord object, collection or class to make the filters from. Warning:
|
10
|
-
# if you use anything but the class and the collection or object comes up nil or empty, then you will
|
10
|
+
# if you use anything but the class and the collection or object comes up nil or empty, then you will
|
11
11
|
# not have filters renderred. The prefferred way is to use the class unless you cannot due to dynamic reasons.
|
12
|
-
#
|
12
|
+
#
|
13
13
|
# === Options
|
14
14
|
# +id+ - (Required) This will be the id of the ul returned that wraps the filters.
|
15
15
|
# +class+ - This will be the id of the ul returned that wraps the filters. Defaults to 'filters.'
|
@@ -20,7 +20,7 @@ module GNamedScopeFilters
|
|
20
20
|
# +record_counts+ - A hash providing teh counts for each filter to override the built in counting funcitonality.
|
21
21
|
# +include_all+ - True if you want the all filter to be renderred, otherwise false. Defaults to true.
|
22
22
|
# +all_label+ - The text to use for the All filter's label. Defaults to 'All.'
|
23
|
-
# +all_param+ - The param to pass for the all filter. Set to :none or false for no filter parameter added to URL
|
23
|
+
# +all_param+ - The param to pass for the all filter. Set to :none or false for no filter parameter added to URL
|
24
24
|
# when all selected. Defaults to false.
|
25
25
|
# +filter_param_key+ - The key for the filter param. Defaults to 'filter.' ie. &filter=something
|
26
26
|
# +scoped_by+ - This is the ActiveRecord object that this list is scoped by. For instance, if an account
|
@@ -28,7 +28,7 @@ module GNamedScopeFilters
|
|
28
28
|
# This will scope the user list with filter to that account. It will also change the path helper from
|
29
29
|
# users_path to account_users_path, unless you overrode the path helper with :list_path_helper.
|
30
30
|
# +namespace+ - The name of the namespace being used for this resource.
|
31
|
-
# +polymorphic_type+ - A string representing the name of the type to use if the current type is just a polymorphic
|
31
|
+
# +polymorphic_type+ - A string representing the name of the type to use if the current type is just a polymorphic
|
32
32
|
# association table, etc. For instance
|
33
33
|
# +polymorphic_as+ -
|
34
34
|
#
|
@@ -36,7 +36,7 @@ module GNamedScopeFilters
|
|
36
36
|
options = args.extract_options!
|
37
37
|
options.merge! :class => "filters" unless options.include?( :class )
|
38
38
|
options.merge! :selected_class => "selected" unless options.include?( :selected_class )
|
39
|
-
options.merge! :exclude_css => true, :exclude_js => true
|
39
|
+
options.merge! :exclude_css => true, :exclude_js => true
|
40
40
|
|
41
41
|
if options[:only]
|
42
42
|
if options[:only].is_a?( String ) || options[:only].is_a?( Symbol )
|
@@ -57,7 +57,7 @@ module GNamedScopeFilters
|
|
57
57
|
all_param = options[:all_param]
|
58
58
|
all_param = nil if all_param == :none || all_param == false
|
59
59
|
filter_param_key = options[:filter_param_key] || 'filter'
|
60
|
-
|
60
|
+
|
61
61
|
raise "You must provide the 'polymorphic_as' option if you provide the 'polymorphic_type' option." if polymorphic_type && !polymorphic_as
|
62
62
|
|
63
63
|
Guilded::Guilder.instance.add( :named_scope_filters, options )
|
@@ -83,7 +83,7 @@ module GNamedScopeFilters
|
|
83
83
|
|
84
84
|
# Resolve scoped by if it is an array
|
85
85
|
scoped_by = scoped_by.last if scoped_by.is_a?( Array )
|
86
|
-
|
86
|
+
|
87
87
|
html << "<ul id=\"#{options[:id].to_s}\" class=\"#{options[:class].to_s}\">"
|
88
88
|
|
89
89
|
# Handle the all filter
|
@@ -93,7 +93,7 @@ module GNamedScopeFilters
|
|
93
93
|
if options[:include_count]
|
94
94
|
if record_counts
|
95
95
|
link_text << " <span>#{record_counts[:all]}</span>"
|
96
|
-
elsif scoped_by
|
96
|
+
elsif scoped_by
|
97
97
|
if polymorphic_type
|
98
98
|
poly_scoped_finder = polymorphic_type.to_s.tableize
|
99
99
|
link_text << " <span>#{scoped_by.send( poly_scoped_finder.to_sym ).count}</span>"
|
@@ -102,7 +102,7 @@ module GNamedScopeFilters
|
|
102
102
|
link_text << " <span>#{scoped_by.send( scoped_finder.to_sym ).count}</span>"
|
103
103
|
end
|
104
104
|
else
|
105
|
-
link_text << " <span>#{klass.count}</span>"
|
105
|
+
link_text << " <span>#{klass.count}</span>"
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
@@ -110,9 +110,11 @@ module GNamedScopeFilters
|
|
110
110
|
filter_options.push( :order => params[:order] ) if params[:order]
|
111
111
|
filter_options.push( filter_param_key.to_sym => all_param ) if all_param # Send a param for 'All' filter
|
112
112
|
|
113
|
+
is_selected = all_param.nil? ? params[:filter] == all_param : params[:filter] == all_param.to_s
|
114
|
+
|
113
115
|
html << "<li>"
|
114
|
-
html << link_to( link_text, @controller.send( list_path_helper, *(path_helpers[:index_rest_args] + filter_options) ),
|
115
|
-
:class => "#{
|
116
|
+
html << link_to( link_text, @controller.send( list_path_helper, *(path_helpers[:index_rest_args] + filter_options) ),
|
117
|
+
:class => "#{is_selected ? options[:selected_class] : ''}" )
|
116
118
|
end
|
117
119
|
|
118
120
|
filters.each do |filter|
|
@@ -126,7 +128,7 @@ module GNamedScopeFilters
|
|
126
128
|
scoped_finder = klass.to_s.tableize if scoped_finder.nil? || scoped_finder.empty?
|
127
129
|
|
128
130
|
if polymorphic_type
|
129
|
-
# If there is a named scope finder defined on the root klass that can get the
|
131
|
+
# If there is a named scope finder defined on the root klass that can get the
|
130
132
|
# polymorpic associated objects, the use it
|
131
133
|
if klass.respond_to?( poly_scoped_finder )
|
132
134
|
link_text << " <span>#{scoped_by.send( scoped_finder.to_sym ).send( poly_scoped_finder.to_sym ).send( filter.to_sym ).count}</span>"
|
@@ -150,7 +152,7 @@ module GNamedScopeFilters
|
|
150
152
|
end
|
151
153
|
|
152
154
|
html << "<li>"
|
153
|
-
html << link_to( link_text, @controller.send( list_path_helper, *(path_helpers[:index_rest_args] + filter_options) ),
|
155
|
+
html << link_to( link_text, @controller.send( list_path_helper, *(path_helpers[:index_rest_args] + filter_options) ),
|
154
156
|
:class => "#{params[:filter] == filter.to_s ? options[:selected_class] : ''}" )
|
155
157
|
html << "</li>"
|
156
158
|
end
|
@@ -158,6 +160,6 @@ module GNamedScopeFilters
|
|
158
160
|
html << "</ul>"
|
159
161
|
html
|
160
162
|
end
|
161
|
-
|
163
|
+
|
162
164
|
end
|
163
165
|
end
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: g_named_scope_filters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 0
|
8
|
+
- 6
|
9
|
+
version: 1.0.6
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- C. Jason Harrelson (midas)
|
@@ -9,39 +14,51 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date:
|
17
|
+
date: 2010-07-19 00:00:00 -05:00
|
13
18
|
default_executable:
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: rspec
|
17
|
-
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
24
|
requirements:
|
21
25
|
- - ">="
|
22
26
|
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 1
|
29
|
+
- 2
|
30
|
+
- 8
|
23
31
|
version: 1.2.8
|
24
|
-
|
32
|
+
type: :development
|
33
|
+
version_requirements: *id001
|
25
34
|
- !ruby/object:Gem::Dependency
|
26
35
|
name: rails
|
27
|
-
|
28
|
-
|
29
|
-
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
38
|
requirements:
|
31
39
|
- - ">="
|
32
40
|
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 2
|
43
|
+
- 2
|
44
|
+
- 0
|
33
45
|
version: 2.2.0
|
34
|
-
|
46
|
+
type: :runtime
|
47
|
+
version_requirements: *id002
|
35
48
|
- !ruby/object:Gem::Dependency
|
36
49
|
name: guilded
|
37
|
-
|
38
|
-
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
40
52
|
requirements:
|
41
53
|
- - ">="
|
42
54
|
- !ruby/object:Gem::Version
|
55
|
+
segments:
|
56
|
+
- 1
|
57
|
+
- 0
|
58
|
+
- 0
|
43
59
|
version: 1.0.0
|
44
|
-
|
60
|
+
type: :runtime
|
61
|
+
version_requirements: *id003
|
45
62
|
description: A UI component that generates an unordered list of filters that use named scopes within an ActiveRecord model to filter a list. It is not tied to a table or list specifically as it simply manipulates the url, resulting in a manipulation of any collection (list, table, etc.) it may be coupled with.
|
46
63
|
email: jason@lookforwardenterprises.com
|
47
64
|
executables: []
|
@@ -78,18 +95,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
78
95
|
requirements:
|
79
96
|
- - ">="
|
80
97
|
- !ruby/object:Gem::Version
|
98
|
+
segments:
|
99
|
+
- 0
|
81
100
|
version: "0"
|
82
|
-
version:
|
83
101
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
102
|
requirements:
|
85
103
|
- - ">="
|
86
104
|
- !ruby/object:Gem::Version
|
105
|
+
segments:
|
106
|
+
- 0
|
87
107
|
version: "0"
|
88
|
-
version:
|
89
108
|
requirements: []
|
90
109
|
|
91
110
|
rubyforge_project:
|
92
|
-
rubygems_version: 1.3.
|
111
|
+
rubygems_version: 1.3.6
|
93
112
|
signing_key:
|
94
113
|
specification_version: 3
|
95
114
|
summary: A UI component that generates an unordered list of filters that use named scopes within an ActiveRecord model to filter a list.
|