datagrid 0.5.3 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -2
- data/Gemfile.lock +10 -10
- data/Readme.markdown +1 -1
- data/VERSION +1 -1
- data/app/views/datagrid/_row.html.erb +1 -3
- data/datagrid.gemspec +9 -9
- data/lib/datagrid/active_model.rb +1 -1
- data/lib/datagrid/core.rb +1 -0
- data/lib/datagrid/filters/enum_filter.rb +1 -1
- data/lib/datagrid/renderer.rb +5 -2
- data/spec/datagrid/active_model_spec.rb +15 -1
- data/spec/datagrid/filters/enum_filter_spec.rb +7 -0
- data/spec/datagrid/helper_spec.rb +13 -0
- metadata +39 -39
data/Gemfile
CHANGED
@@ -7,14 +7,14 @@ gem "rails", ">= 3.0"
|
|
7
7
|
group :development do
|
8
8
|
|
9
9
|
gem "rake"
|
10
|
-
gem "bundler", "~> 1.
|
10
|
+
gem "bundler", "~> 1.1.0"
|
11
11
|
gem "jeweler", "~> 1.6.0"
|
12
12
|
|
13
13
|
gem "ruby-debug", :platform => "mri_18"
|
14
14
|
#gem "ruby-debug19", :platform => "mri_19"
|
15
15
|
|
16
16
|
gem "mocha"
|
17
|
-
gem "rspec"
|
17
|
+
gem "rspec"
|
18
18
|
gem "accept_values_for"
|
19
19
|
gem "nokogiri" # used to test html output
|
20
20
|
|
data/Gemfile.lock
CHANGED
@@ -101,14 +101,14 @@ GEM
|
|
101
101
|
rbx-require-relative (0.0.5)
|
102
102
|
rdoc (3.11)
|
103
103
|
json (~> 1.4)
|
104
|
-
rspec (2.
|
105
|
-
rspec-core (~> 2.
|
106
|
-
rspec-expectations (~> 2.
|
107
|
-
rspec-mocks (~> 2.
|
108
|
-
rspec-core (2.
|
109
|
-
rspec-expectations (2.
|
110
|
-
diff-lcs (~> 1.1.
|
111
|
-
rspec-mocks (2.
|
104
|
+
rspec (2.9.0)
|
105
|
+
rspec-core (~> 2.9.0)
|
106
|
+
rspec-expectations (~> 2.9.0)
|
107
|
+
rspec-mocks (~> 2.9.0)
|
108
|
+
rspec-core (2.9.0)
|
109
|
+
rspec-expectations (2.9.1)
|
110
|
+
diff-lcs (~> 1.1.3)
|
111
|
+
rspec-mocks (2.9.0)
|
112
112
|
ruby-debug (0.10.4)
|
113
113
|
columnize (>= 0.1)
|
114
114
|
ruby-debug-base (~> 0.10.4.0)
|
@@ -136,7 +136,7 @@ DEPENDENCIES
|
|
136
136
|
accept_values_for
|
137
137
|
bson (= 1.4.0)
|
138
138
|
bson_ext (= 1.4.0)
|
139
|
-
bundler (~> 1.
|
139
|
+
bundler (~> 1.1.0)
|
140
140
|
fastercsv
|
141
141
|
jeweler (~> 1.6.0)
|
142
142
|
mocha
|
@@ -145,7 +145,7 @@ DEPENDENCIES
|
|
145
145
|
nokogiri
|
146
146
|
rails (>= 3.0)
|
147
147
|
rake
|
148
|
-
rspec
|
148
|
+
rspec
|
149
149
|
ruby-debug
|
150
150
|
sqlite3-ruby
|
151
151
|
will_paginate (= 2.3.15)
|
data/Readme.markdown
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.4
|
@@ -1,7 +1,5 @@
|
|
1
1
|
<tr class="<%= options[:cycle] && cycle(*options[:cycle]) %>">
|
2
2
|
<% grid.columns.each do |column| %>
|
3
|
-
<td class="<%= datagrid_column_classes(grid, column) %>">
|
4
|
-
<%= datagrid_format_value(grid, column, asset) %>
|
5
|
-
</td>
|
3
|
+
<td class="<%= datagrid_column_classes(grid, column) %>"><%= datagrid_format_value(grid, column, asset) %></td>
|
6
4
|
<% end %>
|
7
5
|
</tr>
|
data/datagrid.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "datagrid"
|
8
|
-
s.version = "0.5.
|
8
|
+
s.version = "0.5.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Bogdan Gusiev"]
|
12
|
-
s.date = "2012-
|
12
|
+
s.date = "2012-04-11"
|
13
13
|
s.description = "This allows you to easily build datagrid aka data tables with sortable columns and filters"
|
14
14
|
s.email = "agresso@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -82,7 +82,7 @@ Gem::Specification.new do |s|
|
|
82
82
|
s.homepage = "http://github.com/bogdan/datagrid"
|
83
83
|
s.licenses = ["MIT"]
|
84
84
|
s.require_paths = ["lib"]
|
85
|
-
s.rubygems_version = "1.8.
|
85
|
+
s.rubygems_version = "1.8.11"
|
86
86
|
s.summary = "Ruby gem to create datagrids"
|
87
87
|
|
88
88
|
if s.respond_to? :specification_version then
|
@@ -91,11 +91,11 @@ Gem::Specification.new do |s|
|
|
91
91
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
92
92
|
s.add_runtime_dependency(%q<rails>, [">= 3.0"])
|
93
93
|
s.add_development_dependency(%q<rake>, [">= 0"])
|
94
|
-
s.add_development_dependency(%q<bundler>, ["~> 1.
|
94
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.1.0"])
|
95
95
|
s.add_development_dependency(%q<jeweler>, ["~> 1.6.0"])
|
96
96
|
s.add_development_dependency(%q<ruby-debug>, [">= 0"])
|
97
97
|
s.add_development_dependency(%q<mocha>, [">= 0"])
|
98
|
-
s.add_development_dependency(%q<rspec>, ["
|
98
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
99
99
|
s.add_development_dependency(%q<accept_values_for>, [">= 0"])
|
100
100
|
s.add_development_dependency(%q<nokogiri>, [">= 0"])
|
101
101
|
s.add_development_dependency(%q<sqlite3-ruby>, [">= 0"])
|
@@ -108,11 +108,11 @@ Gem::Specification.new do |s|
|
|
108
108
|
else
|
109
109
|
s.add_dependency(%q<rails>, [">= 3.0"])
|
110
110
|
s.add_dependency(%q<rake>, [">= 0"])
|
111
|
-
s.add_dependency(%q<bundler>, ["~> 1.
|
111
|
+
s.add_dependency(%q<bundler>, ["~> 1.1.0"])
|
112
112
|
s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
|
113
113
|
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
114
114
|
s.add_dependency(%q<mocha>, [">= 0"])
|
115
|
-
s.add_dependency(%q<rspec>, ["
|
115
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
116
116
|
s.add_dependency(%q<accept_values_for>, [">= 0"])
|
117
117
|
s.add_dependency(%q<nokogiri>, [">= 0"])
|
118
118
|
s.add_dependency(%q<sqlite3-ruby>, [">= 0"])
|
@@ -126,11 +126,11 @@ Gem::Specification.new do |s|
|
|
126
126
|
else
|
127
127
|
s.add_dependency(%q<rails>, [">= 3.0"])
|
128
128
|
s.add_dependency(%q<rake>, [">= 0"])
|
129
|
-
s.add_dependency(%q<bundler>, ["~> 1.
|
129
|
+
s.add_dependency(%q<bundler>, ["~> 1.1.0"])
|
130
130
|
s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
|
131
131
|
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
132
132
|
s.add_dependency(%q<mocha>, [">= 0"])
|
133
|
-
s.add_dependency(%q<rspec>, ["
|
133
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
134
134
|
s.add_dependency(%q<accept_values_for>, [">= 0"])
|
135
135
|
s.add_dependency(%q<nokogiri>, [">= 0"])
|
136
136
|
s.add_dependency(%q<sqlite3-ruby>, [">= 0"])
|
data/lib/datagrid/core.rb
CHANGED
@@ -2,7 +2,7 @@ class Datagrid::Filters::EnumFilter < Datagrid::Filters::BaseFilter
|
|
2
2
|
|
3
3
|
def initialize(*args)
|
4
4
|
super(*args)
|
5
|
-
raise Datagrid::ConfigurationError, ":select option not specified" unless select
|
5
|
+
raise Datagrid::ConfigurationError, ":select option not specified" unless options[:select]
|
6
6
|
end
|
7
7
|
|
8
8
|
def format(value)
|
data/lib/datagrid/renderer.rb
CHANGED
@@ -12,7 +12,7 @@ module Datagrid
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def format_value(grid, column, asset)
|
15
|
-
value = column.html? ? @template.instance_exec(asset, &column.block) : column.value(asset, grid)
|
15
|
+
value = column.html? ? @template.instance_exec(asset, grid, &column.block) : column.value(asset, grid)
|
16
16
|
url = column.options[:url] && column.options[:url].call(asset)
|
17
17
|
if url
|
18
18
|
@template.link_to(value, url)
|
@@ -32,7 +32,10 @@ module Datagrid
|
|
32
32
|
options[:html][:class] ||= "datagrid #{grid.class.to_s.underscore.demodulize}"
|
33
33
|
assets = args.any? ? args.shift : grid.assets
|
34
34
|
paginate = options[:paginate]
|
35
|
-
|
35
|
+
if paginate
|
36
|
+
::Datagrid::Utils.warn_once(":paginate option is deprecated. Looks to https://github.com/bogdan/datagrid/wiki/Frontend.")
|
37
|
+
assets = assets.paginate(paginate)
|
38
|
+
end
|
36
39
|
|
37
40
|
@template.render :partial => "datagrid/table", :locals => {:grid => grid, :options => options, :assets => assets}
|
38
41
|
end
|
@@ -6,6 +6,12 @@ describe Datagrid::ActiveModel do
|
|
6
6
|
include Datagrid::ActiveModel
|
7
7
|
end
|
8
8
|
|
9
|
+
module Grid
|
10
|
+
class ActiveReport
|
11
|
+
include Datagrid::ActiveModel
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
9
15
|
describe ".model_name" do
|
10
16
|
it "should be generate from class name " do
|
11
17
|
ActiveReport.model_name.should == "ActiveReport"
|
@@ -15,5 +21,13 @@ describe Datagrid::ActiveModel do
|
|
15
21
|
end
|
16
22
|
end
|
17
23
|
|
18
|
-
|
24
|
+
describe ".param_name" do
|
25
|
+
it "should make right param key from simple class name" do
|
26
|
+
ActiveReport.param_name.should == 'active_report'
|
27
|
+
end
|
28
|
+
it "should make right param key from class of module" do
|
29
|
+
Grid::ActiveReport.param_name.should == 'grid_active_report'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
19
33
|
end
|
@@ -16,4 +16,11 @@ describe Datagrid::Filters::EnumFilter do
|
|
16
16
|
end.class.filter_by_name(:group_id).select.should == [1,2]
|
17
17
|
end
|
18
18
|
|
19
|
+
it "should initialize select option only on instanciation" do
|
20
|
+
class ReportWithLazySelect
|
21
|
+
include Datagrid
|
22
|
+
scope {Entry}
|
23
|
+
filter(:group_id, :enum, :select => proc { raise 'hello' })
|
24
|
+
end
|
25
|
+
end
|
19
26
|
end
|
@@ -125,6 +125,19 @@ describe Datagrid::Helper do
|
|
125
125
|
"tr td.name span" => "Star"
|
126
126
|
)
|
127
127
|
end
|
128
|
+
|
129
|
+
it "should render html columns with double arguments for column" do
|
130
|
+
rp = test_report do
|
131
|
+
scope { Entry }
|
132
|
+
column(:name, :html => true) do |model, grid|
|
133
|
+
content_tag(:span, "#{model.name}-#{grid.assets.klass}" )
|
134
|
+
end
|
135
|
+
end
|
136
|
+
subject.datagrid_rows(rp, [entry]).should match_css_pattern(
|
137
|
+
"tr td.name span" => "Star-Entry"
|
138
|
+
)
|
139
|
+
end
|
140
|
+
|
128
141
|
end
|
129
142
|
|
130
143
|
describe ".datagrid_order_for" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: datagrid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-04-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &9639800 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '3.0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *9639800
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &9638360 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,21 +32,21 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *9638360
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: bundler
|
38
|
-
requirement: &
|
38
|
+
requirement: &9637320 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: 1.
|
43
|
+
version: 1.1.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *9637320
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: jeweler
|
49
|
-
requirement: &
|
49
|
+
requirement: &9636560 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 1.6.0
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *9636560
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: ruby-debug
|
60
|
-
requirement: &
|
60
|
+
requirement: &9634860 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *9634860
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: mocha
|
71
|
-
requirement: &
|
71
|
+
requirement: &9632840 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,21 +76,21 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *9632840
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: rspec
|
82
|
-
requirement: &
|
82
|
+
requirement: &9647700 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
|
-
- -
|
85
|
+
- - ! '>='
|
86
86
|
- !ruby/object:Gem::Version
|
87
|
-
version:
|
87
|
+
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *9647700
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: accept_values_for
|
93
|
-
requirement: &
|
93
|
+
requirement: &9644920 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: '0'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *9644920
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: nokogiri
|
104
|
-
requirement: &
|
104
|
+
requirement: &9642560 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ! '>='
|
@@ -109,10 +109,10 @@ dependencies:
|
|
109
109
|
version: '0'
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *9642560
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: sqlite3-ruby
|
115
|
-
requirement: &
|
115
|
+
requirement: &9641040 !ruby/object:Gem::Requirement
|
116
116
|
none: false
|
117
117
|
requirements:
|
118
118
|
- - ! '>='
|
@@ -120,10 +120,10 @@ dependencies:
|
|
120
120
|
version: '0'
|
121
121
|
type: :development
|
122
122
|
prerelease: false
|
123
|
-
version_requirements: *
|
123
|
+
version_requirements: *9641040
|
124
124
|
- !ruby/object:Gem::Dependency
|
125
125
|
name: will_paginate
|
126
|
-
requirement: &
|
126
|
+
requirement: &9656640 !ruby/object:Gem::Requirement
|
127
127
|
none: false
|
128
128
|
requirements:
|
129
129
|
- - =
|
@@ -131,10 +131,10 @@ dependencies:
|
|
131
131
|
version: 2.3.15
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
|
-
version_requirements: *
|
134
|
+
version_requirements: *9656640
|
135
135
|
- !ruby/object:Gem::Dependency
|
136
136
|
name: mongoid
|
137
|
-
requirement: &
|
137
|
+
requirement: &9655700 !ruby/object:Gem::Requirement
|
138
138
|
none: false
|
139
139
|
requirements:
|
140
140
|
- - =
|
@@ -142,10 +142,10 @@ dependencies:
|
|
142
142
|
version: 2.2.2
|
143
143
|
type: :development
|
144
144
|
prerelease: false
|
145
|
-
version_requirements: *
|
145
|
+
version_requirements: *9655700
|
146
146
|
- !ruby/object:Gem::Dependency
|
147
147
|
name: mongo_mapper
|
148
|
-
requirement: &
|
148
|
+
requirement: &9655180 !ruby/object:Gem::Requirement
|
149
149
|
none: false
|
150
150
|
requirements:
|
151
151
|
- - ! '>='
|
@@ -153,10 +153,10 @@ dependencies:
|
|
153
153
|
version: 0.11.0
|
154
154
|
type: :development
|
155
155
|
prerelease: false
|
156
|
-
version_requirements: *
|
156
|
+
version_requirements: *9655180
|
157
157
|
- !ruby/object:Gem::Dependency
|
158
158
|
name: bson
|
159
|
-
requirement: &
|
159
|
+
requirement: &9654520 !ruby/object:Gem::Requirement
|
160
160
|
none: false
|
161
161
|
requirements:
|
162
162
|
- - =
|
@@ -164,10 +164,10 @@ dependencies:
|
|
164
164
|
version: 1.4.0
|
165
165
|
type: :development
|
166
166
|
prerelease: false
|
167
|
-
version_requirements: *
|
167
|
+
version_requirements: *9654520
|
168
168
|
- !ruby/object:Gem::Dependency
|
169
169
|
name: bson_ext
|
170
|
-
requirement: &
|
170
|
+
requirement: &9653580 !ruby/object:Gem::Requirement
|
171
171
|
none: false
|
172
172
|
requirements:
|
173
173
|
- - =
|
@@ -175,10 +175,10 @@ dependencies:
|
|
175
175
|
version: 1.4.0
|
176
176
|
type: :development
|
177
177
|
prerelease: false
|
178
|
-
version_requirements: *
|
178
|
+
version_requirements: *9653580
|
179
179
|
- !ruby/object:Gem::Dependency
|
180
180
|
name: fastercsv
|
181
|
-
requirement: &
|
181
|
+
requirement: &9652580 !ruby/object:Gem::Requirement
|
182
182
|
none: false
|
183
183
|
requirements:
|
184
184
|
- - ! '>='
|
@@ -186,7 +186,7 @@ dependencies:
|
|
186
186
|
version: '0'
|
187
187
|
type: :development
|
188
188
|
prerelease: false
|
189
|
-
version_requirements: *
|
189
|
+
version_requirements: *9652580
|
190
190
|
description: This allows you to easily build datagrid aka data tables with sortable
|
191
191
|
columns and filters
|
192
192
|
email: agresso@gmail.com
|
@@ -272,7 +272,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
272
272
|
version: '0'
|
273
273
|
segments:
|
274
274
|
- 0
|
275
|
-
hash:
|
275
|
+
hash: -2917374290940836838
|
276
276
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
277
277
|
none: false
|
278
278
|
requirements:
|
@@ -281,7 +281,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
281
281
|
version: '0'
|
282
282
|
requirements: []
|
283
283
|
rubyforge_project:
|
284
|
-
rubygems_version: 1.8.
|
284
|
+
rubygems_version: 1.8.11
|
285
285
|
signing_key:
|
286
286
|
specification_version: 3
|
287
287
|
summary: Ruby gem to create datagrids
|