datagrid 1.4.1 → 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/VERSION +1 -1
- data/datagrid.gemspec +8 -7
- data/lib/datagrid/columns/column.rb +22 -10
- data/lib/datagrid/filters/base_filter.rb +9 -1
- data/spec/datagrid/columns/column_spec.rb +19 -0
- data/spec/datagrid/columns_spec.rb +9 -0
- data/spec/datagrid/filters_spec.rb +11 -0
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b69adb5df9eebf47a8446dd095c6b966b635649
|
4
|
+
data.tar.gz: 576710b7d11168fcde29d19eddc77f730b94fd43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74512141aa0e4dd111ed9dea6783f562c71f509ae45b7a81395371b716331d75a5a95383e2157858c1555f7183de042f33143286eadef72a17db72dba9a83d3f
|
7
|
+
data.tar.gz: 79d7d6e111160e03a1df224be0c3f8263cf968dc2d2266a1c3ca5a2f495adf9c0edb0f71d62e5428953f380b5b4fd3c1594848c7a89f03a41a40227f60b9a7d9
|
data/Gemfile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.4.
|
1
|
+
1.4.2
|
data/datagrid.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: datagrid 1.4.
|
5
|
+
# stub: datagrid 1.4.2 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "datagrid"
|
9
|
-
s.version = "1.4.
|
9
|
+
s.version = "1.4.2"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Bogdan Gusiev"]
|
14
|
-
s.date = "2016-
|
14
|
+
s.date = "2016-03-08"
|
15
15
|
s.description = "This allows you to easily build datagrid aka data tables with sortable columns and filters"
|
16
16
|
s.email = "agresso@gmail.com"
|
17
17
|
s.extra_rdoc_files = [
|
@@ -78,6 +78,7 @@ Gem::Specification.new do |s|
|
|
78
78
|
"lib/tasks/datagrid_tasks.rake",
|
79
79
|
"spec/datagrid/active_model_spec.rb",
|
80
80
|
"spec/datagrid/column_names_attribute_spec.rb",
|
81
|
+
"spec/datagrid/columns/column_spec.rb",
|
81
82
|
"spec/datagrid/columns_spec.rb",
|
82
83
|
"spec/datagrid/core_spec.rb",
|
83
84
|
"spec/datagrid/drivers/active_record_spec.rb",
|
@@ -128,14 +129,14 @@ Gem::Specification.new do |s|
|
|
128
129
|
]
|
129
130
|
s.homepage = "http://github.com/bogdan/datagrid"
|
130
131
|
s.licenses = ["MIT"]
|
131
|
-
s.rubygems_version = "2.4.
|
132
|
+
s.rubygems_version = "2.4.5"
|
132
133
|
s.summary = "Ruby gem to create datagrids"
|
133
134
|
|
134
135
|
if s.respond_to? :specification_version then
|
135
136
|
s.specification_version = 4
|
136
137
|
|
137
138
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
138
|
-
s.add_runtime_dependency(%q<rails>, [">= 3.2.
|
139
|
+
s.add_runtime_dependency(%q<rails>, [">= 3.2.22.2"])
|
139
140
|
s.add_development_dependency(%q<bundler>, [">= 0"])
|
140
141
|
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
141
142
|
s.add_development_dependency(%q<debugger>, [">= 0"])
|
@@ -149,7 +150,7 @@ Gem::Specification.new do |s|
|
|
149
150
|
s.add_development_dependency(%q<bson>, [">= 0"])
|
150
151
|
s.add_development_dependency(%q<bson_ext>, [">= 0"])
|
151
152
|
else
|
152
|
-
s.add_dependency(%q<rails>, [">= 3.2.
|
153
|
+
s.add_dependency(%q<rails>, [">= 3.2.22.2"])
|
153
154
|
s.add_dependency(%q<bundler>, [">= 0"])
|
154
155
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
155
156
|
s.add_dependency(%q<debugger>, [">= 0"])
|
@@ -164,7 +165,7 @@ Gem::Specification.new do |s|
|
|
164
165
|
s.add_dependency(%q<bson_ext>, [">= 0"])
|
165
166
|
end
|
166
167
|
else
|
167
|
-
s.add_dependency(%q<rails>, [">= 3.2.
|
168
|
+
s.add_dependency(%q<rails>, [">= 3.2.22.2"])
|
168
169
|
s.add_dependency(%q<bundler>, [">= 0"])
|
169
170
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
170
171
|
s.add_dependency(%q<debugger>, [">= 0"])
|
@@ -41,8 +41,6 @@ class Datagrid::Columns::Column
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
self.query = query
|
44
|
-
options[:if] = convert_option_to_proc(options[:if])
|
45
|
-
options[:unless] = convert_option_to_proc(options[:unless])
|
46
44
|
end
|
47
45
|
|
48
46
|
def data_value(model, grid)
|
@@ -56,7 +54,11 @@ class Datagrid::Columns::Column
|
|
56
54
|
end
|
57
55
|
|
58
56
|
def header
|
59
|
-
|
57
|
+
if header = options[:header]
|
58
|
+
callable(header)
|
59
|
+
else
|
60
|
+
Datagrid::Utils.translate_from_namespace(:columns, grid_class, name)
|
61
|
+
end
|
60
62
|
end
|
61
63
|
|
62
64
|
def order
|
@@ -101,11 +103,12 @@ class Datagrid::Columns::Column
|
|
101
103
|
end
|
102
104
|
|
103
105
|
def enabled?(grid)
|
104
|
-
(
|
106
|
+
column_availability(grid, options[:if], true) &&
|
107
|
+
!column_availability(grid, options[:unless], false)
|
105
108
|
end
|
106
109
|
|
107
110
|
def inspect
|
108
|
-
"
|
111
|
+
"#<#{self.class} #{grid_class}##{name} #{options.inspect}>"
|
109
112
|
end
|
110
113
|
|
111
114
|
def to_s
|
@@ -127,11 +130,20 @@ class Datagrid::Columns::Column
|
|
127
130
|
end
|
128
131
|
|
129
132
|
private
|
130
|
-
def
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
133
|
+
def column_availability(grid, option, default)
|
134
|
+
case option
|
135
|
+
when nil
|
136
|
+
default
|
137
|
+
when Proc
|
138
|
+
option.call(grid)
|
139
|
+
when Symbol, String
|
140
|
+
grid.send(option.to_sym)
|
141
|
+
else
|
142
|
+
raise Datagrid::ConfigurationError, "Incorrect column availability option: #{option.insepct}"
|
135
143
|
end
|
136
144
|
end
|
145
|
+
|
146
|
+
def callable(value)
|
147
|
+
value.respond_to?(:call) ? value.call : value
|
148
|
+
end
|
137
149
|
end
|
@@ -49,7 +49,11 @@ class Datagrid::Filters::BaseFilter #:nodoc:
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def header
|
52
|
-
options[:header]
|
52
|
+
if header = options[:header]
|
53
|
+
callable(header)
|
54
|
+
else
|
55
|
+
Datagrid::Utils.translate_from_namespace(:filters, grid_class, name)
|
56
|
+
end
|
53
57
|
end
|
54
58
|
|
55
59
|
def default(object = nil)
|
@@ -154,6 +158,10 @@ class Datagrid::Filters::BaseFilter #:nodoc:
|
|
154
158
|
','
|
155
159
|
end
|
156
160
|
|
161
|
+
def callable(value)
|
162
|
+
value.respond_to?(:call) ? value.call : value
|
163
|
+
end
|
164
|
+
|
157
165
|
def driver
|
158
166
|
grid_class.driver
|
159
167
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Datagrid::Columns::Column do
|
4
|
+
|
5
|
+
describe ".inspect" do
|
6
|
+
subject do
|
7
|
+
class ColumnInspectTest
|
8
|
+
include Datagrid
|
9
|
+
scope {Entry}
|
10
|
+
column(:id, header: "ID")
|
11
|
+
end
|
12
|
+
ColumnInspectTest.column_by_name(:id)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "shows inspect information" do
|
16
|
+
expect(subject.inspect).to eq("#<Datagrid::Columns::Column ColumnInspectTest#id {:header=>\"ID\"}>")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -118,6 +118,15 @@ describe Datagrid::Columns do
|
|
118
118
|
])
|
119
119
|
end
|
120
120
|
|
121
|
+
it "supports dynamic header" do
|
122
|
+
grid = test_report do
|
123
|
+
scope {Entry}
|
124
|
+
column(:id, header: proc { rand(10**9) })
|
125
|
+
end
|
126
|
+
|
127
|
+
expect(grid.header).to_not eq(grid.header)
|
128
|
+
end
|
129
|
+
|
121
130
|
it "should generate hash for given asset" do
|
122
131
|
expect(subject.hash_for(entry)).to eq({
|
123
132
|
:group => "Pop",
|
@@ -192,6 +192,17 @@ describe Datagrid::Filters do
|
|
192
192
|
|
193
193
|
end
|
194
194
|
|
195
|
+
|
196
|
+
it "supports dynamic header" do
|
197
|
+
grid = test_report do
|
198
|
+
scope {Entry}
|
199
|
+
filter(:id, :integer, header: proc { rand(10**9) })
|
200
|
+
end
|
201
|
+
|
202
|
+
filter = grid.filter_by_name(:id)
|
203
|
+
expect(filter.header).to_not eq(filter.header)
|
204
|
+
end
|
205
|
+
|
195
206
|
|
196
207
|
describe "#filter_by_name" do
|
197
208
|
it "should return filter object" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: datagrid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bogdan Gusiev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 3.2.
|
19
|
+
version: 3.2.22.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 3.2.
|
26
|
+
version: 3.2.22.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -260,6 +260,7 @@ files:
|
|
260
260
|
- lib/tasks/datagrid_tasks.rake
|
261
261
|
- spec/datagrid/active_model_spec.rb
|
262
262
|
- spec/datagrid/column_names_attribute_spec.rb
|
263
|
+
- spec/datagrid/columns/column_spec.rb
|
263
264
|
- spec/datagrid/columns_spec.rb
|
264
265
|
- spec/datagrid/core_spec.rb
|
265
266
|
- spec/datagrid/drivers/active_record_spec.rb
|
@@ -327,7 +328,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
327
328
|
version: '0'
|
328
329
|
requirements: []
|
329
330
|
rubyforge_project:
|
330
|
-
rubygems_version: 2.4.
|
331
|
+
rubygems_version: 2.4.5
|
331
332
|
signing_key:
|
332
333
|
specification_version: 4
|
333
334
|
summary: Ruby gem to create datagrids
|