midas-g_named_scope_filters 1.0.0 → 1.0.2
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 +4 -0
- data/README.rdoc +1 -1
- data/g_named_scope_filters.gemspec +5 -5
- data/lib/g_named_scope_filters.rb +1 -1
- data/lib/g_named_scope_filters/view_helpers.rb +35 -26
- metadata +3 -3
data/History.txt
CHANGED
data/README.rdoc
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{g_named_scope_filters}
|
5
|
-
s.version = "1.0.
|
5
|
+
s.version = "1.0.2"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["C. Jason Harrelson (midas)"]
|
9
|
-
s.date = %q{2009-
|
9
|
+
s.date = %q{2009-04-17}
|
10
10
|
s.description = %q{This is 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.}
|
11
11
|
s.email = ["jason@lookforwardenterprises.com"]
|
12
12
|
s.extra_rdoc_files = ["History.txt", "Manifest.txt", "PostInstall.txt", "README.rdoc"]
|
@@ -25,18 +25,18 @@ Gem::Specification.new do |s|
|
|
25
25
|
s.specification_version = 2
|
26
26
|
|
27
27
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
28
|
-
s.add_development_dependency(%q<newgem>, [">= 1.
|
28
|
+
s.add_development_dependency(%q<newgem>, [">= 1.3.0"])
|
29
29
|
s.add_development_dependency(%q<rails>, [">= 2.2.0"])
|
30
30
|
s.add_development_dependency(%q<midas-guilded>, [">= 0.0.6"])
|
31
31
|
s.add_development_dependency(%q<hoe>, [">= 1.8.0"])
|
32
32
|
else
|
33
|
-
s.add_dependency(%q<newgem>, [">= 1.
|
33
|
+
s.add_dependency(%q<newgem>, [">= 1.3.0"])
|
34
34
|
s.add_dependency(%q<rails>, [">= 2.2.0"])
|
35
35
|
s.add_dependency(%q<midas-guilded>, [">= 0.0.6"])
|
36
36
|
s.add_dependency(%q<hoe>, [">= 1.8.0"])
|
37
37
|
end
|
38
38
|
else
|
39
|
-
s.add_dependency(%q<newgem>, [">= 1.
|
39
|
+
s.add_dependency(%q<newgem>, [">= 1.3.0"])
|
40
40
|
s.add_dependency(%q<rails>, [">= 2.2.0"])
|
41
41
|
s.add_dependency(%q<midas-guilded>, [">= 0.0.6"])
|
42
42
|
s.add_dependency(%q<hoe>, [">= 1.8.0"])
|
@@ -5,26 +5,26 @@ module GNamedScopeFilters
|
|
5
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
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
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
13
|
+
# === Options
|
14
|
+
# +id+ - (Required) This will be the id of the ul returned that wraps the filters.
|
15
|
+
# +class+ - This will be the id of the ul returned that wraps the filters. Defaults to 'filters.'
|
16
|
+
# +selected_class+ - This will be the class that is used to show whih filter is selected. Defaults to 'selected.'
|
17
|
+
# +only+ - This is the filters to include. Can be an array or string (for one filter).
|
18
|
+
# +include_count+ - True if you would like a span created within each filter list item containg the count for
|
19
19
|
# items in that filter.
|
20
|
-
#
|
20
|
+
# +scoped_by+ - This is the ActiveRecord object that this list is scoped by. For instance, if an account
|
21
21
|
# has many users and this is the user list for said acccount, then you would use :scoped_by => @account.
|
22
22
|
# This will scope the user list with filter to that account. It will also change the path helper from
|
23
23
|
# users_path to account_users_path, unless you overrode the path helper with :list_path_helper.
|
24
|
-
#
|
25
|
-
#
|
26
|
-
# :polymorphic:: A string representing the name of the type to use if the current type is just a polymorphic
|
24
|
+
# +namespace+ - The name of the namespace being used for this resource.
|
25
|
+
# +polymorphic_type+ - A string representing the name of the type to use if the current type is just a polymorphic
|
27
26
|
# association table, etc. For instance
|
27
|
+
# +polymorphic_as+ -
|
28
28
|
#
|
29
29
|
def g_named_scope_filters( ar_obj_col_or_class, *args )
|
30
30
|
options = args.extract_options!
|
@@ -41,9 +41,9 @@ module GNamedScopeFilters
|
|
41
41
|
end
|
42
42
|
options[:filters] = filters
|
43
43
|
|
44
|
-
scoped_by = options.delete( :scoped_by )
|
45
|
-
polymorphic_type = options.delete( :polymorphic_type ).to_s if options.has_key?( :polymorphic_type )
|
46
|
-
polymorphic_as = options.delete( :polymorphic_as ).to_s if options.has_key?( :polymorphic_as )
|
44
|
+
scoped_by = options[:scoped_by] #options.delete( :scoped_by )
|
45
|
+
polymorphic_type = options[:polymorphic_type] #options.delete( :polymorphic_type ).to_s if options.has_key?( :polymorphic_type )
|
46
|
+
polymorphic_as = options[:polymorphic_as] #options.delete( :polymorphic_as ).to_s if options.has_key?( :polymorphic_as )
|
47
47
|
|
48
48
|
raise "You must provide the 'polymorphic_as' option if you provide the 'polymorphic_type' option." if polymorphic_type && !polymorphic_as
|
49
49
|
|
@@ -61,13 +61,15 @@ module GNamedScopeFilters
|
|
61
61
|
throw 'You must provide either an ActiveRecord object, collection or type in order to generate filters.'
|
62
62
|
end
|
63
63
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
64
|
+
path_helpers = Guilded::Rails::Helpers.resolve_rest_path_helpers( ar_obj_col_or_class, options )
|
65
|
+
list_path_helper = path_helpers[:index_rest_helper]
|
66
|
+
#if options[:list_path_helper]
|
67
|
+
# list_path_helper = options[:list_path_helper].to_s
|
68
|
+
#elsif scoped_by
|
69
|
+
# list_path_helper = "#{scoped_by.class.to_s.underscore}_#{klass.to_s.tableize}_path"
|
70
|
+
#else
|
71
|
+
# list_path_helper = "#{klass.to_s.tableize}_path"
|
72
|
+
#end
|
71
73
|
|
72
74
|
html = ''
|
73
75
|
|
@@ -92,11 +94,13 @@ module GNamedScopeFilters
|
|
92
94
|
end
|
93
95
|
end
|
94
96
|
|
95
|
-
filter_options = {}
|
96
|
-
filter_options.merge!( :order => params[:order] ) if params[:order]
|
97
|
+
#filter_options = {}
|
98
|
+
#filter_options.merge!( :order => params[:order] ) if params[:order]
|
99
|
+
filter_options = Array.new
|
100
|
+
filter_options.push( :order => params[:order] ) if params[:order]
|
97
101
|
|
98
102
|
html << "<li>"
|
99
|
-
html << link_to( link_text, @controller.send( list_path_helper, filter_options ),
|
103
|
+
html << link_to( link_text, @controller.send( list_path_helper, *(path_helpers[:index_rest_args] + filter_options) ),
|
100
104
|
:class => "#{params[:filter].nil? ? options[:selected_class] : ''}" )
|
101
105
|
|
102
106
|
filters.each do |filter|
|
@@ -129,10 +133,15 @@ module GNamedScopeFilters
|
|
129
133
|
|
130
134
|
end
|
131
135
|
|
132
|
-
filter_options.merge!( :filter => filter )
|
136
|
+
#filter_options.merge!( :filter => filter )
|
137
|
+
if filter_options[filter_options.size-1].is_a?( Hash )
|
138
|
+
filter_options[filter_options.size-1].merge!( :filter => filter )
|
139
|
+
else
|
140
|
+
filter_options.push( :filter => filter )
|
141
|
+
end
|
133
142
|
|
134
143
|
html << "<li>"
|
135
|
-
html << link_to( link_text, @controller.send( list_path_helper, filter_options ),
|
144
|
+
html << link_to( link_text, @controller.send( list_path_helper, *(path_helpers[:index_rest_args] + filter_options) ),
|
136
145
|
:class => "#{params[:filter] == filter.to_s ? options[:selected_class] : ''}" )
|
137
146
|
html << "</li>"
|
138
147
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: midas-g_named_scope_filters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- C. Jason Harrelson (midas)
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-04-17 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 1.
|
23
|
+
version: 1.3.0
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rails
|