g_already_grid 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +25 -1
- data/Rakefile +3 -0
- data/VERSION +1 -1
- data/g_already_grid.gemspec +15 -4
- data/lib/g_already_grid.rb +1 -1
- data/lib/g_already_grid/templates/guilded.already_grid.html.erb +1 -1
- data/lib/g_already_grid/view_helpers.rb +22 -12
- metadata +33 -3
data/README.rdoc
CHANGED
@@ -46,16 +46,40 @@ Add scoping for nested models (deeply nested):
|
|
46
46
|
<%= g_already_grid @items, :id => "items-grid", :cols => [:name, :is_active], :sort => [:name],
|
47
47
|
:scoped_by => @account %>
|
48
48
|
|
49
|
-
Add shallow
|
49
|
+
Add shallow option to use shallow nesting:
|
50
50
|
|
51
51
|
<%= g_already_grid @items, :id => "items-grid", :cols => [:name, :is_active], :sort => [:name],
|
52
52
|
:scoped_by => @account, :shallow => true %>
|
53
53
|
|
54
|
+
Add namespace option for namespacing:
|
55
|
+
|
56
|
+
<%= g_already_grid @items, :id => "items-grid", :cols => [:name, :is_active], :sort => [:name],
|
57
|
+
:namespace => :admin %>
|
58
|
+
|
59
|
+
|
60
|
+
== OPTIONS:
|
61
|
+
|
62
|
+
id:: The HTML id attribute.
|
63
|
+
cols:: (required) An array of column names to include in the table. Each position of the array can be a symbol, string, or hash with 1 entry. The hash entry is the database field name as a key and the name to use in the gird as the value. Each key and value in the hash can be a symbol or string.
|
64
|
+
skin:: The name of the skin to use for this Guilded element. Defaults to default => which is default.css.
|
65
|
+
exclude_css:: A boolean indicating if Guilded should create a stylesheet inlcude tag for this element. Defaults to false.
|
66
|
+
empty_msg:: a message to display when the ar_col is empty or nil. Defaults to 'No matching records'.
|
67
|
+
actions:: Action links to include in the action column of grid. A boolean or Array of symbols. When boolean, if true, add show, edit and delete actions. When boolean, if false, hide actions column. When Array of symbols, add only actions present in array.
|
68
|
+
paginate:: A boolean indicating whether to output pagination controls. Defaults to true. Utilizes will_paginate plugin features.
|
69
|
+
polymorphic_type:: The type of this polymorphic record. Should be a string representing the class name.
|
70
|
+
polymorphic_as:: The as used for the polymorphic type. Can be a symbol or string.
|
71
|
+
namespace:: A string or symbol that is the namespace this collection is under.
|
72
|
+
scoped_by:: The active record object that the objects in the ar_col is scoped by.
|
73
|
+
shallow:: True if this collection is nested shallow, otherwise, false.
|
74
|
+
clickable:: Set to false in order to avoid rows linking to show action. Defaults to true.
|
75
|
+
adaptable_url:: True in order to make the index url automagically adapt to :get collection routes, otherwise false.
|
76
|
+
|
54
77
|
|
55
78
|
== REQUIREMENTS:
|
56
79
|
|
57
80
|
* Rails >= 2.2.0
|
58
81
|
* Guilded >= 0.1.4 (http://github.com/midas/guilded/tree/master)
|
82
|
+
* will_paginate
|
59
83
|
|
60
84
|
|
61
85
|
== LICENSE:
|
data/Rakefile
CHANGED
@@ -10,6 +10,9 @@ begin
|
|
10
10
|
gem.email = "jason@lookforwardenterprises.com"
|
11
11
|
gem.homepage = "http://github.com/midas/g_already_grid"
|
12
12
|
gem.authors = ["C. Jason Harrelson (midas)"]
|
13
|
+
gem.add_dependency "rails", ">= 2.3"
|
14
|
+
gem.add_dependency "guilded", ">= 1.0"
|
15
|
+
gem.add_dependency "will_paginate"
|
13
16
|
gem.add_development_dependency "shoulda", ">= 2.10.2"
|
14
17
|
end
|
15
18
|
Jeweler::GemcutterTasks.new
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.6
|
data/g_already_grid.gemspec
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{g_already_grid}
|
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{2009-
|
12
|
+
s.date = %q{2009-12-09}
|
13
13
|
s.description = %q{A Guilded Rails component that generates a rich grid control from an ActiveRecord.}
|
14
14
|
s.email = %q{jason@lookforwardenterprises.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.files = [
|
20
20
|
".gitignore",
|
21
21
|
"History.txt",
|
22
|
+
"LICENSE",
|
22
23
|
"README.rdoc",
|
23
24
|
"Rakefile",
|
24
25
|
"VERSION",
|
@@ -52,11 +53,21 @@ Gem::Specification.new do |s|
|
|
52
53
|
s.specification_version = 3
|
53
54
|
|
54
55
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
56
|
+
s.add_runtime_dependency(%q<rails>, [">= 2.3"])
|
57
|
+
s.add_runtime_dependency(%q<guilded>, [">= 1.0"])
|
58
|
+
s.add_runtime_dependency(%q<will_paginate>, [">= 0"])
|
55
59
|
s.add_development_dependency(%q<shoulda>, [">= 2.10.2"])
|
56
60
|
else
|
61
|
+
s.add_dependency(%q<rails>, [">= 2.3"])
|
62
|
+
s.add_dependency(%q<guilded>, [">= 1.0"])
|
63
|
+
s.add_dependency(%q<will_paginate>, [">= 0"])
|
57
64
|
s.add_dependency(%q<shoulda>, [">= 2.10.2"])
|
58
65
|
end
|
59
66
|
else
|
67
|
+
s.add_dependency(%q<rails>, [">= 2.3"])
|
68
|
+
s.add_dependency(%q<guilded>, [">= 1.0"])
|
69
|
+
s.add_dependency(%q<will_paginate>, [">= 0"])
|
60
70
|
s.add_dependency(%q<shoulda>, [">= 2.10.2"])
|
61
71
|
end
|
62
72
|
end
|
73
|
+
|
data/lib/g_already_grid.rb
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
<% end %>
|
8
8
|
<% unless options[:actions].empty? %><th>Actions</th><% end %>
|
9
9
|
<% options[:col_titles].each_with_index do |col, i| %>
|
10
|
-
<th><%= sort_by.include?( options[:cols][i].to_sym ) ? sortable_header( col, options[:cols][i], path_helpers[:index_rest_helper], path_helpers[:index_rest_args] ) : col %></th>
|
10
|
+
<th><%= sort_by.include?( options[:cols][i].to_sym ) ? sortable_header( col, options[:cols][i], path_helpers[:index_rest_helper], path_helpers[:index_rest_args], options ) : col %></th>
|
11
11
|
<% end %>
|
12
12
|
<th class="right"></th>
|
13
13
|
</tr>
|
@@ -25,10 +25,11 @@ module GAlreadyGrid
|
|
25
25
|
# true. Utilizes will_paginate plugin features.
|
26
26
|
# polymorphic_type:: The type of this polymorphic record. Should be a string representing the class name.
|
27
27
|
# polymorphic_as:: The as used for the polymorphic type. Can be a symbol or string.
|
28
|
-
# namespace::
|
29
|
-
# scoped_by::
|
30
|
-
# shallow::
|
31
|
-
# clickable:: Set to false in order to avoid rows linking to show action.
|
28
|
+
# namespace:: A string or symbol that is the namespace this collection is under.
|
29
|
+
# scoped_by:: The active record object that the objects in the ar_col is scoped by.
|
30
|
+
# shallow:: True if this collection is nested shallow, otherwise, false.
|
31
|
+
# clickable:: Set to false in order to avoid rows linking to show action. Defaults to true.
|
32
|
+
# adaptable_url:: True in order to make the index url automagically adapt to :get collection routes, otherwise false.
|
32
33
|
#
|
33
34
|
def g_already_grid( ar_col, *args )
|
34
35
|
options = args.extract_options!
|
@@ -79,7 +80,7 @@ module GAlreadyGrid
|
|
79
80
|
if e.is_a? NoMethodError # This just means no will_paginate methods are present.
|
80
81
|
do_paginate = false
|
81
82
|
else
|
82
|
-
|
83
|
+
raise e
|
83
84
|
end
|
84
85
|
end
|
85
86
|
|
@@ -94,6 +95,7 @@ module GAlreadyGrid
|
|
94
95
|
:options => options, :ar_col => ar_col, :do_paginate => do_paginate, :sort_by => sort_by, :path_helpers => path_helpers
|
95
96
|
}
|
96
97
|
|
98
|
+
@g_already_grid_options = options
|
97
99
|
path = File.dirname(__FILE__)
|
98
100
|
full_path = "#{path}/templates/guilded.already_grid.html.erb"
|
99
101
|
self.render( :file => full_path, :use_full_path => false, :locals => vars )
|
@@ -109,10 +111,10 @@ module GAlreadyGrid
|
|
109
111
|
# name:: The text to use for the link
|
110
112
|
# method:: The actual name of this column's field.
|
111
113
|
# path:: (Symbol) The name of the path method to call from routing.
|
114
|
+
# already_grid_options:: The options hash from the already grid view helper.
|
112
115
|
# options:: see link_to helper.
|
113
116
|
#
|
114
|
-
def sortable_header( name, method, path, scoping_args, options={} )
|
115
|
-
|
117
|
+
def sortable_header( name, method, path, scoping_args, already_grid_options, options={} )
|
116
118
|
is_sorted_link = ( method.to_s == params[:order].to_s )
|
117
119
|
|
118
120
|
if is_sorted_link
|
@@ -132,7 +134,7 @@ module GAlreadyGrid
|
|
132
134
|
unsorted_options.merge!( :filter => params[:filter] ) if params[:filter]
|
133
135
|
|
134
136
|
path = path.to_sym unless path.is_a?( Symbol )
|
135
|
-
path_args =
|
137
|
+
path_args = [] + scoping_args
|
136
138
|
|
137
139
|
if is_sorted_link
|
138
140
|
# Handle the currently sorted by link
|
@@ -144,14 +146,22 @@ module GAlreadyGrid
|
|
144
146
|
path_args << unsorted_options
|
145
147
|
path = @controller.send( path, *path_args )
|
146
148
|
end
|
147
|
-
|
148
|
-
|
149
|
+
|
150
|
+
# Try to adapt to get collection rest methods
|
151
|
+
if already_grid_options[:adaptable_url]
|
152
|
+
path_parts = path.split( '?' )
|
153
|
+
match = request.path_info.match( /#{path_parts[0]}\/(\w*)/ ) unless path_parts.blank?
|
154
|
+
left_overs = match[1] unless match.nil?
|
155
|
+
if left_overs == params[:action]
|
156
|
+
path = "#{request.path_info}?#{path_parts[1]}" # path.gsub( /#path_parts[0]/, request.request_uri )
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
149
160
|
# Load the params to an args array to send to the link_to helper
|
150
|
-
args =
|
161
|
+
args = []
|
151
162
|
args << name << path << options
|
152
163
|
|
153
164
|
link_to( *args )
|
154
|
-
|
155
165
|
end
|
156
166
|
|
157
167
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: g_already_grid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- C. Jason Harrelson (midas)
|
@@ -9,9 +9,39 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-12-09 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rails
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "2.3"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: guilded
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "1.0"
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: will_paginate
|
37
|
+
type: :runtime
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: "0"
|
44
|
+
version:
|
15
45
|
- !ruby/object:Gem::Dependency
|
16
46
|
name: shoulda
|
17
47
|
type: :development
|
@@ -34,6 +64,7 @@ extra_rdoc_files:
|
|
34
64
|
files:
|
35
65
|
- .gitignore
|
36
66
|
- History.txt
|
67
|
+
- LICENSE
|
37
68
|
- README.rdoc
|
38
69
|
- Rakefile
|
39
70
|
- VERSION
|
@@ -55,7 +86,6 @@ files:
|
|
55
86
|
- script/destroy
|
56
87
|
- script/generate
|
57
88
|
- tasks/rspec.rake
|
58
|
-
- LICENSE
|
59
89
|
has_rdoc: true
|
60
90
|
homepage: http://github.com/midas/g_already_grid
|
61
91
|
licenses: []
|