datagrid 1.5.8 → 1.5.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +1 -0
- data/Gemfile +3 -3
- data/VERSION +1 -1
- data/datagrid.gemspec +7 -7
- data/lib/datagrid/columns/column.rb +0 -5
- data/lib/datagrid/filters.rb +1 -1
- data/lib/datagrid/filters/base_filter.rb +3 -16
- data/lib/datagrid/filters/dynamic_filter.rb +15 -5
- data/lib/datagrid/filters/select_options.rb +1 -4
- data/lib/datagrid/form_builder.rb +3 -30
- data/lib/datagrid/locale/en.yml +6 -6
- data/spec/datagrid/form_builder_spec.rb +1 -28
- data/spec/datagrid/helper_spec.rb +1 -1
- data/spec/support/active_record.rb +1 -0
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 94a9a3ff232cd83f323e280e35a805ebd4ec725b74b531c18328c4de27952f2f
|
4
|
+
data.tar.gz: c91f39764fa86f0d8b016de33eeabfd37b47d16411f3f52ec796f2bf1d14d534
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b999afc64d7094dfd47a2e4f393824df58edf15769c445a9d16712dc6f531f3b30f872046cd657bc9323df6a460b4d1a74334fc4b498de141a9998d3aa6c34bc
|
7
|
+
data.tar.gz: 89d0e83bd75e28ee33dc890d2f5f82de6391a9d32b0723e77afa8dfc0856d126c1fe0ee4c8ab5b0b2f5491e5908b45e14de0bd18669c2786764faeac8c6fc0c2
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -6,17 +6,17 @@ group :development do
|
|
6
6
|
|
7
7
|
gem "bundler"
|
8
8
|
if RUBY_VERSION >= "2.3"
|
9
|
-
gem "jeweler", ">= 2.1.2", platform: [:ruby_23, :ruby_24]
|
9
|
+
gem "jeweler", ">= 2.1.2", platform: [:ruby_23, :ruby_24, :ruby_25]
|
10
10
|
end
|
11
11
|
|
12
12
|
|
13
13
|
#gem "json", ">= 1.9"
|
14
|
-
gem "pry-byebug", :platform => [:
|
14
|
+
gem "pry-byebug", :platform => [:ruby_24, :ruby_25, :ruby_22, :ruby_23] & Bundler::Dsl::VALID_PLATFORMS
|
15
15
|
|
16
16
|
gem "rspec", ">= 3"
|
17
17
|
gem "nokogiri" # used to test html output
|
18
18
|
|
19
|
-
gem "sqlite3"
|
19
|
+
gem "sqlite3", "~> 1.3.6"
|
20
20
|
gem "sequel"
|
21
21
|
|
22
22
|
group :mongo do
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.5.
|
1
|
+
1.5.9
|
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.5.
|
5
|
+
# stub: datagrid 1.5.9 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "datagrid".freeze
|
9
|
-
s.version = "1.5.
|
9
|
+
s.version = "1.5.9"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
13
13
|
s.authors = ["Bogdan Gusiev".freeze]
|
14
|
-
s.date = "
|
14
|
+
s.date = "2019-05-10"
|
15
15
|
s.description = "This allows you to easily build datagrid aka data tables with sortable columns and filters".freeze
|
16
16
|
s.email = "agresso@gmail.com".freeze
|
17
17
|
s.extra_rdoc_files = [
|
@@ -130,7 +130,7 @@ Gem::Specification.new do |s|
|
|
130
130
|
s.homepage = "http://github.com/bogdan/datagrid".freeze
|
131
131
|
s.licenses = ["MIT".freeze]
|
132
132
|
s.required_ruby_version = Gem::Requirement.new(">= 2.0".freeze)
|
133
|
-
s.rubygems_version = "2.
|
133
|
+
s.rubygems_version = "2.7.8".freeze
|
134
134
|
s.summary = "Ruby gem to create datagrids".freeze
|
135
135
|
|
136
136
|
if s.respond_to? :specification_version then
|
@@ -143,7 +143,7 @@ Gem::Specification.new do |s|
|
|
143
143
|
s.add_development_dependency(%q<pry-byebug>.freeze, [">= 0"])
|
144
144
|
s.add_development_dependency(%q<rspec>.freeze, [">= 3"])
|
145
145
|
s.add_development_dependency(%q<nokogiri>.freeze, [">= 0"])
|
146
|
-
s.add_development_dependency(%q<sqlite3>.freeze, ["
|
146
|
+
s.add_development_dependency(%q<sqlite3>.freeze, ["~> 1.3.6"])
|
147
147
|
s.add_development_dependency(%q<sequel>.freeze, [">= 0"])
|
148
148
|
s.add_development_dependency(%q<mongoid>.freeze, [">= 0"])
|
149
149
|
s.add_development_dependency(%q<bson>.freeze, [">= 0"])
|
@@ -155,7 +155,7 @@ Gem::Specification.new do |s|
|
|
155
155
|
s.add_dependency(%q<pry-byebug>.freeze, [">= 0"])
|
156
156
|
s.add_dependency(%q<rspec>.freeze, [">= 3"])
|
157
157
|
s.add_dependency(%q<nokogiri>.freeze, [">= 0"])
|
158
|
-
s.add_dependency(%q<sqlite3>.freeze, ["
|
158
|
+
s.add_dependency(%q<sqlite3>.freeze, ["~> 1.3.6"])
|
159
159
|
s.add_dependency(%q<sequel>.freeze, [">= 0"])
|
160
160
|
s.add_dependency(%q<mongoid>.freeze, [">= 0"])
|
161
161
|
s.add_dependency(%q<bson>.freeze, [">= 0"])
|
@@ -168,7 +168,7 @@ Gem::Specification.new do |s|
|
|
168
168
|
s.add_dependency(%q<pry-byebug>.freeze, [">= 0"])
|
169
169
|
s.add_dependency(%q<rspec>.freeze, [">= 3"])
|
170
170
|
s.add_dependency(%q<nokogiri>.freeze, [">= 0"])
|
171
|
-
s.add_dependency(%q<sqlite3>.freeze, ["
|
171
|
+
s.add_dependency(%q<sqlite3>.freeze, ["~> 1.3.6"])
|
172
172
|
s.add_dependency(%q<sequel>.freeze, [">= 0"])
|
173
173
|
s.add_dependency(%q<mongoid>.freeze, [">= 0"])
|
174
174
|
s.add_dependency(%q<bson>.freeze, [">= 0"])
|
@@ -123,11 +123,6 @@ class Datagrid::Columns::Column
|
|
123
123
|
end
|
124
124
|
|
125
125
|
|
126
|
-
def block
|
127
|
-
Datagrid::Utils.warn_once("Datagrid::Columns::Column#block is deprecated. Use #html_block or #data_block instead")
|
128
|
-
data_block
|
129
|
-
end
|
130
|
-
|
131
126
|
def generic_value(model, grid)
|
132
127
|
grid.generic_value(self, model)
|
133
128
|
end
|
data/lib/datagrid/filters.rb
CHANGED
@@ -7,7 +7,7 @@ class Datagrid::Filters::BaseFilter #:nodoc:
|
|
7
7
|
|
8
8
|
def initialize(grid_class, name, options = {}, &block)
|
9
9
|
self.grid_class = grid_class
|
10
|
-
self.name = name
|
10
|
+
self.name = name.to_sym
|
11
11
|
self.options = options
|
12
12
|
self.block = block || default_filter_block
|
13
13
|
end
|
@@ -61,18 +61,10 @@ class Datagrid::Filters::BaseFilter #:nodoc:
|
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
-
def default(object
|
65
|
-
unless object
|
66
|
-
Datagrid::Utils.warn_once("#{self.class.name}#default without argument is deprecated")
|
67
|
-
end
|
64
|
+
def default(object)
|
68
65
|
default = self.options[:default]
|
69
66
|
if default.is_a?(Symbol)
|
70
|
-
|
71
|
-
object.send(default)
|
72
|
-
else
|
73
|
-
Datagrid::Utils.warn_once(":default as a Symbol is now treated as a method name. Use String instead or -> { default } if you really want default value to be a Symbol but not a String.")
|
74
|
-
default
|
75
|
-
end
|
67
|
+
object.send(default)
|
76
68
|
elsif default.respond_to?(:call)
|
77
69
|
Datagrid::Utils.apply_args(object, &default)
|
78
70
|
else
|
@@ -80,11 +72,6 @@ class Datagrid::Filters::BaseFilter #:nodoc:
|
|
80
72
|
end
|
81
73
|
end
|
82
74
|
|
83
|
-
def multiple
|
84
|
-
Datagrid::Utils.warn_once("Filter#multiple method is deprecated. Use Filter#multiple? instead")
|
85
|
-
multiple?
|
86
|
-
end
|
87
|
-
|
88
75
|
def multiple?
|
89
76
|
self.options[:multiple]
|
90
77
|
end
|
@@ -4,12 +4,22 @@ class Datagrid::Filters::DynamicFilter < Datagrid::Filters::BaseFilter
|
|
4
4
|
|
5
5
|
include Datagrid::Filters::SelectOptions
|
6
6
|
|
7
|
+
EQUAL_OPERATION = '='
|
8
|
+
LIKE_OPERATION = '=~'
|
9
|
+
MORE_EQUAL_OPERATION = '>='
|
10
|
+
LESS_EQUAL_OPERATION = '<='
|
11
|
+
DEFAULT_OPERATIONS = [
|
12
|
+
EQUAL_OPERATION,
|
13
|
+
LIKE_OPERATION,
|
14
|
+
MORE_EQUAL_OPERATION,
|
15
|
+
LESS_EQUAL_OPERATION,
|
16
|
+
]
|
7
17
|
AVAILABLE_OPERATIONS = %w(= =~ >= <=)
|
8
18
|
|
9
19
|
def initialize(*)
|
10
20
|
super
|
11
21
|
options[:select] ||= default_select
|
12
|
-
options[:operations] ||=
|
22
|
+
options[:operations] ||= DEFAULT_OPERATIONS
|
13
23
|
unless options.has_key?(:include_blank)
|
14
24
|
options[:include_blank] = false
|
15
25
|
end
|
@@ -35,12 +45,12 @@ class Datagrid::Filters::DynamicFilter < Datagrid::Filters::BaseFilter
|
|
35
45
|
raise Datagrid::FilteringError, "Unknown operation: #{operation.inspect}. Available operations: #{operations.join(' ')}"
|
36
46
|
end
|
37
47
|
case operation
|
38
|
-
when
|
48
|
+
when EQUAL_OPERATION
|
39
49
|
if date_conversion
|
40
50
|
value = Datagrid::Utils.format_date_as_timestamp(value)
|
41
51
|
end
|
42
52
|
driver.where(scope, field, value)
|
43
|
-
when
|
53
|
+
when LIKE_OPERATION
|
44
54
|
if column_type(field) == :string
|
45
55
|
driver.contains(scope, field, value)
|
46
56
|
else
|
@@ -49,12 +59,12 @@ class Datagrid::Filters::DynamicFilter < Datagrid::Filters::BaseFilter
|
|
49
59
|
end
|
50
60
|
driver.where(scope, field, value)
|
51
61
|
end
|
52
|
-
when
|
62
|
+
when MORE_EQUAL_OPERATION
|
53
63
|
if date_conversion
|
54
64
|
value = value.beginning_of_day
|
55
65
|
end
|
56
66
|
driver.greater_equal(scope, field, value)
|
57
|
-
when
|
67
|
+
when LESS_EQUAL_OPERATION
|
58
68
|
if date_conversion
|
59
69
|
value = value.end_of_day
|
60
70
|
end
|
@@ -1,9 +1,6 @@
|
|
1
1
|
module Datagrid::Filters::SelectOptions
|
2
2
|
|
3
|
-
def select(object
|
4
|
-
unless object
|
5
|
-
Datagrid::Utils.warn_once("#{self.class.name}#select without argument is deprecated")
|
6
|
-
end
|
3
|
+
def select(object)
|
7
4
|
select = self.options[:select]
|
8
5
|
if select.is_a?(Symbol)
|
9
6
|
object.send(select)
|
@@ -140,43 +140,16 @@ module Datagrid
|
|
140
140
|
if filter.range?
|
141
141
|
partial = partial_path('range_filter')
|
142
142
|
options = options.merge(:multiple => true)
|
143
|
-
|
144
|
-
|
145
143
|
from_options = datagrid_range_filter_options(object, filter, :from, options)
|
146
144
|
to_options = datagrid_range_filter_options(object, filter, :to, options)
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
format_key = "datagrid.filters.#{type}.range_format"
|
151
|
-
separator_key = "datagrid.filters.#{type}.range_separator"
|
152
|
-
# 2 inputs: "from date" and "to date" to specify a range
|
153
|
-
if I18n.exists?(separator_key)
|
154
|
-
# Support deprecated translation option: range_separator
|
155
|
-
warn_deprecated_range_localization(separator_key)
|
156
|
-
separator = I18n.t(separator_key, default: '').presence
|
157
|
-
[from_input, separator, to_input].join.html_safe
|
158
|
-
elsif I18n.exists?(format_key)
|
159
|
-
# Support deprecated translation option: range_format
|
160
|
-
warn_deprecated_range_localization(format_key)
|
161
|
-
I18n.t(format_key, :from_input => from_input, :to_input => to_input).html_safe
|
162
|
-
else
|
163
|
-
# More flexible way to render via partial
|
164
|
-
@template.render :partial => partial, :locals => {
|
165
|
-
:from_options => from_options, :to_options => to_options, :filter => filter, :form => self
|
166
|
-
}
|
167
|
-
end
|
145
|
+
@template.render :partial => partial, :locals => {
|
146
|
+
:from_options => from_options, :to_options => to_options, :filter => filter, :form => self
|
147
|
+
}
|
168
148
|
else
|
169
149
|
datagrid_default_filter(filter, options)
|
170
150
|
end
|
171
151
|
end
|
172
152
|
|
173
|
-
def warn_deprecated_range_localization(key)
|
174
|
-
Datagrid::Utils.warn_once(
|
175
|
-
"#{key} localization key is deprectated. " +
|
176
|
-
"Customize formatting by rake datagrid:copy_partials and editing app/views/datagrid/range_filter partial."
|
177
|
-
)
|
178
|
-
end
|
179
|
-
|
180
153
|
def datagrid_range_filter_options(object, filter, type, options)
|
181
154
|
type_method_map = {:from => :first, :to => :last}
|
182
155
|
options = add_html_classes(options, type)
|
data/lib/datagrid/locale/en.yml
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
en:
|
2
2
|
datagrid:
|
3
3
|
no_results:
|
4
|
-
"
|
4
|
+
"――"
|
5
5
|
table:
|
6
6
|
order:
|
7
|
-
asc: "
|
8
|
-
desc: "
|
7
|
+
asc: "↑"
|
8
|
+
desc: "↓"
|
9
9
|
no_columns: "No columns selected"
|
10
10
|
form:
|
11
11
|
search: "Search"
|
@@ -17,7 +17,7 @@ en:
|
|
17
17
|
|
18
18
|
dynamic:
|
19
19
|
operations:
|
20
|
-
">=": "
|
21
|
-
"<=": "
|
20
|
+
">=": "≥"
|
21
|
+
"<=": "≤"
|
22
22
|
"=": "="
|
23
|
-
"=~": "
|
23
|
+
"=~": "≈"
|
@@ -154,34 +154,8 @@ describe Datagrid::FormBuilder do
|
|
154
154
|
) }
|
155
155
|
|
156
156
|
end
|
157
|
-
|
158
|
-
context "when deprecated format translation specified" do
|
159
|
-
let(:_range) { nil }
|
160
|
-
around(:each) do |example|
|
161
|
-
store_translations(:en, datagrid: {filters: {integer: {range_format: "from %{from_input} to %{to_input}"}}}) do
|
162
|
-
silence_warnings do
|
163
|
-
example.run
|
164
|
-
end
|
165
|
-
end
|
166
|
-
end
|
167
|
-
it { should equal_to_dom(
|
168
|
-
'from <input class="group_id integer_filter from" multiple type="text" name="report[group_id][]"> to <input class="group_id integer_filter to" multiple type="text" name="report[group_id][]">'
|
169
|
-
)}
|
170
|
-
end
|
171
|
-
context "when deprecated separator is specified" do
|
172
|
-
let(:_range) { nil }
|
173
|
-
around(:each) do |example|
|
174
|
-
store_translations(:en, datagrid: {filters: {integer: {range_separator: " | "}}}) do
|
175
|
-
silence_warnings do
|
176
|
-
example.run
|
177
|
-
end
|
178
|
-
end
|
179
|
-
end
|
180
|
-
it { should equal_to_dom(
|
181
|
-
'<input class="group_id integer_filter from" multiple type="text" name="report[group_id][]"> | <input class="group_id integer_filter to" multiple type="text" name="report[group_id][]">'
|
182
|
-
)}
|
183
|
-
end
|
184
157
|
end
|
158
|
+
|
185
159
|
context "with float filter type and range option" do
|
186
160
|
let(:_filter) { :rating }
|
187
161
|
let(:_grid) {
|
@@ -198,7 +172,6 @@ describe Datagrid::FormBuilder do
|
|
198
172
|
)}
|
199
173
|
end
|
200
174
|
|
201
|
-
|
202
175
|
context "with date filter type and range option" do
|
203
176
|
let(:_filter) { :created_at }
|
204
177
|
let(:_grid) {
|
@@ -44,7 +44,7 @@ describe Datagrid::Helper do
|
|
44
44
|
expect(datagrid_table).to match_css_pattern(
|
45
45
|
"table.datagrid tr td.noresults" => 1
|
46
46
|
)
|
47
|
-
expect(datagrid_table).to include("
|
47
|
+
expect(datagrid_table).to include(I18n.t("datagrid.no_results"))
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
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.5.
|
4
|
+
version: 1.5.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bogdan Gusiev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -98,16 +98,16 @@ dependencies:
|
|
98
98
|
name: sqlite3
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 1.3.6
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - "
|
108
|
+
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 1.3.6
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: sequel
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -300,7 +300,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
300
300
|
version: '0'
|
301
301
|
requirements: []
|
302
302
|
rubyforge_project:
|
303
|
-
rubygems_version: 2.
|
303
|
+
rubygems_version: 2.7.8
|
304
304
|
signing_key:
|
305
305
|
specification_version: 4
|
306
306
|
summary: Ruby gem to create datagrids
|