datagrid 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +3 -2
- data/Gemfile.lock +8 -7
- data/VERSION +1 -1
- data/datagrid.gemspec +12 -8
- data/lib/datagrid/columns/column.rb +1 -2
- data/lib/datagrid/filters.rb +1 -1
- data/lib/datagrid/filters/filter_eval.rb +2 -0
- data/lib/datagrid/helper.rb +3 -2
- data/spec/datagrid/filters/boolean_enum_filter_spec.rb +5 -0
- data/spec/datagrid/filters/enum_filter_spec.rb +9 -0
- data/spec/datagrid/helper_spec.rb +37 -0
- metadata +31 -12
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -32,8 +32,8 @@ GEM
|
|
32
32
|
activesupport (= 3.0.7)
|
33
33
|
activesupport (3.0.7)
|
34
34
|
arel (2.0.10)
|
35
|
-
bson (1.4.
|
36
|
-
bson_ext (1.4.
|
35
|
+
bson (1.4.0)
|
36
|
+
bson_ext (1.4.0)
|
37
37
|
builder (2.1.2)
|
38
38
|
columnize (0.3.2)
|
39
39
|
diff-lcs (1.1.2)
|
@@ -54,9 +54,9 @@ GEM
|
|
54
54
|
treetop (~> 1.4.8)
|
55
55
|
mime-types (1.16)
|
56
56
|
mocha (0.9.12)
|
57
|
-
mongo (1.4.
|
58
|
-
bson (= 1.4.
|
59
|
-
mongoid (2.2.
|
57
|
+
mongo (1.4.0)
|
58
|
+
bson (= 1.4.0)
|
59
|
+
mongoid (2.2.2)
|
60
60
|
activemodel (~> 3.0)
|
61
61
|
mongo (~> 1.3)
|
62
62
|
tzinfo (~> 0.3.22)
|
@@ -108,12 +108,13 @@ PLATFORMS
|
|
108
108
|
|
109
109
|
DEPENDENCIES
|
110
110
|
accept_values_for
|
111
|
-
|
111
|
+
bson (= 1.4.0)
|
112
|
+
bson_ext (= 1.4.0)
|
112
113
|
bundler (~> 1.0.0)
|
113
114
|
fastercsv
|
114
115
|
jeweler (~> 1.6.0)
|
115
116
|
mocha
|
116
|
-
mongoid (= 2.2.
|
117
|
+
mongoid (= 2.2.2)
|
117
118
|
nokogiri
|
118
119
|
rails (>= 3.0)
|
119
120
|
rake
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.1
|
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.4.
|
8
|
+
s.version = "0.4.1"
|
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 = "2011-
|
12
|
+
s.date = "2011-12-06"
|
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 = [
|
@@ -54,6 +54,7 @@ Gem::Specification.new do |s|
|
|
54
54
|
"spec/datagrid/columns_spec.rb",
|
55
55
|
"spec/datagrid/drivers/active_record_spec.rb",
|
56
56
|
"spec/datagrid/drivers/mongoid_spec.rb",
|
57
|
+
"spec/datagrid/filters/boolean_enum_filter_spec.rb",
|
57
58
|
"spec/datagrid/filters/composite_filters_spec.rb",
|
58
59
|
"spec/datagrid/filters/enum_filter_spec.rb",
|
59
60
|
"spec/datagrid/filters_spec.rb",
|
@@ -88,8 +89,9 @@ Gem::Specification.new do |s|
|
|
88
89
|
s.add_development_dependency(%q<nokogiri>, [">= 0"])
|
89
90
|
s.add_development_dependency(%q<sqlite3-ruby>, [">= 0"])
|
90
91
|
s.add_development_dependency(%q<will_paginate>, ["= 2.3.15"])
|
91
|
-
s.add_development_dependency(%q<mongoid>, ["= 2.2.
|
92
|
-
s.add_development_dependency(%q<
|
92
|
+
s.add_development_dependency(%q<mongoid>, ["= 2.2.2"])
|
93
|
+
s.add_development_dependency(%q<bson>, ["= 1.4.0"])
|
94
|
+
s.add_development_dependency(%q<bson_ext>, ["= 1.4.0"])
|
93
95
|
s.add_development_dependency(%q<fastercsv>, [">= 0"])
|
94
96
|
else
|
95
97
|
s.add_dependency(%q<rails>, [">= 3.0"])
|
@@ -103,8 +105,9 @@ Gem::Specification.new do |s|
|
|
103
105
|
s.add_dependency(%q<nokogiri>, [">= 0"])
|
104
106
|
s.add_dependency(%q<sqlite3-ruby>, [">= 0"])
|
105
107
|
s.add_dependency(%q<will_paginate>, ["= 2.3.15"])
|
106
|
-
s.add_dependency(%q<mongoid>, ["= 2.2.
|
107
|
-
s.add_dependency(%q<
|
108
|
+
s.add_dependency(%q<mongoid>, ["= 2.2.2"])
|
109
|
+
s.add_dependency(%q<bson>, ["= 1.4.0"])
|
110
|
+
s.add_dependency(%q<bson_ext>, ["= 1.4.0"])
|
108
111
|
s.add_dependency(%q<fastercsv>, [">= 0"])
|
109
112
|
end
|
110
113
|
else
|
@@ -119,8 +122,9 @@ Gem::Specification.new do |s|
|
|
119
122
|
s.add_dependency(%q<nokogiri>, [">= 0"])
|
120
123
|
s.add_dependency(%q<sqlite3-ruby>, [">= 0"])
|
121
124
|
s.add_dependency(%q<will_paginate>, ["= 2.3.15"])
|
122
|
-
s.add_dependency(%q<mongoid>, ["= 2.2.
|
123
|
-
s.add_dependency(%q<
|
125
|
+
s.add_dependency(%q<mongoid>, ["= 2.2.2"])
|
126
|
+
s.add_dependency(%q<bson>, ["= 1.4.0"])
|
127
|
+
s.add_dependency(%q<bson_ext>, ["= 1.4.0"])
|
124
128
|
s.add_dependency(%q<fastercsv>, [">= 0"])
|
125
129
|
end
|
126
130
|
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
class Datagrid::Columns::Column
|
3
2
|
|
4
3
|
attr_accessor :grid, :options, :block, :name
|
@@ -34,7 +33,7 @@ class Datagrid::Columns::Column
|
|
34
33
|
|
35
34
|
def header
|
36
35
|
self.options[:header] ||
|
37
|
-
I18n.translate(self.name, :scope => "
|
36
|
+
I18n.translate(self.name, :scope => "datagrid.#{self.grid.param_name}.columns", :default => self.name.to_s.humanize )
|
38
37
|
end
|
39
38
|
|
40
39
|
def order
|
data/lib/datagrid/filters.rb
CHANGED
data/lib/datagrid/helper.rb
CHANGED
@@ -5,8 +5,9 @@ module Datagrid
|
|
5
5
|
|
6
6
|
def datagrid_format_value(report, column, asset)
|
7
7
|
value = column.value(asset, report)
|
8
|
-
|
9
|
-
|
8
|
+
url = column.options[:url] && column.options[:url].call(asset)
|
9
|
+
if url
|
10
|
+
link_to(value, url)
|
10
11
|
else
|
11
12
|
case column.format
|
12
13
|
when :url
|
@@ -16,4 +16,13 @@ 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 stack with other filters" do
|
20
|
+
Entry.create(:name => "ZZ", :category => "first")
|
21
|
+
report = test_report(:name => "Pop", :category => "first") do
|
22
|
+
scope { Entry }
|
23
|
+
filter(:name)
|
24
|
+
filter(:category, :enum, :select => ["first", "second"])
|
25
|
+
end
|
26
|
+
report.assets.should be_empty
|
27
|
+
end
|
19
28
|
end
|
@@ -52,6 +52,24 @@ HTML
|
|
52
52
|
</th>
|
53
53
|
</tr>
|
54
54
|
|
55
|
+
<tr>
|
56
|
+
<td class="group">Pop</td>
|
57
|
+
<td class="name">Star</td>
|
58
|
+
</tr>
|
59
|
+
</table>
|
60
|
+
HTML
|
61
|
+
end
|
62
|
+
it "should support giving assets implicitly" do
|
63
|
+
other_entry = Entry.create!(entry.attributes)
|
64
|
+
subject.datagrid_table(grid, [entry]).should equal_to_dom(<<-HTML)
|
65
|
+
<table class="datagrid">
|
66
|
+
<tr>
|
67
|
+
<th class="group">Group<div class="order"></div>
|
68
|
+
</th>
|
69
|
+
<th class="name">Name<div class="order"></div>
|
70
|
+
</th>
|
71
|
+
</tr>
|
72
|
+
|
55
73
|
<tr>
|
56
74
|
<td class="group">Pop</td>
|
57
75
|
<td class="name">Star</td>
|
@@ -66,6 +84,25 @@ HTML
|
|
66
84
|
<td class="group">Pop</td>
|
67
85
|
<td class="name">Star</td>
|
68
86
|
</tr>
|
87
|
+
HTML
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should support urls" do
|
91
|
+
rp = test_report do
|
92
|
+
scope { Entry }
|
93
|
+
column(:name, :url => lambda {|model| model.name})
|
94
|
+
end
|
95
|
+
subject.datagrid_rows(rp, [entry], {}).should equal_to_dom(<<-HTML)
|
96
|
+
<tr><td class="name"><a href="Star">Star</a></td></tr>
|
97
|
+
HTML
|
98
|
+
end
|
99
|
+
it "should support conditional urls" do
|
100
|
+
rp = test_report do
|
101
|
+
scope { Entry }
|
102
|
+
column(:name, :url => lambda {false})
|
103
|
+
end
|
104
|
+
subject.datagrid_rows(rp, [entry], {}).should equal_to_dom(<<-HTML)
|
105
|
+
<tr><td class="name">Star</td></tr>
|
69
106
|
HTML
|
70
107
|
end
|
71
108
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: datagrid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 13
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 0.4.
|
9
|
+
- 1
|
10
|
+
version: 0.4.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Bogdan Gusiev
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-12-06 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
type: :runtime
|
@@ -187,12 +187,12 @@ dependencies:
|
|
187
187
|
requirements:
|
188
188
|
- - "="
|
189
189
|
- !ruby/object:Gem::Version
|
190
|
-
hash:
|
190
|
+
hash: 3
|
191
191
|
segments:
|
192
192
|
- 2
|
193
193
|
- 2
|
194
|
-
-
|
195
|
-
version: 2.2.
|
194
|
+
- 2
|
195
|
+
version: 2.2.2
|
196
196
|
prerelease: false
|
197
197
|
name: mongoid
|
198
198
|
version_requirements: *id012
|
@@ -201,18 +201,36 @@ dependencies:
|
|
201
201
|
requirement: &id013 !ruby/object:Gem::Requirement
|
202
202
|
none: false
|
203
203
|
requirements:
|
204
|
-
- - "
|
204
|
+
- - "="
|
205
205
|
- !ruby/object:Gem::Version
|
206
|
-
hash:
|
206
|
+
hash: 7
|
207
207
|
segments:
|
208
|
+
- 1
|
209
|
+
- 4
|
208
210
|
- 0
|
209
|
-
version:
|
211
|
+
version: 1.4.0
|
210
212
|
prerelease: false
|
211
|
-
name:
|
213
|
+
name: bson
|
212
214
|
version_requirements: *id013
|
213
215
|
- !ruby/object:Gem::Dependency
|
214
216
|
type: :development
|
215
217
|
requirement: &id014 !ruby/object:Gem::Requirement
|
218
|
+
none: false
|
219
|
+
requirements:
|
220
|
+
- - "="
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
hash: 7
|
223
|
+
segments:
|
224
|
+
- 1
|
225
|
+
- 4
|
226
|
+
- 0
|
227
|
+
version: 1.4.0
|
228
|
+
prerelease: false
|
229
|
+
name: bson_ext
|
230
|
+
version_requirements: *id014
|
231
|
+
- !ruby/object:Gem::Dependency
|
232
|
+
type: :development
|
233
|
+
requirement: &id015 !ruby/object:Gem::Requirement
|
216
234
|
none: false
|
217
235
|
requirements:
|
218
236
|
- - ">="
|
@@ -223,7 +241,7 @@ dependencies:
|
|
223
241
|
version: "0"
|
224
242
|
prerelease: false
|
225
243
|
name: fastercsv
|
226
|
-
version_requirements: *
|
244
|
+
version_requirements: *id015
|
227
245
|
description: This allows you to easily build datagrid aka data tables with sortable columns and filters
|
228
246
|
email: agresso@gmail.com
|
229
247
|
executables: []
|
@@ -271,6 +289,7 @@ files:
|
|
271
289
|
- spec/datagrid/columns_spec.rb
|
272
290
|
- spec/datagrid/drivers/active_record_spec.rb
|
273
291
|
- spec/datagrid/drivers/mongoid_spec.rb
|
292
|
+
- spec/datagrid/filters/boolean_enum_filter_spec.rb
|
274
293
|
- spec/datagrid/filters/composite_filters_spec.rb
|
275
294
|
- spec/datagrid/filters/enum_filter_spec.rb
|
276
295
|
- spec/datagrid/filters_spec.rb
|