datagrid 1.8.2 → 2.0.0.pre.alpha
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 -1
- data/{Readme.markdown → README.md} +44 -27
- data/app/assets/stylesheets/datagrid.css +145 -0
- data/app/views/datagrid/_enum_checkboxes.html.erb +5 -3
- data/app/views/datagrid/_form.html.erb +4 -4
- data/app/views/datagrid/_head.html.erb +26 -3
- data/app/views/datagrid/_range_filter.html.erb +5 -3
- data/app/views/datagrid/_row.html.erb +12 -1
- data/app/views/datagrid/_table.html.erb +4 -4
- data/datagrid.gemspec +6 -6
- data/lib/datagrid/active_model.rb +9 -17
- data/lib/datagrid/base.rb +39 -0
- data/lib/datagrid/column_names_attribute.rb +9 -11
- data/lib/datagrid/columns/column.rb +155 -133
- data/lib/datagrid/columns.rb +254 -45
- data/lib/datagrid/configuration.rb +23 -10
- data/lib/datagrid/core.rb +89 -54
- data/lib/datagrid/deprecated_object.rb +20 -0
- data/lib/datagrid/drivers/abstract_driver.rb +12 -23
- data/lib/datagrid/drivers/active_record.rb +24 -26
- data/lib/datagrid/drivers/array.rb +22 -14
- data/lib/datagrid/drivers/mongo_mapper.rb +15 -14
- data/lib/datagrid/drivers/mongoid.rb +15 -17
- data/lib/datagrid/drivers/sequel.rb +14 -19
- data/lib/datagrid/drivers.rb +2 -1
- data/lib/datagrid/engine.rb +11 -3
- data/lib/datagrid/filters/base_filter.rb +166 -142
- data/lib/datagrid/filters/boolean_filter.rb +19 -5
- data/lib/datagrid/filters/date_filter.rb +33 -35
- data/lib/datagrid/filters/date_time_filter.rb +24 -16
- data/lib/datagrid/filters/default_filter.rb +9 -3
- data/lib/datagrid/filters/dynamic_filter.rb +151 -105
- data/lib/datagrid/filters/enum_filter.rb +43 -19
- data/lib/datagrid/filters/extended_boolean_filter.rb +39 -30
- data/lib/datagrid/filters/float_filter.rb +16 -5
- data/lib/datagrid/filters/integer_filter.rb +21 -10
- data/lib/datagrid/filters/ranged_filter.rb +66 -45
- data/lib/datagrid/filters/select_options.rb +58 -49
- data/lib/datagrid/filters/string_filter.rb +9 -4
- data/lib/datagrid/filters.rb +190 -57
- data/lib/datagrid/form_builder.rb +116 -128
- data/lib/datagrid/generators/scaffold.rb +185 -0
- data/lib/datagrid/generators/views.rb +20 -0
- data/lib/datagrid/helper.rb +397 -22
- data/lib/datagrid/ordering.rb +26 -29
- data/lib/datagrid/rspec.rb +6 -10
- data/lib/datagrid/utils.rb +37 -30
- data/lib/datagrid/version.rb +3 -1
- data/lib/datagrid.rb +18 -28
- data/templates/base.rb.erb +6 -4
- data/templates/grid.rb.erb +1 -1
- metadata +15 -16
- data/app/assets/stylesheets/datagrid.sass +0 -134
- data/lib/datagrid/filters/composite_filters.rb +0 -49
- data/lib/datagrid/renderer.rb +0 -157
- data/lib/datagrid/scaffold.rb +0 -129
- data/lib/tasks/datagrid_tasks.rake +0 -15
- data/templates/controller.rb.erb +0 -6
- data/templates/index.html.erb +0 -5
data/lib/datagrid/utils.rb
CHANGED
@@ -1,44 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Datagrid
|
2
4
|
# @!visibility private
|
3
|
-
module Utils
|
5
|
+
module Utils
|
4
6
|
class << self
|
5
|
-
|
6
|
-
|
7
|
-
TRUTH = [true, 1, "1", "true", "yes", "on"]
|
7
|
+
TRUTH = [true, 1, "1", "true", "yes", "on"].freeze
|
8
8
|
|
9
9
|
def booleanize(value)
|
10
|
-
if value.respond_to?(:downcase)
|
11
|
-
value = value.downcase
|
12
|
-
end
|
10
|
+
value = value.downcase if value.respond_to?(:downcase)
|
13
11
|
TRUTH.include?(value)
|
14
12
|
end
|
15
13
|
|
16
14
|
def translate_from_namespace(namespace, grid_class, key)
|
17
|
-
|
18
15
|
lookups = []
|
19
16
|
namespaced_key = "#{namespace}.#{key}"
|
20
17
|
|
21
18
|
grid_class.ancestors.each do |ancestor|
|
22
|
-
if ancestor.respond_to?(:model_name)
|
23
|
-
lookups << :"datagrid.#{ancestor.model_name.i18n_key}.#{namespaced_key}"
|
24
|
-
end
|
19
|
+
lookups << :"datagrid.#{ancestor.model_name.i18n_key}.#{namespaced_key}" if ancestor.respond_to?(:model_name)
|
25
20
|
end
|
26
21
|
lookups << :"datagrid.defaults.#{namespaced_key}"
|
27
22
|
lookups << key.to_s.humanize
|
28
23
|
I18n.t(lookups.shift, default: lookups).presence
|
29
24
|
end
|
30
25
|
|
26
|
+
def deprecator
|
27
|
+
if defined?(Rails) && Rails.version >= "7.1.0"
|
28
|
+
Rails.deprecator
|
29
|
+
else
|
30
|
+
ActiveSupport::Deprecation
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
31
34
|
def warn_once(message, delay = 5)
|
32
35
|
@warnings ||= {}
|
33
36
|
timestamp = @warnings[message]
|
34
37
|
return false if timestamp && timestamp >= Time.now - delay
|
35
|
-
|
38
|
+
|
39
|
+
deprecator.warn(message)
|
36
40
|
@warnings[message] = Time.now
|
37
41
|
true
|
38
42
|
end
|
39
43
|
|
40
44
|
def add_html_classes(options, *classes)
|
41
45
|
return options if classes.empty?
|
46
|
+
|
42
47
|
options = options.clone
|
43
48
|
options[:class] ||= []
|
44
49
|
array = options[:class].is_a?(Array)
|
@@ -52,41 +57,42 @@ module Datagrid
|
|
52
57
|
end
|
53
58
|
|
54
59
|
def extract_position_from_options(array, options)
|
55
|
-
before
|
56
|
-
|
57
|
-
|
58
|
-
end
|
60
|
+
before = options[:before]
|
61
|
+
after = options[:after]
|
62
|
+
raise Datagrid::ConfigurationError, "Options :before and :after can not be used together" if before && after
|
59
63
|
# Consider as before all
|
60
64
|
return 0 if before == true
|
65
|
+
|
61
66
|
if before
|
62
67
|
before = before.to_sym
|
63
|
-
array.index {|c| c.name.to_sym == before }
|
68
|
+
array.index { |c| c.name.to_sym == before }
|
64
69
|
elsif after
|
65
70
|
after = after.to_sym
|
66
|
-
array.index {|c| c.name.to_sym == after } + 1
|
71
|
+
array.index { |c| c.name.to_sym == after } + 1
|
67
72
|
else
|
68
73
|
-1
|
69
74
|
end
|
70
75
|
end
|
71
76
|
|
72
77
|
def apply_args(*args, &block)
|
73
|
-
size = block.arity
|
78
|
+
size = block.arity.negative? ? args.size : block.arity
|
74
79
|
block.call(*args.slice(0, size))
|
75
80
|
end
|
76
81
|
|
77
82
|
def parse_date(value)
|
78
83
|
return nil if value.blank?
|
79
84
|
return value if value.is_a?(Range)
|
85
|
+
|
80
86
|
if value.is_a?(String)
|
81
87
|
Array(Datagrid.configuration.date_formats).each do |format|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
end
|
88
|
+
return Date.strptime(value, format)
|
89
|
+
rescue ::ArgumentError
|
90
|
+
nil
|
86
91
|
end
|
87
92
|
end
|
88
93
|
return Date.parse(value) if value.is_a?(String)
|
89
94
|
return value.to_date if value.respond_to?(:to_date)
|
95
|
+
|
90
96
|
value
|
91
97
|
rescue ::ArgumentError
|
92
98
|
nil
|
@@ -95,16 +101,18 @@ module Datagrid
|
|
95
101
|
def parse_datetime(value)
|
96
102
|
return nil if value.blank?
|
97
103
|
return value if value.is_a?(Range)
|
104
|
+
return value if defined?(ActiveSupport::TimeWithZone) && value.is_a?(ActiveSupport::TimeWithZone)
|
105
|
+
|
98
106
|
if value.is_a?(String)
|
99
107
|
Array(Datagrid.configuration.datetime_formats).each do |format|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
end
|
108
|
+
return Time.strptime(value, format)
|
109
|
+
rescue ::ArgumentError
|
110
|
+
nil
|
104
111
|
end
|
105
112
|
end
|
106
113
|
return Time.parse(value) if value.is_a?(String)
|
107
114
|
return value.to_time if value.respond_to?(:to_time)
|
115
|
+
|
108
116
|
value
|
109
117
|
rescue ::ArgumentError
|
110
118
|
nil
|
@@ -113,10 +121,8 @@ module Datagrid
|
|
113
121
|
def format_date_as_timestamp(value)
|
114
122
|
if !value
|
115
123
|
value
|
116
|
-
elsif value.is_a?(Array)
|
117
|
-
[value.first&.beginning_of_day, value.last&.end_of_day]
|
118
124
|
elsif value.is_a?(Range)
|
119
|
-
|
125
|
+
value.begin&.beginning_of_day..value.end&.end_of_day
|
120
126
|
else
|
121
127
|
value.beginning_of_day..value.end_of_day
|
122
128
|
end
|
@@ -132,6 +138,7 @@ module Datagrid
|
|
132
138
|
end
|
133
139
|
|
134
140
|
protected
|
141
|
+
|
135
142
|
def property_availability(grid, option, default)
|
136
143
|
case option
|
137
144
|
when nil
|
data/lib/datagrid/version.rb
CHANGED
data/lib/datagrid.rb
CHANGED
@@ -1,49 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "action_view"
|
2
4
|
require "datagrid/configuration"
|
5
|
+
require "datagrid/engine"
|
3
6
|
|
7
|
+
# @main README.md
|
4
8
|
module Datagrid
|
5
|
-
|
6
|
-
extend ActiveSupport::Autoload
|
7
|
-
|
8
|
-
autoload :Core
|
9
|
-
autoload :ActiveModel
|
10
|
-
autoload :Filters
|
11
|
-
autoload :Columns
|
12
|
-
autoload :ColumnNamesAttribute
|
13
|
-
autoload :Ordering
|
14
|
-
autoload :Configuration
|
15
|
-
|
16
|
-
autoload :Helper
|
17
|
-
ActionView::Base.send(:include, Datagrid::Helper)
|
18
|
-
|
19
|
-
autoload :FormBuilder
|
20
|
-
ActionView::Helpers::FormBuilder.send(:include, Datagrid::FormBuilder)
|
21
|
-
|
22
|
-
autoload :Renderer
|
23
|
-
|
24
|
-
autoload :Engine
|
25
|
-
|
26
9
|
# @!visibility private
|
27
10
|
def self.included(base)
|
11
|
+
Utils.warn_once("Including Datagrid is deprecated. Inherit Datagrid::Base instead.")
|
28
12
|
base.class_eval do
|
29
|
-
|
30
13
|
include ::Datagrid::Core
|
31
14
|
include ::Datagrid::ActiveModel
|
32
15
|
include ::Datagrid::Filters
|
33
16
|
include ::Datagrid::Columns
|
34
17
|
include ::Datagrid::ColumnNamesAttribute
|
35
18
|
include ::Datagrid::Ordering
|
36
|
-
|
37
19
|
end
|
38
20
|
end
|
39
21
|
|
22
|
+
def self.configuration
|
23
|
+
@configuration ||= Configuration.new
|
24
|
+
end
|
25
|
+
|
26
|
+
# Configure
|
27
|
+
def self.configure(&block)
|
28
|
+
block.call(configuration)
|
29
|
+
end
|
30
|
+
|
40
31
|
class ConfigurationError < StandardError; end
|
41
32
|
class ArgumentError < ::ArgumentError; end
|
42
33
|
class ColumnUnavailableError < StandardError; end
|
43
|
-
|
44
34
|
end
|
45
35
|
|
46
|
-
require "datagrid/
|
47
|
-
|
48
|
-
|
49
|
-
|
36
|
+
require "datagrid/base"
|
37
|
+
require "datagrid/generators/scaffold"
|
38
|
+
require "datagrid/generators/views"
|
39
|
+
I18n.load_path << File.expand_path("datagrid/locale/en.yml", __dir__)
|
data/templates/base.rb.erb
CHANGED
@@ -1,7 +1,4 @@
|
|
1
|
-
class
|
2
|
-
|
3
|
-
include Datagrid
|
4
|
-
|
1
|
+
class ApplicationGrid < Datagrid::Base
|
5
2
|
self.default_column_options = {
|
6
3
|
# Uncomment to disable the default order
|
7
4
|
# order: false,
|
@@ -42,4 +39,9 @@ class BaseGrid
|
|
42
39
|
end
|
43
40
|
end
|
44
41
|
|
42
|
+
# Uncomment to shorten URL query string for all grids.
|
43
|
+
# May cause collisions if multiple grids are used on the same page.
|
44
|
+
# def param_name
|
45
|
+
# 'grid'
|
46
|
+
# end
|
45
47
|
end
|
data/templates/grid.rb.erb
CHANGED
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:
|
4
|
+
version: 2.0.0.pre.alpha
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bogdan Gusiev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '7.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '7.0'
|
27
27
|
description: The library allows you to easily build datagrid aka data tables with
|
28
28
|
sortable columns and filters
|
29
29
|
email: agresso@gmail.com
|
@@ -31,12 +31,12 @@ executables: []
|
|
31
31
|
extensions: []
|
32
32
|
extra_rdoc_files:
|
33
33
|
- LICENSE.txt
|
34
|
-
-
|
34
|
+
- README.md
|
35
35
|
files:
|
36
36
|
- CHANGELOG.md
|
37
37
|
- LICENSE.txt
|
38
|
-
-
|
39
|
-
- app/assets/stylesheets/datagrid.
|
38
|
+
- README.md
|
39
|
+
- app/assets/stylesheets/datagrid.css
|
40
40
|
- app/views/datagrid/_enum_checkboxes.html.erb
|
41
41
|
- app/views/datagrid/_form.html.erb
|
42
42
|
- app/views/datagrid/_head.html.erb
|
@@ -47,11 +47,13 @@ files:
|
|
47
47
|
- datagrid.gemspec
|
48
48
|
- lib/datagrid.rb
|
49
49
|
- lib/datagrid/active_model.rb
|
50
|
+
- lib/datagrid/base.rb
|
50
51
|
- lib/datagrid/column_names_attribute.rb
|
51
52
|
- lib/datagrid/columns.rb
|
52
53
|
- lib/datagrid/columns/column.rb
|
53
54
|
- lib/datagrid/configuration.rb
|
54
55
|
- lib/datagrid/core.rb
|
56
|
+
- lib/datagrid/deprecated_object.rb
|
55
57
|
- lib/datagrid/drivers.rb
|
56
58
|
- lib/datagrid/drivers/abstract_driver.rb
|
57
59
|
- lib/datagrid/drivers/active_record.rb
|
@@ -63,7 +65,6 @@ files:
|
|
63
65
|
- lib/datagrid/filters.rb
|
64
66
|
- lib/datagrid/filters/base_filter.rb
|
65
67
|
- lib/datagrid/filters/boolean_filter.rb
|
66
|
-
- lib/datagrid/filters/composite_filters.rb
|
67
68
|
- lib/datagrid/filters/date_filter.rb
|
68
69
|
- lib/datagrid/filters/date_time_filter.rb
|
69
70
|
- lib/datagrid/filters/default_filter.rb
|
@@ -76,19 +77,16 @@ files:
|
|
76
77
|
- lib/datagrid/filters/select_options.rb
|
77
78
|
- lib/datagrid/filters/string_filter.rb
|
78
79
|
- lib/datagrid/form_builder.rb
|
80
|
+
- lib/datagrid/generators/scaffold.rb
|
81
|
+
- lib/datagrid/generators/views.rb
|
79
82
|
- lib/datagrid/helper.rb
|
80
83
|
- lib/datagrid/locale/en.yml
|
81
84
|
- lib/datagrid/ordering.rb
|
82
|
-
- lib/datagrid/renderer.rb
|
83
85
|
- lib/datagrid/rspec.rb
|
84
|
-
- lib/datagrid/scaffold.rb
|
85
86
|
- lib/datagrid/utils.rb
|
86
87
|
- lib/datagrid/version.rb
|
87
|
-
- lib/tasks/datagrid_tasks.rake
|
88
88
|
- templates/base.rb.erb
|
89
|
-
- templates/controller.rb.erb
|
90
89
|
- templates/grid.rb.erb
|
91
|
-
- templates/index.html.erb
|
92
90
|
homepage: https://github.com/bogdan/datagrid
|
93
91
|
licenses:
|
94
92
|
- MIT
|
@@ -96,8 +94,9 @@ metadata:
|
|
96
94
|
homepage_uri: https://github.com/bogdan/datagrid
|
97
95
|
bug_tracker_uri: https://github.com/bogdan/datagrid/issues
|
98
96
|
documentation_uri: https://github.com/bogdan/datagrid/wiki
|
99
|
-
changelog_uri: https://github.com/bogdan/datagrid/blob/
|
97
|
+
changelog_uri: https://github.com/bogdan/datagrid/blob/main/CHANGELOG.md
|
100
98
|
source_code_uri: https://github.com/bogdan/datagrid
|
99
|
+
rubygems_mfa_required: 'true'
|
101
100
|
post_install_message:
|
102
101
|
rdoc_options: []
|
103
102
|
require_paths:
|
@@ -106,14 +105,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
106
105
|
requirements:
|
107
106
|
- - ">="
|
108
107
|
- !ruby/object:Gem::Version
|
109
|
-
version: '
|
108
|
+
version: '3.0'
|
110
109
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
110
|
requirements:
|
112
111
|
- - ">="
|
113
112
|
- !ruby/object:Gem::Version
|
114
113
|
version: '0'
|
115
114
|
requirements: []
|
116
|
-
rubygems_version: 3.
|
115
|
+
rubygems_version: 3.5.11
|
117
116
|
signing_key:
|
118
117
|
specification_version: 4
|
119
118
|
summary: Library that provides DSL to present table like data
|
@@ -1,134 +0,0 @@
|
|
1
|
-
$dg-form-label: 150px
|
2
|
-
|
3
|
-
= clearfix
|
4
|
-
*zoom: 1
|
5
|
-
|
6
|
-
&:before,
|
7
|
-
&:after
|
8
|
-
display: table
|
9
|
-
content: ''
|
10
|
-
|
11
|
-
&:after
|
12
|
-
clear: both
|
13
|
-
|
14
|
-
=inline-block
|
15
|
-
display: inline-block
|
16
|
-
zoom: 1
|
17
|
-
*display: inline
|
18
|
-
|
19
|
-
table.datagrid
|
20
|
-
background-color: transparent
|
21
|
-
border-collapse: collapse
|
22
|
-
max-width: 100%
|
23
|
-
|
24
|
-
th
|
25
|
-
background-color: #eee
|
26
|
-
text-align: left
|
27
|
-
|
28
|
-
td,
|
29
|
-
th
|
30
|
-
border: 1px solid #d6d6d6
|
31
|
-
padding: 5px 10px
|
32
|
-
|
33
|
-
.order
|
34
|
-
a.asc, a.desc
|
35
|
-
text-decoration: none
|
36
|
-
font-weight: normal
|
37
|
-
|
38
|
-
&.ordered
|
39
|
-
background-color: #fff7d5
|
40
|
-
|
41
|
-
&.asc
|
42
|
-
a.asc
|
43
|
-
font-weight: bold
|
44
|
-
color: #d00
|
45
|
-
|
46
|
-
&.desc
|
47
|
-
a.desc
|
48
|
-
font-weight: bold
|
49
|
-
color: #d00
|
50
|
-
.noresults
|
51
|
-
text-align: center
|
52
|
-
|
53
|
-
.datagrid-form
|
54
|
-
background-color: #f0f0f0
|
55
|
-
border-radius: 5px
|
56
|
-
padding: 20px
|
57
|
-
|
58
|
-
.datagrid-filter
|
59
|
-
margin: 10px
|
60
|
-
+clearfix
|
61
|
-
|
62
|
-
label
|
63
|
-
width: $dg-form-label
|
64
|
-
float: left
|
65
|
-
a
|
66
|
-
float: left
|
67
|
-
|
68
|
-
input[class*='filter']
|
69
|
-
border: 2px solid #ccc
|
70
|
-
border-radius: 4px
|
71
|
-
float: left
|
72
|
-
padding: 5px 12px
|
73
|
-
width: 207px
|
74
|
-
|
75
|
-
&.from, &.to
|
76
|
-
width: 83px
|
77
|
-
|
78
|
-
select
|
79
|
-
float: left
|
80
|
-
width: 235px
|
81
|
-
|
82
|
-
&[multiple]
|
83
|
-
border: 2px solid #ccc
|
84
|
-
border-radius: 5px
|
85
|
-
height: 100px
|
86
|
-
&.dynamic_filter
|
87
|
-
&.field
|
88
|
-
width: 178px
|
89
|
-
&.operation
|
90
|
-
margin-left: 7px
|
91
|
-
width: 50px
|
92
|
-
input.dynamic_filter.value
|
93
|
-
margin: 10px 0 0 $dg-form-label
|
94
|
-
clear: both
|
95
|
-
|
96
|
-
.separator
|
97
|
-
float: left
|
98
|
-
margin: 6px 4px 0
|
99
|
-
.enum_filter.checkboxes
|
100
|
-
float: none
|
101
|
-
display: block
|
102
|
-
input
|
103
|
-
margin: 7px
|
104
|
-
margin-left: 150px
|
105
|
-
|
106
|
-
|
107
|
-
.datagrid-actions
|
108
|
-
padding-left: $dg-form-label + 10
|
109
|
-
|
110
|
-
input[type='submit']
|
111
|
-
background-color: #555
|
112
|
-
border: none
|
113
|
-
border-radius: 5px
|
114
|
-
color: white
|
115
|
-
cursor: pointer
|
116
|
-
font-size: 14px
|
117
|
-
font-weight: bold
|
118
|
-
line-height: normal
|
119
|
-
padding: 7px 15px
|
120
|
-
vertical-align: middle
|
121
|
-
+inline-block
|
122
|
-
|
123
|
-
&:hover,
|
124
|
-
&:focus
|
125
|
-
background-color: #333
|
126
|
-
|
127
|
-
&:active
|
128
|
-
background-color: #000
|
129
|
-
|
130
|
-
> a
|
131
|
-
font-size: 14px
|
132
|
-
padding: 7px 15px
|
133
|
-
vertical-align: middle
|
134
|
-
+inline-block
|
@@ -1,49 +0,0 @@
|
|
1
|
-
module Datagrid
|
2
|
-
module Filters
|
3
|
-
# @!visibility private
|
4
|
-
module CompositeFilters
|
5
|
-
|
6
|
-
def self.included(base)
|
7
|
-
base.extend ClassMethods
|
8
|
-
base.class_eval do
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
# @!visibility private
|
13
|
-
module ClassMethods
|
14
|
-
|
15
|
-
def date_range_filters(field, from_options = {}, to_options = {})
|
16
|
-
Utils.warn_once('date_range_filters is deprecated in favor of range option for date filter')
|
17
|
-
from_options = normalize_composite_filter_options(from_options, field)
|
18
|
-
to_options = normalize_composite_filter_options(to_options, field)
|
19
|
-
|
20
|
-
filter(from_options[:name] || :"from_#{field.to_s.tr('.', '_')}", :date, **from_options) do |date, scope, grid|
|
21
|
-
grid.driver.greater_equal(scope, field, date)
|
22
|
-
end
|
23
|
-
filter(to_options[:name] || :"to_#{field.to_s.tr('.', '_')}", :date, **to_options) do |date, scope, grid|
|
24
|
-
grid.driver.less_equal(scope, field, date)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def integer_range_filters(field, from_options = {}, to_options = {})
|
29
|
-
Utils.warn_once('integer_range_filters is deprecated in favor of range option for integer filter')
|
30
|
-
from_options = normalize_composite_filter_options(from_options, field)
|
31
|
-
to_options = normalize_composite_filter_options(to_options, field)
|
32
|
-
filter(from_options[:name] || :"from_#{field.to_s.tr('.', '_')}", :integer, **from_options) do |value, scope, grid|
|
33
|
-
grid.driver.greater_equal(scope, field, value)
|
34
|
-
end
|
35
|
-
filter(to_options[:name] || :"to_#{field.to_s.tr('.', '_')}", :integer, **to_options) do |value, scope, grid|
|
36
|
-
grid.driver.less_equal(scope, field, value)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def normalize_composite_filter_options(options, field)
|
41
|
-
if options.is_a?(String) || options.is_a?(Symbol)
|
42
|
-
options = {name: options}
|
43
|
-
end
|
44
|
-
options
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|