datagrid 1.6.2 → 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 +11 -0
- data/Readme.markdown +5 -4
- data/datagrid.gemspec +10 -14
- data/lib/datagrid/active_model.rb +25 -29
- data/lib/datagrid/column_names_attribute.rb +21 -20
- data/lib/datagrid/columns/column.rb +7 -1
- data/lib/datagrid/columns.rb +157 -189
- 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 +9 -15
- 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 +17 -8
- data/lib/datagrid/helper.rb +49 -23
- data/lib/datagrid/ordering.rb +14 -14
- data/lib/datagrid/renderer.rb +3 -4
- 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,3 +1,14 @@
|
|
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
|
+
|
8
|
+
## 1.6.3
|
9
|
+
|
10
|
+
* Fix usage of options spread operator for Ruby 3.0 [#296](https://github.com/bogdan/datagrid/issues/296)
|
11
|
+
|
1
12
|
## 1.6.2
|
2
13
|
|
3
14
|
* Add `input_options` and `label_options` to `filter` method [#294](https://github.com/bogdan/datagrid/issues/294)
|
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
|
|
@@ -23,10 +23,11 @@ Ruby library that helps you to build and represent table-like data with:
|
|
23
23
|
[Create an issue](https://github.com/bogdan/datagrid/issues/new) if you want more.
|
24
24
|
|
25
25
|
|
26
|
-
###
|
26
|
+
### Documentation
|
27
27
|
|
28
|
-
*
|
29
|
-
*
|
28
|
+
* [Readme](/Readme.markdown) - this read-me for basic information
|
29
|
+
* [Wiki](https://github.com/bogdan/datagrid/wiki) - general reference on how to use the gem
|
30
|
+
* [Rdoc](https://rubydoc.info/gems/datagrid) - API reference
|
30
31
|
|
31
32
|
### Live Demo
|
32
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,45 +21,46 @@ 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
|
-
#
|
26
|
-
#
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
:
|
32
|
-
:
|
33
|
-
|
34
|
-
|
24
|
+
# @example
|
25
|
+
# column_names_filter(header: "Choose columns")
|
26
|
+
# @see Datagrid::Filters::ClassMethods#filter
|
27
|
+
def column_names_filter(**options)
|
28
|
+
filter(
|
29
|
+
:column_names, :enum,
|
30
|
+
select: :optional_columns_select,
|
31
|
+
multiple: true,
|
32
|
+
dummy: true,
|
33
|
+
**options,
|
34
|
+
)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
column_names << options
|
42
|
-
super(*column_names)
|
38
|
+
# @!visibility private
|
39
|
+
def columns(*args, **options)
|
40
|
+
super(*selected_column_names(*args), **options)
|
43
41
|
end
|
44
42
|
|
45
|
-
# Returns a list of enabled columns with <tt
|
43
|
+
# Returns a list of enabled columns with <tt>mandatory: true</tt> option
|
46
44
|
# If no mandatory columns specified than all of them considered mandatory
|
45
|
+
# @return [Array<Datagrid::Columns::Column>]
|
47
46
|
def mandatory_columns
|
48
47
|
available_columns.select {|c| c.mandatory? }
|
49
48
|
end
|
50
49
|
|
51
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>]
|
52
53
|
def optional_columns
|
53
54
|
available_columns - mandatory_columns
|
54
55
|
end
|
55
56
|
|
56
57
|
protected
|
57
58
|
|
58
|
-
def optional_columns_select
|
59
|
+
def optional_columns_select
|
59
60
|
optional_columns.map {|c| [c.header, c.name] }
|
60
61
|
end
|
61
62
|
|
62
|
-
def selected_column_names(*args)
|
63
|
+
def selected_column_names(*args)
|
63
64
|
if args.any?
|
64
65
|
args.compact!
|
65
66
|
args.map!(&:to_sym)
|
@@ -75,7 +76,7 @@ module Datagrid
|
|
75
76
|
|
76
77
|
def columns_visibility_enabled?
|
77
78
|
columns_array.any? do |column|
|
78
|
-
column.
|
79
|
+
column.mandatory_explicitly_set?
|
79
80
|
end
|
80
81
|
end
|
81
82
|
|
@@ -1,6 +1,8 @@
|
|
1
1
|
class Datagrid::Columns::Column
|
2
2
|
|
3
|
-
class
|
3
|
+
# Datagrid class holding an information of
|
4
|
+
# how a column should be rendered in data/console/csv format and HTML format
|
5
|
+
class ResponseFormat
|
4
6
|
|
5
7
|
attr_accessor :data_block, :html_block
|
6
8
|
|
@@ -106,6 +108,10 @@ class Datagrid::Columns::Column
|
|
106
108
|
!! options[:mandatory]
|
107
109
|
end
|
108
110
|
|
111
|
+
def mandatory_explicitly_set?
|
112
|
+
options.key?(:mandatory)
|
113
|
+
end
|
114
|
+
|
109
115
|
def enabled?(grid)
|
110
116
|
::Datagrid::Utils.process_availability(grid, options[:if], options[:unless])
|
111
117
|
end
|