datagrid 1.6.3 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -1
- data/Readme.markdown +2 -2
- data/datagrid.gemspec +10 -14
- data/lib/datagrid/active_model.rb +25 -29
- data/lib/datagrid/column_names_attribute.rb +9 -7
- data/lib/datagrid/columns/column.rb +3 -1
- data/lib/datagrid/columns.rb +139 -171
- data/lib/datagrid/configuration.rb +6 -1
- data/lib/datagrid/core.rb +43 -22
- data/lib/datagrid/drivers/abstract_driver.rb +2 -1
- data/lib/datagrid/drivers/active_record.rb +2 -1
- data/lib/datagrid/drivers/array.rb +2 -1
- data/lib/datagrid/drivers/mongo_mapper.rb +2 -1
- data/lib/datagrid/drivers/mongoid.rb +3 -2
- data/lib/datagrid/drivers/sequel.rb +2 -1
- data/lib/datagrid/drivers.rb +2 -1
- data/lib/datagrid/engine.rb +3 -2
- data/lib/datagrid/filters/base_filter.rb +5 -2
- data/lib/datagrid/filters/boolean_enum_filter.rb +5 -3
- data/lib/datagrid/filters/boolean_filter.rb +2 -1
- data/lib/datagrid/filters/composite_filters.rb +5 -11
- data/lib/datagrid/filters/extended_boolean_filter.rb +2 -1
- data/lib/datagrid/filters/select_options.rb +34 -1
- data/lib/datagrid/filters.rb +38 -15
- data/lib/datagrid/form_builder.rb +10 -3
- data/lib/datagrid/helper.rb +47 -21
- data/lib/datagrid/ordering.rb +14 -14
- data/lib/datagrid/renderer.rb +2 -1
- data/lib/datagrid/scaffold.rb +1 -1
- data/lib/datagrid/utils.rb +1 -0
- data/lib/datagrid/version.rb +1 -1
- data/lib/datagrid.rb +2 -1
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cae619097e4bcae30de30bf2b5e9dc949f197146f3b17c01f5a2e4edb17e5ecc
|
4
|
+
data.tar.gz: 61751f34844c4127b7fc47bbacdbb2656d61aa015f574855de2a23bfc2dffe4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8bcea069b9bafc8b573226366a1abf194910d3fa5798711568b7106428d94ec915b141f23986094d8579ce8450328e1eb5b71932646c4224c0f1f7ac01f9718b
|
7
|
+
data.tar.gz: 7a40443171fe84d7b9f22daabdf2d1c182926fc69c9b47fde54e5a2271c394b8b5f7541a512e898c4e1472f93f4e94cf9cb90a7d47a9ad51113ee65efaf80610
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,13 @@
|
|
1
|
+
## 1.7.0
|
2
|
+
|
3
|
+
* Depend on `railties` instead of `rails` to prevent loading of unnecessary frameworks
|
4
|
+
* Bugfix `File.exist?` usage for ruby 3.0 [#307](https://github.com/bogdan/datagrid/issues/307)
|
5
|
+
* Drop support of old Ruby versions (< 2.7)
|
6
|
+
* Drop support of old Rails versions (< 6.0)
|
7
|
+
|
1
8
|
## 1.6.3
|
2
9
|
|
3
|
-
* Fix usage of options spread operator for
|
10
|
+
* Fix usage of options spread operator for Ruby 3.0 [#296](https://github.com/bogdan/datagrid/issues/296)
|
4
11
|
|
5
12
|
## 1.6.2
|
6
13
|
|
data/Readme.markdown
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Datagrid
|
2
2
|
|
3
|
-
[![Build Status](https://
|
3
|
+
[![Build Status](https://github.com/bogdan/datagrid/workflows/CI/badge.svg?branch=master)](https://github.com/bogdan/datagrid/actions)
|
4
4
|
|
5
5
|
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fbogdan%2Fdatagrid.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fbogdan%2Fdatagrid?ref=badge_shield)
|
6
6
|
|
@@ -27,7 +27,7 @@ Ruby library that helps you to build and represent table-like data with:
|
|
27
27
|
|
28
28
|
* [Readme](/Readme.markdown) - this read-me for basic information
|
29
29
|
* [Wiki](https://github.com/bogdan/datagrid/wiki) - general reference on how to use the gem
|
30
|
-
* [Rdoc](https://
|
30
|
+
* [Rdoc](https://rubydoc.info/gems/datagrid) - API reference
|
31
31
|
|
32
32
|
### Live Demo
|
33
33
|
|
data/datagrid.gemspec
CHANGED
@@ -1,14 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
3
|
-
|
4
|
-
require "datagrid/version"
|
2
|
+
|
3
|
+
require_relative "lib/datagrid/version"
|
5
4
|
|
6
5
|
Gem::Specification.new do |s|
|
7
6
|
s.name = "datagrid"
|
8
7
|
s.version = Datagrid::VERSION
|
9
8
|
s.require_paths = ["lib"]
|
10
9
|
s.authors = ["Bogdan Gusiev"]
|
11
|
-
s.date = "2020-09-07"
|
12
10
|
s.summary = "Ruby gem to create datagrids"
|
13
11
|
s.description = "This allows you to easily build datagrid aka data tables with sortable columns and filters"
|
14
12
|
s.email = "agresso@gmail.com"
|
@@ -23,19 +21,17 @@ Gem::Specification.new do |s|
|
|
23
21
|
"datagrid.gemspec",
|
24
22
|
]
|
25
23
|
s.files += `git ls-files | grep -E '^(app|lib|templates)'`.split("\n")
|
26
|
-
s.homepage = "
|
24
|
+
s.homepage = "https://github.com/bogdan/datagrid"
|
27
25
|
s.licenses = ["MIT"]
|
28
|
-
s.required_ruby_version = Gem::Requirement.new(">= 2.
|
29
|
-
s.rubygems_version = "3.0.8"
|
30
|
-
url = 'https://github.com/bogdan/datagrid'
|
26
|
+
s.required_ruby_version = Gem::Requirement.new(">= 2.7")
|
31
27
|
s.metadata = {
|
32
|
-
"homepage_uri" =>
|
33
|
-
"bug_tracker_uri" => "#{
|
34
|
-
"documentation_uri" => "#{
|
35
|
-
"changelog_uri" => "#{
|
36
|
-
"source_code_uri" =>
|
28
|
+
"homepage_uri" => s.homepage,
|
29
|
+
"bug_tracker_uri" => "#{s.homepage}/issues",
|
30
|
+
"documentation_uri" => "#{s.homepage}/wiki",
|
31
|
+
"changelog_uri" => "#{s.homepage}/blob/master/CHANGELOG.md",
|
32
|
+
"source_code_uri" => s.homepage,
|
37
33
|
}
|
38
34
|
|
39
|
-
s.add_dependency
|
35
|
+
s.add_dependency "railties", ">= 6.0"
|
40
36
|
end
|
41
37
|
|
@@ -1,10 +1,7 @@
|
|
1
|
-
|
2
1
|
module Datagrid
|
3
|
-
|
4
2
|
# Required to be ActiveModel compatible
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
module ActiveModel
|
4
|
+
# @!visibility private
|
8
5
|
def self.included(base)
|
9
6
|
base.extend ClassMethods
|
10
7
|
base.class_eval do
|
@@ -18,41 +15,40 @@ module Datagrid
|
|
18
15
|
extend ::ActiveModel::AttributesAssignment
|
19
16
|
rescue LoadError
|
20
17
|
end
|
21
|
-
|
22
18
|
end
|
23
|
-
|
24
|
-
end # self.included
|
19
|
+
end
|
25
20
|
|
26
21
|
module ClassMethods
|
22
|
+
# @return [String] URL query parameter name of the grid class
|
27
23
|
def param_name
|
28
24
|
self.to_s.underscore.tr('/', '_')
|
29
25
|
end
|
30
|
-
end
|
26
|
+
end
|
31
27
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
28
|
+
# @return [String] URL query parameter name of the grid class
|
29
|
+
def param_name
|
30
|
+
self.class.param_name
|
31
|
+
end
|
36
32
|
|
37
|
-
|
38
|
-
|
39
|
-
|
33
|
+
# @return [String] URL query parameter name of the grid class
|
34
|
+
def param_key
|
35
|
+
param_name
|
36
|
+
end
|
40
37
|
|
41
|
-
|
42
|
-
|
43
|
-
|
38
|
+
def to_key
|
39
|
+
[self.class.param_name]
|
40
|
+
end
|
44
41
|
|
45
|
-
|
46
|
-
|
47
|
-
|
42
|
+
def persisted?
|
43
|
+
false
|
44
|
+
end
|
48
45
|
|
49
|
-
|
50
|
-
|
51
|
-
|
46
|
+
def to_model
|
47
|
+
self
|
48
|
+
end
|
52
49
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
end # InstanceMethods
|
50
|
+
def to_param
|
51
|
+
self.param_name
|
52
|
+
end
|
57
53
|
end
|
58
54
|
end
|
@@ -21,11 +21,9 @@ module Datagrid
|
|
21
21
|
# will always present in the grid table and won't be listed
|
22
22
|
# in column names selection
|
23
23
|
# Accepts same options as <tt>:enum</tt> filter
|
24
|
-
#
|
25
|
-
# Examples:
|
26
|
-
#
|
24
|
+
# @example
|
27
25
|
# column_names_filter(header: "Choose columns")
|
28
|
-
#
|
26
|
+
# @see Datagrid::Filters::ClassMethods#filter
|
29
27
|
def column_names_filter(**options)
|
30
28
|
filter(
|
31
29
|
:column_names, :enum,
|
@@ -37,24 +35,28 @@ module Datagrid
|
|
37
35
|
end
|
38
36
|
end
|
39
37
|
|
40
|
-
|
38
|
+
# @!visibility private
|
39
|
+
def columns(*args, **options)
|
41
40
|
super(*selected_column_names(*args), **options)
|
42
41
|
end
|
43
42
|
|
44
|
-
# Returns a list of enabled columns with <tt
|
43
|
+
# Returns a list of enabled columns with <tt>mandatory: true</tt> option
|
45
44
|
# If no mandatory columns specified than all of them considered mandatory
|
45
|
+
# @return [Array<Datagrid::Columns::Column>]
|
46
46
|
def mandatory_columns
|
47
47
|
available_columns.select {|c| c.mandatory? }
|
48
48
|
end
|
49
49
|
|
50
50
|
# Returns a list of enabled columns without <tt>:mandatory => true</tt> option
|
51
|
+
# If no mandatory columns specified than all of them considered mandatory but not optional
|
52
|
+
# @return [Array<Datagrid::Columns::Column>]
|
51
53
|
def optional_columns
|
52
54
|
available_columns - mandatory_columns
|
53
55
|
end
|
54
56
|
|
55
57
|
protected
|
56
58
|
|
57
|
-
def optional_columns_select
|
59
|
+
def optional_columns_select
|
58
60
|
optional_columns.map {|c| [c.header, c.name] }
|
59
61
|
end
|
60
62
|
|