datagrid 1.3.2 → 1.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/app/views/datagrid/_enum_checkboxes.html.erb +11 -0
- data/datagrid.gemspec +4 -3
- data/lib/datagrid/core.rb +1 -1
- data/lib/datagrid/filters/base_filter.rb +9 -0
- data/lib/datagrid/filters/boolean_enum_filter.rb +4 -0
- data/lib/datagrid/form_builder.rb +19 -12
- data/lib/datagrid/ordering.rb +2 -2
- data/spec/datagrid/filters_spec.rb +13 -0
- data/spec/datagrid/form_builder_spec.rb +6 -1
- data/spec/datagrid/ordering_spec.rb +15 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7dd21661c0b7829a023451513b73670d0b0be11
|
4
|
+
data.tar.gz: 4b2b5bb748791497da883b6c24ad8f19c7ce3c81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d33aa9a4a8eceaacad1ff76ee91ba9dc3b9e312d2158f70998e7eaef707877042ace5218df8de47a28373dce7d92f6886e4fdf7be70ea27bf90baa6246f763c
|
7
|
+
data.tar.gz: d19b2234cbaba7712206f4b9ed7159cdcf2fd44ec320ff0c3a937a4ea3f03caf237499b4d2a594a0f76a84526fe28cbf23132279e0072a3eaf0535334179692c
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.3.
|
1
|
+
1.3.3
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<%#
|
2
|
+
Indent in this file may cause extra space to appear.
|
3
|
+
You can add indent if whitespace doesn't matter for you
|
4
|
+
%>
|
5
|
+
<%- elements.each do |value, text, checked| -%>
|
6
|
+
<%- id = [form.object_name, filter.name, value].join('_').underscore -%>
|
7
|
+
<%= form.label filter.name, options.merge(:for => id) do -%>
|
8
|
+
<%= form.check_box(filter.name, form.datagrid_extra_checkbox_options.merge(:multiple => true, :id => id, :checked => checked), value.to_s, nil) -%>
|
9
|
+
<%= text -%>
|
10
|
+
<%- end -%>
|
11
|
+
<%- end -%>
|
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.3.
|
5
|
+
# stub: datagrid 1.3.3 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "datagrid"
|
9
|
-
s.version = "1.3.
|
9
|
+
s.version = "1.3.3"
|
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 = "2014-
|
14
|
+
s.date = "2014-11-12"
|
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 = [
|
@@ -27,6 +27,7 @@ Gem::Specification.new do |s|
|
|
27
27
|
"Readme.markdown",
|
28
28
|
"VERSION",
|
29
29
|
"app/assets/stylesheets/datagrid.css.sass",
|
30
|
+
"app/views/datagrid/_enum_checkboxes.html.erb",
|
30
31
|
"app/views/datagrid/_form.html.erb",
|
31
32
|
"app/views/datagrid/_head.html.erb",
|
32
33
|
"app/views/datagrid/_order_for.html.erb",
|
data/lib/datagrid/core.rb
CHANGED
@@ -108,6 +108,15 @@ class Datagrid::Filters::BaseFilter #:nodoc:
|
|
108
108
|
options[:dummy]
|
109
109
|
end
|
110
110
|
|
111
|
+
def type
|
112
|
+
Datagrid::Filters::FILTER_TYPES.each do |type, klass|
|
113
|
+
if is_a?(klass)
|
114
|
+
return type
|
115
|
+
end
|
116
|
+
end
|
117
|
+
raise "wtf is #{inspect}"
|
118
|
+
end
|
119
|
+
|
111
120
|
protected
|
112
121
|
|
113
122
|
def default_filter_where(driver, scope, value)
|
@@ -17,6 +17,10 @@ module Datagrid
|
|
17
17
|
label(filter.name, text, options, &block)
|
18
18
|
end
|
19
19
|
|
20
|
+
def datagrid_extra_checkbox_options
|
21
|
+
::ActionPack::VERSION::MAJOR >= 4 ? {:include_hidden => false} : {}
|
22
|
+
end
|
23
|
+
|
20
24
|
protected
|
21
25
|
def datagrid_boolean_enum_filter(attribute_or_filter, options = {})
|
22
26
|
datagrid_enum_filter(attribute_or_filter, options)
|
@@ -44,18 +48,25 @@ module Datagrid
|
|
44
48
|
end
|
45
49
|
|
46
50
|
def datagrid_enum_filter(attribute_or_filter, options = {}, &block)
|
51
|
+
options = options.clone
|
47
52
|
filter = datagrid_get_filter(attribute_or_filter)
|
48
53
|
if filter.checkboxes?
|
49
54
|
options = add_html_classes(options, 'checkboxes')
|
50
|
-
|
55
|
+
partials_path = options.delete(:partials) || 'datagrid'
|
56
|
+
elements = filter.select(object).map do |element|
|
51
57
|
text, value = @template.send(:option_text_and_value, element)
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
58
|
+
checked = enum_checkbox_checked?(filter, value)
|
59
|
+
[value, text, checked]
|
60
|
+
end
|
61
|
+
@template.render(
|
62
|
+
:partial => File.join(partials_path, 'enum_checkboxes'),
|
63
|
+
:locals => {
|
64
|
+
:elements => elements,
|
65
|
+
:form => self,
|
66
|
+
:filter => filter,
|
67
|
+
:options => options,
|
68
|
+
}
|
69
|
+
)
|
59
70
|
else
|
60
71
|
if !options.has_key?(:multiple) && filter.multiple?
|
61
72
|
options[:multiple] = true
|
@@ -186,10 +197,6 @@ module Datagrid
|
|
186
197
|
Datagrid::Utils.add_html_classes(options, *classes)
|
187
198
|
end
|
188
199
|
|
189
|
-
def datagrid_extra_checkbox_options
|
190
|
-
::ActionPack::VERSION::MAJOR >= 4 ? {:include_hidden => false} : {}
|
191
|
-
end
|
192
|
-
|
193
200
|
class Error < StandardError
|
194
201
|
end
|
195
202
|
|
data/lib/datagrid/ordering.rb
CHANGED
@@ -15,10 +15,10 @@ module Datagrid
|
|
15
15
|
value = value.to_sym
|
16
16
|
column = column_by_name(value)
|
17
17
|
unless column
|
18
|
-
order_unsupported(value, "no column #{value} in #{self.class}")
|
18
|
+
self.class.order_unsupported(value, "no column #{value} in #{self.class}")
|
19
19
|
end
|
20
20
|
unless column.supports_order?
|
21
|
-
order_unsupported(column.name, "column don't support order" )
|
21
|
+
self.class.order_unsupported(column.name, "column don't support order" )
|
22
22
|
end
|
23
23
|
value
|
24
24
|
else
|
@@ -191,4 +191,17 @@ describe Datagrid::Filters do
|
|
191
191
|
expect(grid.class.filters.map(&:name)).to eq([:id, :name])
|
192
192
|
|
193
193
|
end
|
194
|
+
|
195
|
+
|
196
|
+
describe "#filter_by_name" do
|
197
|
+
it "should return filter object" do
|
198
|
+
r = test_report do
|
199
|
+
scope {Entry}
|
200
|
+
filter(:id, :integer)
|
201
|
+
end
|
202
|
+
|
203
|
+
object = r.filter_by_name(:id)
|
204
|
+
expect(object.type).to eq(:integer)
|
205
|
+
end
|
206
|
+
end
|
194
207
|
end
|
@@ -12,7 +12,12 @@ end
|
|
12
12
|
|
13
13
|
describe Datagrid::FormBuilder do
|
14
14
|
|
15
|
-
let(:template)
|
15
|
+
let(:template) do
|
16
|
+
ActionView::Base.new.tap do |v|
|
17
|
+
v.view_paths << File.expand_path("../../../app/views", __FILE__)
|
18
|
+
v.view_paths << File.expand_path("../../support/test_partials", __FILE__)
|
19
|
+
end
|
20
|
+
end
|
16
21
|
let(:view) { ActionView::Helpers::FormBuilder.new(:report, _grid, template, {}, Proc.new {|f| })}
|
17
22
|
|
18
23
|
|
@@ -106,4 +106,19 @@ describe Datagrid::Ordering do
|
|
106
106
|
expect(report.assets).to eq([second, first, third])
|
107
107
|
end
|
108
108
|
|
109
|
+
it "should work correctly with inherited classes" do
|
110
|
+
class OrderInheritenceBase
|
111
|
+
include Datagrid
|
112
|
+
scope { Entry }
|
113
|
+
end
|
114
|
+
|
115
|
+
class OrderInheritenceChild < OrderInheritenceBase
|
116
|
+
column(:name)
|
117
|
+
end
|
118
|
+
|
119
|
+
grid = OrderInheritenceChild.new(order: 'name')
|
120
|
+
expect(grid.assets).to eq([first, second, third])
|
121
|
+
grid.descending = true
|
122
|
+
expect(grid.assets).to eq([third, second, first])
|
123
|
+
end
|
109
124
|
end
|
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.3.
|
4
|
+
version: 1.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bogdan Gusiev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -223,6 +223,7 @@ files:
|
|
223
223
|
- Readme.markdown
|
224
224
|
- VERSION
|
225
225
|
- app/assets/stylesheets/datagrid.css.sass
|
226
|
+
- app/views/datagrid/_enum_checkboxes.html.erb
|
226
227
|
- app/views/datagrid/_form.html.erb
|
227
228
|
- app/views/datagrid/_head.html.erb
|
228
229
|
- app/views/datagrid/_order_for.html.erb
|