tabulatr2 0.9.31 → 0.9.32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/tabulatr/_events.js +1 -1
- data/lib/tabulatr/data/data.rb +3 -2
- data/lib/tabulatr/data/filtering.rb +6 -5
- data/lib/tabulatr/data/sorting.rb +2 -0
- data/lib/tabulatr/rails/action_controller.rb +3 -3
- data/lib/tabulatr/version.rb +1 -1
- data/tabulatr.gemspec +4 -4
- metadata +11 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8925e114b7d2dc500bb27471320b8c81ad86773c
|
4
|
+
data.tar.gz: ca9a67f02bd9d69763d502fd9c5fd1ecaa321ae9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96a7faf7a4ad05a24433a3e67355775fa0340919c6d7a325bc82fea6a155c5514aeb0f7cbe4523506cb28a332b0cf2b1daecbf6ec867f0cbfb08c0f7c0795d16
|
7
|
+
data.tar.gz: 53c823ee7b120e983cd9281245b9b4118953c9aa595c0a4807e960c4b0014a655613abb6a170779e8e51598ba1a12bbdd9c2a13d2050ae68d5aab26670d5fce5
|
data/lib/tabulatr/data/data.rb
CHANGED
@@ -40,10 +40,11 @@ class Tabulatr::Data
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
def data_for_table(params, locals: {}, controller: nil, &block)
|
43
|
+
def data_for_table(params, locals: {}, default_order: nil, controller: nil, &block)
|
44
44
|
|
45
45
|
@batch_actions = block if block_given?
|
46
|
-
@controller
|
46
|
+
@controller = controller
|
47
|
+
@default_order = default_order
|
47
48
|
|
48
49
|
# count
|
49
50
|
total = @relation.count
|
@@ -43,7 +43,7 @@ module Tabulatr::Data::Filtering
|
|
43
43
|
|
44
44
|
def apply_filters(filter_params)
|
45
45
|
return unless filter_params
|
46
|
-
filter_params.each do |param|
|
46
|
+
filter_params.permit!.to_hash.with_indifferent_access.each do |param|
|
47
47
|
name, value = param
|
48
48
|
next unless value.present?
|
49
49
|
|
@@ -52,14 +52,15 @@ module Tabulatr::Data::Filtering
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def apply_condition(n,v)
|
55
|
+
# puts "FILTER: »#{n.filter.inspect}«, »#{n.filter.class}«"
|
55
56
|
case n.filter
|
56
57
|
when :checkbox then apply_boolean_condition(n, v)
|
57
58
|
when :decimal then apply_string_condition("#{n.col_options.filter_sql} = ?", v.to_f)
|
58
59
|
when :integer, :enum then apply_string_condition("#{n.col_options.filter_sql} = ?", v.to_i)
|
59
60
|
when :enum_multiselect then apply_array_condition(n, v)
|
60
61
|
when :exact, Hash, Array then apply_string_condition("#{n.col_options.filter_sql} = ?", v)
|
61
|
-
when :like then apply_like_condition(n, v[
|
62
|
-
when :date then apply_date_condition(n, v[
|
62
|
+
when :like then apply_like_condition(n, v['like'])
|
63
|
+
when :date then apply_date_condition(n, v['date'])
|
63
64
|
when :range then apply_range_condition(n, v)
|
64
65
|
when :custom then apply_custom_filter(n, v)
|
65
66
|
else raise "Wrong filter type for #{n.name}: #{n.filter}"
|
@@ -73,7 +74,7 @@ module Tabulatr::Data::Filtering
|
|
73
74
|
def apply_date_condition(n, cond)
|
74
75
|
today = Date.today
|
75
76
|
yesterday = today - 1.day
|
76
|
-
case cond[
|
77
|
+
case cond['simple']
|
77
78
|
when 'none' then return
|
78
79
|
when 'today' then date_in_between(today, today.at_end_of_day, n)
|
79
80
|
when 'yesterday' then date_in_between(yesterday, yesterday.at_end_of_day, n)
|
@@ -83,7 +84,7 @@ module Tabulatr::Data::Filtering
|
|
83
84
|
when 'this_month' then date_in_between(today.at_beginning_of_month.beginning_of_day,
|
84
85
|
today.at_end_of_month.end_of_day, n)
|
85
86
|
when 'last_30_days' then date_in_between((today - 29.day).beginning_of_day, today.at_end_of_day, n)
|
86
|
-
when 'from_to' then date_in_between((Date.parse(cond[
|
87
|
+
when 'from_to' then date_in_between((Date.parse(cond['from']) rescue nil), (Date.parse(cond['to']) rescue nil), n)
|
87
88
|
end
|
88
89
|
end
|
89
90
|
|
@@ -40,6 +40,8 @@ module Tabulatr::Data::Sorting
|
|
40
40
|
column = table_columns.find{|c| c.name == name}
|
41
41
|
end
|
42
42
|
sort_by(column, orientation)
|
43
|
+
elsif @default_order.present?
|
44
|
+
@relation = @relation.reorder(@default_order)
|
43
45
|
else
|
44
46
|
@relation = @relation.reorder("#{@table_name}.#{@base.primary_key} desc")
|
45
47
|
end
|
@@ -22,16 +22,16 @@
|
|
22
22
|
#++
|
23
23
|
|
24
24
|
class ActionController::Base
|
25
|
-
|
25
|
+
before_action do
|
26
26
|
@_tabulatr_table_index = 0
|
27
27
|
end
|
28
28
|
|
29
|
-
def tabulatr_for(relation, tabulatr_data_class: nil, serializer: nil, render_action: nil, locals: {}, &block)
|
29
|
+
def tabulatr_for(relation, tabulatr_data_class: nil, serializer: nil, render_action: nil, default_order: nil, locals: {}, &block)
|
30
30
|
klass = relation.respond_to?(:klass) ? relation.klass : relation
|
31
31
|
respond_to do |format|
|
32
32
|
format.json {
|
33
33
|
locals[:current_user] ||= current_user if respond_to?(:current_user)
|
34
|
-
records = klass.tabulatr(relation, tabulatr_data_class).data_for_table(params, locals: locals, controller: self, &block)
|
34
|
+
records = klass.tabulatr(relation, tabulatr_data_class).data_for_table(params, locals: locals, controller: self, default_order: default_order, &block)
|
35
35
|
render json: records.to_tabulatr_json(serializer)
|
36
36
|
records
|
37
37
|
}
|
data/lib/tabulatr/version.rb
CHANGED
data/tabulatr.gemspec
CHANGED
@@ -23,10 +23,10 @@ Gem::Specification.new do |s|
|
|
23
23
|
s.rdoc_options = ['--charset=UTF-8']
|
24
24
|
|
25
25
|
|
26
|
-
s.add_runtime_dependency('rails', '
|
26
|
+
s.add_runtime_dependency('rails', '> 4.0')
|
27
27
|
s.add_dependency('slim', '>= 2.0')
|
28
|
-
s.add_dependency('tilt', '
|
28
|
+
s.add_dependency('tilt', '> 1.4')
|
29
29
|
s.add_dependency('font-awesome-rails', '>= 4.0')
|
30
|
-
s.add_development_dependency('rspec-rails', '
|
31
|
-
s.add_development_dependency('capybara', '
|
30
|
+
s.add_development_dependency('rspec-rails', '>= 3.1.0')
|
31
|
+
s.add_development_dependency('capybara', '>= 2.4.1')
|
32
32
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tabulatr2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.32
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Horn
|
@@ -10,20 +10,20 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2017-
|
13
|
+
date: 2017-10-26 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
requirements:
|
19
|
-
- - "
|
19
|
+
- - ">"
|
20
20
|
- !ruby/object:Gem::Version
|
21
21
|
version: '4.0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
|
-
- - "
|
26
|
+
- - ">"
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
version: '4.0'
|
29
29
|
- !ruby/object:Gem::Dependency
|
@@ -44,22 +44,16 @@ dependencies:
|
|
44
44
|
name: tilt
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
|
-
- - "
|
47
|
+
- - ">"
|
48
48
|
- !ruby/object:Gem::Version
|
49
49
|
version: '1.4'
|
50
|
-
- - ">="
|
51
|
-
- !ruby/object:Gem::Version
|
52
|
-
version: 1.4.1
|
53
50
|
type: :runtime
|
54
51
|
prerelease: false
|
55
52
|
version_requirements: !ruby/object:Gem::Requirement
|
56
53
|
requirements:
|
57
|
-
- - "
|
54
|
+
- - ">"
|
58
55
|
- !ruby/object:Gem::Version
|
59
56
|
version: '1.4'
|
60
|
-
- - ">="
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
version: 1.4.1
|
63
57
|
- !ruby/object:Gem::Dependency
|
64
58
|
name: font-awesome-rails
|
65
59
|
requirement: !ruby/object:Gem::Requirement
|
@@ -78,28 +72,28 @@ dependencies:
|
|
78
72
|
name: rspec-rails
|
79
73
|
requirement: !ruby/object:Gem::Requirement
|
80
74
|
requirements:
|
81
|
-
- - "
|
75
|
+
- - ">="
|
82
76
|
- !ruby/object:Gem::Version
|
83
77
|
version: 3.1.0
|
84
78
|
type: :development
|
85
79
|
prerelease: false
|
86
80
|
version_requirements: !ruby/object:Gem::Requirement
|
87
81
|
requirements:
|
88
|
-
- - "
|
82
|
+
- - ">="
|
89
83
|
- !ruby/object:Gem::Version
|
90
84
|
version: 3.1.0
|
91
85
|
- !ruby/object:Gem::Dependency
|
92
86
|
name: capybara
|
93
87
|
requirement: !ruby/object:Gem::Requirement
|
94
88
|
requirements:
|
95
|
-
- - "
|
89
|
+
- - ">="
|
96
90
|
- !ruby/object:Gem::Version
|
97
91
|
version: 2.4.1
|
98
92
|
type: :development
|
99
93
|
prerelease: false
|
100
94
|
version_requirements: !ruby/object:Gem::Requirement
|
101
95
|
requirements:
|
102
|
-
- - "
|
96
|
+
- - ">="
|
103
97
|
- !ruby/object:Gem::Version
|
104
98
|
version: 2.4.1
|
105
99
|
description: A tight DSL to build tables of ActiveRecord models with sorting, pagination,
|
@@ -281,7 +275,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
281
275
|
version: '0'
|
282
276
|
requirements: []
|
283
277
|
rubyforge_project:
|
284
|
-
rubygems_version: 2.6.
|
278
|
+
rubygems_version: 2.6.13
|
285
279
|
signing_key:
|
286
280
|
specification_version: 4
|
287
281
|
summary: A tight DSL to build tables of ActiveRecord models with sorting, pagination,
|