datagrid 0.5.4 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -4
- data/Readme.markdown +1 -1
- data/VERSION +1 -1
- data/app/views/datagrid/_table.html.erb +8 -4
- data/datagrid.gemspec +5 -13
- data/lib/datagrid.rb +18 -10
- data/lib/datagrid/core.rb +8 -3
- data/lib/datagrid/drivers/mongoid.rb +1 -1
- data/lib/datagrid/filters.rb +3 -5
- data/lib/datagrid/filters/base_filter.rb +7 -3
- data/lib/datagrid/filters/boolean_enum_filter.rb +2 -2
- data/lib/datagrid/filters/composite_filters.rb +8 -8
- data/lib/datagrid/form_builder.rb +5 -6
- data/lib/datagrid/helper.rb +1 -1
- data/lib/datagrid/renderer.rb +11 -3
- data/spec/datagrid/form_builder_spec.rb +8 -6
- data/spec/datagrid/helper_spec.rb +0 -1
- data/spec/datagrid_spec.rb +30 -5
- data/spec/spec_helper.rb +1 -1
- data/spec/support/active_record.rb +0 -1
- data/spec/support/mongoid.rb +1 -1
- metadata +32 -56
- data/Gemfile.lock +0 -151
- data/lib/datagrid/filters/filter_eval.rb +0 -31
data/Gemfile
CHANGED
@@ -10,16 +10,13 @@ group :development do
|
|
10
10
|
gem "bundler", "~> 1.1.0"
|
11
11
|
gem "jeweler", "~> 1.6.0"
|
12
12
|
|
13
|
-
gem "
|
14
|
-
#gem "ruby-debug19", :platform => "mri_19"
|
13
|
+
gem "debugger"
|
15
14
|
|
16
|
-
gem "mocha"
|
17
15
|
gem "rspec"
|
18
16
|
gem "accept_values_for"
|
19
17
|
gem "nokogiri" # used to test html output
|
20
18
|
|
21
19
|
gem "sqlite3-ruby"
|
22
|
-
gem 'will_paginate', '2.3.15'
|
23
20
|
|
24
21
|
gem "mongoid", "2.2.2"
|
25
22
|
gem "mongo_mapper", ">=0.11.0"
|
data/Readme.markdown
CHANGED
@@ -189,6 +189,6 @@ If you need a custom interface for your report you should probably build it your
|
|
189
189
|
|
190
190
|
Like datagrid?
|
191
191
|
|
192
|
-
Follow the repository on [GitHub](https://github.com/bogdan/datagrid
|
192
|
+
Follow the repository on [GitHub](https://github.com/bogdan/datagrid).
|
193
193
|
|
194
194
|
Read [author blog](http://gusiev.com).
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.6.0
|
@@ -1,10 +1,14 @@
|
|
1
|
-
|
1
|
+
<%#
|
2
2
|
Local variables:
|
3
3
|
* grid - instance of Datagrid
|
4
4
|
* assets - Array of database Entities
|
5
5
|
* options - passed options Hash
|
6
|
-
|
6
|
+
%>
|
7
7
|
<%= content_tag :table, options[:html] do %>
|
8
|
-
|
9
|
-
|
8
|
+
<thead>
|
9
|
+
<%= datagrid_header(grid, options) %>
|
10
|
+
</thead>
|
11
|
+
<tbody>
|
12
|
+
<%= datagrid_rows(grid, assets, options) %>
|
13
|
+
</tbody>
|
10
14
|
<% end %>
|
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.
|
8
|
+
s.version = "0.6.0"
|
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-05-24"
|
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 = [
|
@@ -19,7 +19,6 @@ Gem::Specification.new do |s|
|
|
19
19
|
".document",
|
20
20
|
".rspec",
|
21
21
|
"Gemfile",
|
22
|
-
"Gemfile.lock",
|
23
22
|
"LICENSE.txt",
|
24
23
|
"Rakefile",
|
25
24
|
"Readme.markdown",
|
@@ -47,7 +46,6 @@ Gem::Specification.new do |s|
|
|
47
46
|
"lib/datagrid/filters/date_filter.rb",
|
48
47
|
"lib/datagrid/filters/default_filter.rb",
|
49
48
|
"lib/datagrid/filters/enum_filter.rb",
|
50
|
-
"lib/datagrid/filters/filter_eval.rb",
|
51
49
|
"lib/datagrid/filters/integer_filter.rb",
|
52
50
|
"lib/datagrid/filters/string_filter.rb",
|
53
51
|
"lib/datagrid/form_builder.rb",
|
@@ -93,13 +91,11 @@ Gem::Specification.new do |s|
|
|
93
91
|
s.add_development_dependency(%q<rake>, [">= 0"])
|
94
92
|
s.add_development_dependency(%q<bundler>, ["~> 1.1.0"])
|
95
93
|
s.add_development_dependency(%q<jeweler>, ["~> 1.6.0"])
|
96
|
-
s.add_development_dependency(%q<
|
97
|
-
s.add_development_dependency(%q<mocha>, [">= 0"])
|
94
|
+
s.add_development_dependency(%q<debugger>, [">= 0"])
|
98
95
|
s.add_development_dependency(%q<rspec>, [">= 0"])
|
99
96
|
s.add_development_dependency(%q<accept_values_for>, [">= 0"])
|
100
97
|
s.add_development_dependency(%q<nokogiri>, [">= 0"])
|
101
98
|
s.add_development_dependency(%q<sqlite3-ruby>, [">= 0"])
|
102
|
-
s.add_development_dependency(%q<will_paginate>, ["= 2.3.15"])
|
103
99
|
s.add_development_dependency(%q<mongoid>, ["= 2.2.2"])
|
104
100
|
s.add_development_dependency(%q<mongo_mapper>, [">= 0.11.0"])
|
105
101
|
s.add_development_dependency(%q<bson>, ["= 1.4.0"])
|
@@ -110,13 +106,11 @@ Gem::Specification.new do |s|
|
|
110
106
|
s.add_dependency(%q<rake>, [">= 0"])
|
111
107
|
s.add_dependency(%q<bundler>, ["~> 1.1.0"])
|
112
108
|
s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
|
113
|
-
s.add_dependency(%q<
|
114
|
-
s.add_dependency(%q<mocha>, [">= 0"])
|
109
|
+
s.add_dependency(%q<debugger>, [">= 0"])
|
115
110
|
s.add_dependency(%q<rspec>, [">= 0"])
|
116
111
|
s.add_dependency(%q<accept_values_for>, [">= 0"])
|
117
112
|
s.add_dependency(%q<nokogiri>, [">= 0"])
|
118
113
|
s.add_dependency(%q<sqlite3-ruby>, [">= 0"])
|
119
|
-
s.add_dependency(%q<will_paginate>, ["= 2.3.15"])
|
120
114
|
s.add_dependency(%q<mongoid>, ["= 2.2.2"])
|
121
115
|
s.add_dependency(%q<mongo_mapper>, [">= 0.11.0"])
|
122
116
|
s.add_dependency(%q<bson>, ["= 1.4.0"])
|
@@ -128,13 +122,11 @@ Gem::Specification.new do |s|
|
|
128
122
|
s.add_dependency(%q<rake>, [">= 0"])
|
129
123
|
s.add_dependency(%q<bundler>, ["~> 1.1.0"])
|
130
124
|
s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
|
131
|
-
s.add_dependency(%q<
|
132
|
-
s.add_dependency(%q<mocha>, [">= 0"])
|
125
|
+
s.add_dependency(%q<debugger>, [">= 0"])
|
133
126
|
s.add_dependency(%q<rspec>, [">= 0"])
|
134
127
|
s.add_dependency(%q<accept_values_for>, [">= 0"])
|
135
128
|
s.add_dependency(%q<nokogiri>, [">= 0"])
|
136
129
|
s.add_dependency(%q<sqlite3-ruby>, [">= 0"])
|
137
|
-
s.add_dependency(%q<will_paginate>, ["= 2.3.15"])
|
138
130
|
s.add_dependency(%q<mongoid>, ["= 2.2.2"])
|
139
131
|
s.add_dependency(%q<mongo_mapper>, [">= 0.11.0"])
|
140
132
|
s.add_dependency(%q<bson>, ["= 1.4.0"])
|
data/lib/datagrid.rb
CHANGED
@@ -1,16 +1,24 @@
|
|
1
|
-
require "
|
2
|
-
require "datagrid/active_model"
|
3
|
-
require "datagrid/filters"
|
4
|
-
require "datagrid/columns"
|
5
|
-
require "datagrid/ordering"
|
1
|
+
require "action_view"
|
6
2
|
|
7
|
-
|
8
|
-
require "datagrid/form_builder"
|
9
|
-
require "datagrid/renderer"
|
3
|
+
module Datagrid
|
10
4
|
|
11
|
-
|
5
|
+
extend ActiveSupport::Autoload
|
12
6
|
|
13
|
-
|
7
|
+
autoload :Core
|
8
|
+
autoload :ActiveModel
|
9
|
+
autoload :Filters
|
10
|
+
autoload :Columns
|
11
|
+
autoload :Ordering
|
12
|
+
|
13
|
+
autoload :Helper
|
14
|
+
ActionView::Base.send(:include, Datagrid::Helper)
|
15
|
+
|
16
|
+
autoload :FormBuilder
|
17
|
+
ActionView::Helpers::FormBuilder.send(:include, Datagrid::FormBuilder)
|
18
|
+
|
19
|
+
autoload :Renderer
|
20
|
+
|
21
|
+
autoload :Engine
|
14
22
|
|
15
23
|
def self.included(base)
|
16
24
|
base.extend ClassMethods
|
data/lib/datagrid/core.rb
CHANGED
@@ -42,6 +42,10 @@ module Datagrid
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
+
def current_scope
|
46
|
+
@scope
|
47
|
+
end
|
48
|
+
|
45
49
|
def driver
|
46
50
|
@driver ||= Drivers::AbstractDriver.guess_driver(scope).new
|
47
51
|
end
|
@@ -95,15 +99,16 @@ module Datagrid
|
|
95
99
|
end
|
96
100
|
|
97
101
|
def scope
|
98
|
-
|
102
|
+
check_scope_defined!
|
103
|
+
instance_eval(&self.class.current_scope)
|
99
104
|
end
|
100
105
|
|
101
106
|
def driver
|
102
107
|
self.class.driver
|
103
108
|
end
|
104
109
|
|
105
|
-
def check_scope_defined!(message)
|
106
|
-
self.class.check_scope_defined
|
110
|
+
def check_scope_defined!(message = nil )
|
111
|
+
self.class.send :check_scope_defined!, message
|
107
112
|
end
|
108
113
|
|
109
114
|
end # InstanceMethods
|
@@ -28,7 +28,7 @@ module Datagrid
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def default_order(scope, column_name)
|
31
|
-
scope.fields.keys.include?(column_name.to_s) ? column_name : nil
|
31
|
+
to_scope(scope).klass.fields.keys.include?(column_name.to_s) ? column_name : nil
|
32
32
|
end
|
33
33
|
|
34
34
|
def greater_equal(scope, field, value)
|
data/lib/datagrid/filters.rb
CHANGED
@@ -7,7 +7,6 @@ module Datagrid
|
|
7
7
|
require "datagrid/filters/boolean_filter"
|
8
8
|
require "datagrid/filters/date_filter"
|
9
9
|
require "datagrid/filters/default_filter"
|
10
|
-
require "datagrid/filters/filter_eval"
|
11
10
|
require "datagrid/filters/integer_filter"
|
12
11
|
require "datagrid/filters/composite_filters"
|
13
12
|
require "datagrid/filters/string_filter"
|
@@ -67,9 +66,8 @@ module Datagrid
|
|
67
66
|
protected
|
68
67
|
def default_filter(attribute)
|
69
68
|
check_scope_defined!("Scope should be defined before filters")
|
70
|
-
|
71
|
-
|
72
|
-
grid.driver.where(scope, attribute => value)
|
69
|
+
lambda do |value, grid|
|
70
|
+
grid.driver.where(self, attribute => value)
|
73
71
|
end
|
74
72
|
end
|
75
73
|
|
@@ -87,7 +85,7 @@ module Datagrid
|
|
87
85
|
def assets
|
88
86
|
result = super
|
89
87
|
self.class.filters.each do |filter|
|
90
|
-
result = filter.apply(result, filter_value(filter))
|
88
|
+
result = filter.apply(self, result, filter_value(filter))
|
91
89
|
end
|
92
90
|
result
|
93
91
|
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require "datagrid/filters/filter_eval"
|
2
1
|
|
3
2
|
class Datagrid::Filters::BaseFilter
|
4
3
|
|
@@ -15,13 +14,18 @@ class Datagrid::Filters::BaseFilter
|
|
15
14
|
raise NotImplementedError, "#format(value) suppose to be overwritten"
|
16
15
|
end
|
17
16
|
|
18
|
-
def apply(scope, value)
|
17
|
+
def apply(grid_object, scope, value)
|
19
18
|
if value.nil?
|
20
19
|
return scope if !allow_nil?
|
21
20
|
else
|
22
21
|
return scope if value.blank? && !allow_blank?
|
23
22
|
end
|
24
|
-
|
23
|
+
|
24
|
+
if block.arity >= 2 || block.arity < 0
|
25
|
+
scope.instance_exec(value, grid_object, &block)
|
26
|
+
else
|
27
|
+
scope.instance_exec(value, &block)
|
28
|
+
end
|
25
29
|
end
|
26
30
|
|
27
31
|
def format_values(value)
|
@@ -11,8 +11,8 @@ class Datagrid::Filters::BooleanEnumFilter < Datagrid::Filters::EnumFilter
|
|
11
11
|
super(report, attribute, options, &block)
|
12
12
|
end
|
13
13
|
|
14
|
-
def apply(scope, value)
|
15
|
-
super(scope, to_boolean(value))
|
14
|
+
def apply(grid_object, scope, value)
|
15
|
+
super(grid_object, scope, to_boolean(value))
|
16
16
|
end
|
17
17
|
|
18
18
|
def to_boolean(value)
|
@@ -16,22 +16,22 @@ module Datagrid
|
|
16
16
|
from_options = normalize_composite_filter_options(from_options, field)
|
17
17
|
to_options = normalize_composite_filter_options(to_options, field)
|
18
18
|
|
19
|
-
filter(from_options[:name] || :"from_#{field}", :date, from_options) do |date|
|
20
|
-
driver.greater_equal(self, field, date)
|
19
|
+
filter(from_options[:name] || :"from_#{field}", :date, from_options) do |date, grid|
|
20
|
+
grid.driver.greater_equal(self, field, date)
|
21
21
|
end
|
22
|
-
filter(to_options[:name] || :"to_#{field}", :date, to_options) do |date|
|
23
|
-
driver.less_equal(self, field, date)
|
22
|
+
filter(to_options[:name] || :"to_#{field}", :date, to_options) do |date, grid|
|
23
|
+
grid.driver.less_equal(self, field, date)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
def integer_range_filters(field, from_options = {}, to_options = {})
|
28
28
|
from_options = normalize_composite_filter_options(from_options, field)
|
29
29
|
to_options = normalize_composite_filter_options(to_options, field)
|
30
|
-
filter(from_options[:name] || :"from_#{field}", :integer, from_options) do |value|
|
31
|
-
driver.greater_equal(self, field, value)
|
30
|
+
filter(from_options[:name] || :"from_#{field}", :integer, from_options) do |value, grid|
|
31
|
+
grid.driver.greater_equal(self, field, value)
|
32
32
|
end
|
33
|
-
filter(to_options[:name] || :"to_#{field}", :integer, to_options) do |value|
|
34
|
-
driver.less_equal(self, field, value)
|
33
|
+
filter(to_options[:name] || :"to_#{field}", :integer, to_options) do |value, grid|
|
34
|
+
grid.driver.less_equal(self, field, value)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
@@ -13,7 +13,7 @@ module Datagrid
|
|
13
13
|
|
14
14
|
def datagrid_label(filter_or_attribute, options = {})
|
15
15
|
filter = get_filter(filter_or_attribute)
|
16
|
-
self.label(filter.name, filter.header, options
|
16
|
+
self.label(filter.name, filter.header, options)
|
17
17
|
end
|
18
18
|
|
19
19
|
protected
|
@@ -45,7 +45,7 @@ module Datagrid
|
|
45
45
|
def datagrid_integer_filter(attribute_or_filter, options = {})
|
46
46
|
filter = get_filter(attribute_or_filter)
|
47
47
|
if filter.multiple && self.object[filter.name].blank?
|
48
|
-
options[:value] = ""
|
48
|
+
options[:value] = ""
|
49
49
|
end
|
50
50
|
text_field filter.name, options
|
51
51
|
end
|
@@ -55,12 +55,12 @@ module Datagrid
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def get_attribute(attribute_or_filter)
|
58
|
-
attribute_or_filter.is_a?(Symbol) ? attribute_or_filter : attribute_or_filter.name
|
58
|
+
attribute_or_filter.is_a?(Symbol) ? attribute_or_filter : attribute_or_filter.name
|
59
59
|
end
|
60
60
|
|
61
61
|
def get_filter(attribute_or_filter)
|
62
|
-
if attribute_or_filter.is_a?(Symbol)
|
63
|
-
object.class.filter_by_name(attribute_or_filter) ||
|
62
|
+
if attribute_or_filter.is_a?(Symbol)
|
63
|
+
object.class.filter_by_name(attribute_or_filter) ||
|
64
64
|
raise(Error, "filter #{attribute_or_filter} not found")
|
65
65
|
else
|
66
66
|
attribute_or_filter
|
@@ -80,5 +80,4 @@ module Datagrid
|
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
|
-
ActionView::Helpers::FormBuilder.send(:include, Datagrid::FormBuilder)
|
84
83
|
|
data/lib/datagrid/helper.rb
CHANGED
data/lib/datagrid/renderer.rb
CHANGED
@@ -12,7 +12,15 @@ module Datagrid
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def format_value(grid, column, asset)
|
15
|
-
value = column.html?
|
15
|
+
value = if column.html?
|
16
|
+
if column.block.arity > 1
|
17
|
+
@template.instance_exec(asset, grid, &column.block)
|
18
|
+
else
|
19
|
+
@template.instance_exec(asset, &column.block)
|
20
|
+
end
|
21
|
+
else
|
22
|
+
column.value(asset, grid)
|
23
|
+
end
|
16
24
|
url = column.options[:url] && column.options[:url].call(asset)
|
17
25
|
if url
|
18
26
|
@template.link_to(value, url)
|
@@ -32,7 +40,7 @@ module Datagrid
|
|
32
40
|
options[:html][:class] ||= "datagrid #{grid.class.to_s.underscore.demodulize}"
|
33
41
|
assets = args.any? ? args.shift : grid.assets
|
34
42
|
paginate = options[:paginate]
|
35
|
-
if paginate
|
43
|
+
if paginate
|
36
44
|
::Datagrid::Utils.warn_once(":paginate option is deprecated. Looks to https://github.com/bogdan/datagrid/wiki/Frontend.")
|
37
45
|
assets = assets.paginate(paginate)
|
38
46
|
end
|
@@ -57,7 +65,7 @@ module Datagrid
|
|
57
65
|
def order_for(grid, column)
|
58
66
|
@template.content_tag(:div, :class => "order") do
|
59
67
|
@template.link_to(
|
60
|
-
I18n.t("datagrid.table.order.asc", :default => "ASC"),
|
68
|
+
I18n.t("datagrid.table.order.asc", :default => "ASC"),
|
61
69
|
@template.url_for(grid.param_name => grid.attributes.merge(:order => column.name, :descending => false)),
|
62
70
|
:class => "order asc"
|
63
71
|
) + " " + @template.link_to(
|
@@ -119,9 +119,9 @@ describe Datagrid::FormBuilder do
|
|
119
119
|
test_report do
|
120
120
|
scope {Entry}
|
121
121
|
filter(
|
122
|
-
:name, :enum,
|
123
|
-
:include_blank => false,
|
124
|
-
:multiple => false,
|
122
|
+
:name, :enum,
|
123
|
+
:include_blank => false,
|
124
|
+
:multiple => false,
|
125
125
|
:select => []
|
126
126
|
)
|
127
127
|
end
|
@@ -143,10 +143,12 @@ describe Datagrid::FormBuilder do
|
|
143
143
|
'<label for="report_name">Name</label>'
|
144
144
|
)
|
145
145
|
end
|
146
|
+
it "should pass options through to the helper" do
|
147
|
+
view.datagrid_label(:name, :class => 'foo').should equal_to_dom(
|
148
|
+
'<label class="foo" for="report_name">Name</label>'
|
149
|
+
)
|
150
|
+
end
|
146
151
|
end
|
147
|
-
|
148
|
-
|
149
|
-
|
150
152
|
end
|
151
153
|
|
152
154
|
|
data/spec/datagrid_spec.rb
CHANGED
@@ -3,11 +3,11 @@ require "datagrid/rspec"
|
|
3
3
|
|
4
4
|
|
5
5
|
describe SimpleReport do
|
6
|
-
|
6
|
+
|
7
7
|
it_should_behave_like 'Datagrid'
|
8
|
-
|
8
|
+
|
9
9
|
let(:group) { Group.create!(:name => "Pop") }
|
10
|
-
|
10
|
+
|
11
11
|
subject do
|
12
12
|
SimpleReport.new(
|
13
13
|
:group_id => group.id,
|
@@ -37,7 +37,6 @@ describe SimpleReport do
|
|
37
37
|
it "should return defined scope of objects" do
|
38
38
|
subject.scope.should respond_to(:each)
|
39
39
|
end
|
40
|
-
|
41
40
|
|
42
41
|
context "when not defined on class level" do
|
43
42
|
subject do
|
@@ -48,11 +47,37 @@ describe SimpleReport do
|
|
48
47
|
lambda {
|
49
48
|
subject.scope
|
50
49
|
}.should raise_error(Datagrid::ConfigurationError)
|
51
|
-
|
50
|
+
|
52
51
|
end
|
53
52
|
end
|
54
53
|
end
|
55
54
|
|
55
|
+
end
|
56
|
+
|
57
|
+
class SimpleReportWithContext < SimpleReport
|
58
|
+
attr_accessor :current_user
|
59
|
+
scope do
|
60
|
+
current_user.things
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe SimpleReportWithContext, "with context" do
|
65
|
+
|
66
|
+
subject do
|
67
|
+
|
68
|
+
SimpleReportWithContext.new(
|
69
|
+
:name => "Star",
|
70
|
+
:category => "first",
|
71
|
+
:disabled => false,
|
72
|
+
:confirmed => false
|
73
|
+
)
|
74
|
+
end
|
56
75
|
|
76
|
+
it "should call " do
|
77
|
+
current_user = Object.new
|
78
|
+
current_user.should_receive(:things).and_return([])
|
79
|
+
SimpleReportWithContext.new(:current_user => current_user).scope
|
80
|
+
end
|
57
81
|
|
58
82
|
end
|
83
|
+
|
data/spec/spec_helper.rb
CHANGED
@@ -13,7 +13,7 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
13
13
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
14
14
|
|
15
15
|
require "active_record"
|
16
|
-
require
|
16
|
+
require 'action_view'
|
17
17
|
require "mongoid"
|
18
18
|
require "mongo_mapper"
|
19
19
|
require 'datagrid'
|
data/spec/support/mongoid.rb
CHANGED
@@ -6,10 +6,10 @@ Mongoid.from_hash({
|
|
6
6
|
"host" => "localhost",
|
7
7
|
"database" =>"datagrid_mongoid",
|
8
8
|
"autocreate_indexes" => true,
|
9
|
+
"logger" => nil,
|
9
10
|
})
|
10
11
|
|
11
12
|
#Mongoid.logger = TEST_LOGGER #TODO: understand why still output to STDOUT
|
12
|
-
Mongoid.logger = nil
|
13
13
|
|
14
14
|
|
15
15
|
class MongoidEntry
|
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.
|
4
|
+
version: 0.6.0
|
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-05-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &17705320 !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: *17705320
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &17704400 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *17704400
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: bundler
|
38
|
-
requirement: &
|
38
|
+
requirement: &17718840 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 1.1.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *17718840
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: jeweler
|
49
|
-
requirement: &
|
49
|
+
requirement: &17715720 !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: *17715720
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
|
-
name:
|
60
|
-
requirement: &
|
59
|
+
name: debugger
|
60
|
+
requirement: &17713920 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,21 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: mocha
|
71
|
-
requirement: &9632840 !ruby/object:Gem::Requirement
|
72
|
-
none: false
|
73
|
-
requirements:
|
74
|
-
- - ! '>='
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
version: '0'
|
77
|
-
type: :development
|
78
|
-
prerelease: false
|
79
|
-
version_requirements: *9632840
|
68
|
+
version_requirements: *17713920
|
80
69
|
- !ruby/object:Gem::Dependency
|
81
70
|
name: rspec
|
82
|
-
requirement: &
|
71
|
+
requirement: &17711920 !ruby/object:Gem::Requirement
|
83
72
|
none: false
|
84
73
|
requirements:
|
85
74
|
- - ! '>='
|
@@ -87,10 +76,10 @@ dependencies:
|
|
87
76
|
version: '0'
|
88
77
|
type: :development
|
89
78
|
prerelease: false
|
90
|
-
version_requirements: *
|
79
|
+
version_requirements: *17711920
|
91
80
|
- !ruby/object:Gem::Dependency
|
92
81
|
name: accept_values_for
|
93
|
-
requirement: &
|
82
|
+
requirement: &17726920 !ruby/object:Gem::Requirement
|
94
83
|
none: false
|
95
84
|
requirements:
|
96
85
|
- - ! '>='
|
@@ -98,10 +87,10 @@ dependencies:
|
|
98
87
|
version: '0'
|
99
88
|
type: :development
|
100
89
|
prerelease: false
|
101
|
-
version_requirements: *
|
90
|
+
version_requirements: *17726920
|
102
91
|
- !ruby/object:Gem::Dependency
|
103
92
|
name: nokogiri
|
104
|
-
requirement: &
|
93
|
+
requirement: &17725080 !ruby/object:Gem::Requirement
|
105
94
|
none: false
|
106
95
|
requirements:
|
107
96
|
- - ! '>='
|
@@ -109,10 +98,10 @@ dependencies:
|
|
109
98
|
version: '0'
|
110
99
|
type: :development
|
111
100
|
prerelease: false
|
112
|
-
version_requirements: *
|
101
|
+
version_requirements: *17725080
|
113
102
|
- !ruby/object:Gem::Dependency
|
114
103
|
name: sqlite3-ruby
|
115
|
-
requirement: &
|
104
|
+
requirement: &17723640 !ruby/object:Gem::Requirement
|
116
105
|
none: false
|
117
106
|
requirements:
|
118
107
|
- - ! '>='
|
@@ -120,21 +109,10 @@ dependencies:
|
|
120
109
|
version: '0'
|
121
110
|
type: :development
|
122
111
|
prerelease: false
|
123
|
-
version_requirements: *
|
124
|
-
- !ruby/object:Gem::Dependency
|
125
|
-
name: will_paginate
|
126
|
-
requirement: &9656640 !ruby/object:Gem::Requirement
|
127
|
-
none: false
|
128
|
-
requirements:
|
129
|
-
- - =
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: 2.3.15
|
132
|
-
type: :development
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: *9656640
|
112
|
+
version_requirements: *17723640
|
135
113
|
- !ruby/object:Gem::Dependency
|
136
114
|
name: mongoid
|
137
|
-
requirement: &
|
115
|
+
requirement: &17723000 !ruby/object:Gem::Requirement
|
138
116
|
none: false
|
139
117
|
requirements:
|
140
118
|
- - =
|
@@ -142,10 +120,10 @@ dependencies:
|
|
142
120
|
version: 2.2.2
|
143
121
|
type: :development
|
144
122
|
prerelease: false
|
145
|
-
version_requirements: *
|
123
|
+
version_requirements: *17723000
|
146
124
|
- !ruby/object:Gem::Dependency
|
147
125
|
name: mongo_mapper
|
148
|
-
requirement: &
|
126
|
+
requirement: &17722200 !ruby/object:Gem::Requirement
|
149
127
|
none: false
|
150
128
|
requirements:
|
151
129
|
- - ! '>='
|
@@ -153,10 +131,10 @@ dependencies:
|
|
153
131
|
version: 0.11.0
|
154
132
|
type: :development
|
155
133
|
prerelease: false
|
156
|
-
version_requirements: *
|
134
|
+
version_requirements: *17722200
|
157
135
|
- !ruby/object:Gem::Dependency
|
158
136
|
name: bson
|
159
|
-
requirement: &
|
137
|
+
requirement: &17721480 !ruby/object:Gem::Requirement
|
160
138
|
none: false
|
161
139
|
requirements:
|
162
140
|
- - =
|
@@ -164,10 +142,10 @@ dependencies:
|
|
164
142
|
version: 1.4.0
|
165
143
|
type: :development
|
166
144
|
prerelease: false
|
167
|
-
version_requirements: *
|
145
|
+
version_requirements: *17721480
|
168
146
|
- !ruby/object:Gem::Dependency
|
169
147
|
name: bson_ext
|
170
|
-
requirement: &
|
148
|
+
requirement: &17720880 !ruby/object:Gem::Requirement
|
171
149
|
none: false
|
172
150
|
requirements:
|
173
151
|
- - =
|
@@ -175,10 +153,10 @@ dependencies:
|
|
175
153
|
version: 1.4.0
|
176
154
|
type: :development
|
177
155
|
prerelease: false
|
178
|
-
version_requirements: *
|
156
|
+
version_requirements: *17720880
|
179
157
|
- !ruby/object:Gem::Dependency
|
180
158
|
name: fastercsv
|
181
|
-
requirement: &
|
159
|
+
requirement: &17720180 !ruby/object:Gem::Requirement
|
182
160
|
none: false
|
183
161
|
requirements:
|
184
162
|
- - ! '>='
|
@@ -186,7 +164,7 @@ dependencies:
|
|
186
164
|
version: '0'
|
187
165
|
type: :development
|
188
166
|
prerelease: false
|
189
|
-
version_requirements: *
|
167
|
+
version_requirements: *17720180
|
190
168
|
description: This allows you to easily build datagrid aka data tables with sortable
|
191
169
|
columns and filters
|
192
170
|
email: agresso@gmail.com
|
@@ -198,7 +176,6 @@ files:
|
|
198
176
|
- .document
|
199
177
|
- .rspec
|
200
178
|
- Gemfile
|
201
|
-
- Gemfile.lock
|
202
179
|
- LICENSE.txt
|
203
180
|
- Rakefile
|
204
181
|
- Readme.markdown
|
@@ -226,7 +203,6 @@ files:
|
|
226
203
|
- lib/datagrid/filters/date_filter.rb
|
227
204
|
- lib/datagrid/filters/default_filter.rb
|
228
205
|
- lib/datagrid/filters/enum_filter.rb
|
229
|
-
- lib/datagrid/filters/filter_eval.rb
|
230
206
|
- lib/datagrid/filters/integer_filter.rb
|
231
207
|
- lib/datagrid/filters/string_filter.rb
|
232
208
|
- lib/datagrid/form_builder.rb
|
@@ -272,7 +248,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
272
248
|
version: '0'
|
273
249
|
segments:
|
274
250
|
- 0
|
275
|
-
hash: -
|
251
|
+
hash: -1581920802397090213
|
276
252
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
277
253
|
none: false
|
278
254
|
requirements:
|
data/Gemfile.lock
DELETED
@@ -1,151 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: http://rubygems.org/
|
3
|
-
specs:
|
4
|
-
accept_values_for (0.4.3)
|
5
|
-
activemodel (>= 3.0.0)
|
6
|
-
rspec
|
7
|
-
actionmailer (3.1.3)
|
8
|
-
actionpack (= 3.1.3)
|
9
|
-
mail (~> 2.3.0)
|
10
|
-
actionpack (3.1.3)
|
11
|
-
activemodel (= 3.1.3)
|
12
|
-
activesupport (= 3.1.3)
|
13
|
-
builder (~> 3.0.0)
|
14
|
-
erubis (~> 2.7.0)
|
15
|
-
i18n (~> 0.6)
|
16
|
-
rack (~> 1.3.5)
|
17
|
-
rack-cache (~> 1.1)
|
18
|
-
rack-mount (~> 0.8.2)
|
19
|
-
rack-test (~> 0.6.1)
|
20
|
-
sprockets (~> 2.0.3)
|
21
|
-
activemodel (3.1.3)
|
22
|
-
activesupport (= 3.1.3)
|
23
|
-
builder (~> 3.0.0)
|
24
|
-
i18n (~> 0.6)
|
25
|
-
activerecord (3.1.3)
|
26
|
-
activemodel (= 3.1.3)
|
27
|
-
activesupport (= 3.1.3)
|
28
|
-
arel (~> 2.2.1)
|
29
|
-
tzinfo (~> 0.3.29)
|
30
|
-
activeresource (3.1.3)
|
31
|
-
activemodel (= 3.1.3)
|
32
|
-
activesupport (= 3.1.3)
|
33
|
-
activesupport (3.1.3)
|
34
|
-
multi_json (~> 1.0)
|
35
|
-
arel (2.2.1)
|
36
|
-
bson (1.4.0)
|
37
|
-
bson_ext (1.4.0)
|
38
|
-
builder (3.0.0)
|
39
|
-
columnize (0.3.5)
|
40
|
-
diff-lcs (1.1.3)
|
41
|
-
erubis (2.7.0)
|
42
|
-
fastercsv (1.5.4)
|
43
|
-
git (1.2.5)
|
44
|
-
hike (1.2.1)
|
45
|
-
i18n (0.6.0)
|
46
|
-
jeweler (1.6.4)
|
47
|
-
bundler (~> 1.0)
|
48
|
-
git (>= 1.2.5)
|
49
|
-
rake
|
50
|
-
json (1.6.3)
|
51
|
-
linecache (0.46)
|
52
|
-
rbx-require-relative (> 0.0.4)
|
53
|
-
mail (2.3.0)
|
54
|
-
i18n (>= 0.4.0)
|
55
|
-
mime-types (~> 1.16)
|
56
|
-
treetop (~> 1.4.8)
|
57
|
-
metaclass (0.0.1)
|
58
|
-
mime-types (1.17.2)
|
59
|
-
mocha (0.10.0)
|
60
|
-
metaclass (~> 0.0.1)
|
61
|
-
mongo (1.4.0)
|
62
|
-
bson (= 1.4.0)
|
63
|
-
mongo_mapper (0.11.0)
|
64
|
-
activemodel (~> 3.0)
|
65
|
-
activesupport (~> 3.0)
|
66
|
-
plucky (~> 0.4.0)
|
67
|
-
mongoid (2.2.2)
|
68
|
-
activemodel (~> 3.0)
|
69
|
-
mongo (~> 1.3)
|
70
|
-
tzinfo (~> 0.3.22)
|
71
|
-
multi_json (1.0.4)
|
72
|
-
nokogiri (1.5.0)
|
73
|
-
plucky (0.4.3)
|
74
|
-
mongo (~> 1.3)
|
75
|
-
polyglot (0.3.3)
|
76
|
-
rack (1.3.5)
|
77
|
-
rack-cache (1.1)
|
78
|
-
rack (>= 0.4)
|
79
|
-
rack-mount (0.8.3)
|
80
|
-
rack (>= 1.0.0)
|
81
|
-
rack-ssl (1.3.2)
|
82
|
-
rack
|
83
|
-
rack-test (0.6.1)
|
84
|
-
rack (>= 1.0)
|
85
|
-
rails (3.1.3)
|
86
|
-
actionmailer (= 3.1.3)
|
87
|
-
actionpack (= 3.1.3)
|
88
|
-
activerecord (= 3.1.3)
|
89
|
-
activeresource (= 3.1.3)
|
90
|
-
activesupport (= 3.1.3)
|
91
|
-
bundler (~> 1.0)
|
92
|
-
railties (= 3.1.3)
|
93
|
-
railties (3.1.3)
|
94
|
-
actionpack (= 3.1.3)
|
95
|
-
activesupport (= 3.1.3)
|
96
|
-
rack-ssl (~> 1.3.2)
|
97
|
-
rake (>= 0.8.7)
|
98
|
-
rdoc (~> 3.4)
|
99
|
-
thor (~> 0.14.6)
|
100
|
-
rake (0.9.2.2)
|
101
|
-
rbx-require-relative (0.0.5)
|
102
|
-
rdoc (3.11)
|
103
|
-
json (~> 1.4)
|
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
|
-
ruby-debug (0.10.4)
|
113
|
-
columnize (>= 0.1)
|
114
|
-
ruby-debug-base (~> 0.10.4.0)
|
115
|
-
ruby-debug-base (0.10.4)
|
116
|
-
linecache (>= 0.3)
|
117
|
-
sprockets (2.0.3)
|
118
|
-
hike (~> 1.2)
|
119
|
-
rack (~> 1.0)
|
120
|
-
tilt (~> 1.1, != 1.3.0)
|
121
|
-
sqlite3 (1.3.5)
|
122
|
-
sqlite3-ruby (1.3.3)
|
123
|
-
sqlite3 (>= 1.3.3)
|
124
|
-
thor (0.14.6)
|
125
|
-
tilt (1.3.3)
|
126
|
-
treetop (1.4.10)
|
127
|
-
polyglot
|
128
|
-
polyglot (>= 0.3.1)
|
129
|
-
tzinfo (0.3.31)
|
130
|
-
will_paginate (2.3.15)
|
131
|
-
|
132
|
-
PLATFORMS
|
133
|
-
ruby
|
134
|
-
|
135
|
-
DEPENDENCIES
|
136
|
-
accept_values_for
|
137
|
-
bson (= 1.4.0)
|
138
|
-
bson_ext (= 1.4.0)
|
139
|
-
bundler (~> 1.1.0)
|
140
|
-
fastercsv
|
141
|
-
jeweler (~> 1.6.0)
|
142
|
-
mocha
|
143
|
-
mongo_mapper (>= 0.11.0)
|
144
|
-
mongoid (= 2.2.2)
|
145
|
-
nokogiri
|
146
|
-
rails (>= 3.0)
|
147
|
-
rake
|
148
|
-
rspec
|
149
|
-
ruby-debug
|
150
|
-
sqlite3-ruby
|
151
|
-
will_paginate (= 2.3.15)
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# ActiveRecord is a little brain fuck.
|
2
|
-
# We can not call instance_eval on ActiveRecord::Relation class
|
3
|
-
# because it will automatically convert it to an array because #instance_eval
|
4
|
-
# is not included in the method list that do not cause force result loading
|
5
|
-
# That is why we need this helper class
|
6
|
-
class Datagrid::Filters::FilterEval
|
7
|
-
|
8
|
-
attr_accessor :filter, :scope, :value
|
9
|
-
|
10
|
-
def initialize(filter, scope, value)
|
11
|
-
@filter = filter
|
12
|
-
@scope = scope
|
13
|
-
@value = value
|
14
|
-
end
|
15
|
-
|
16
|
-
def run
|
17
|
-
instance_exec @value, &(@filter.block)
|
18
|
-
end
|
19
|
-
|
20
|
-
def driver
|
21
|
-
@filter.grid.driver
|
22
|
-
end
|
23
|
-
|
24
|
-
def method_missing(meth, *args, &blk)
|
25
|
-
if @scope.respond_to?(meth)
|
26
|
-
@scope.send(meth, *args, &blk)
|
27
|
-
else
|
28
|
-
super(meth, *args, &blk)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|