table_on_steroids 0.1.1.12 → 0.1.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +58 -56
- data/README.md +8 -0
- data/app/controllers/concerns/table_on_steroids/table_concern.rb +18 -10
- data/lib/table_on_steroids/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0ba364a74ea76311ca1e2772cef86408871a3756499e82793fa63a4f8b95da3
|
4
|
+
data.tar.gz: fe1b250ade931bf258446c94ec756ef969a75d536d89a35f2e5375e6f6bedb7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be347b11343d1cd0860755b40021a2361c1ea80796a5f43ee3f1483ada2fe832dd1389bb350e7bdb5f70e6d92eaece218becfc54b02fc6086531f3db146c93c7
|
7
|
+
data.tar.gz: 2ee840fe5b762f283849597770f6d8a73c8b296095c684bc59adb17da884a05f60d15f472e4bf2248616e137ab7980a2ee1b551d03f2e456962fae17c0f80d3c
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
table_on_steroids (0.1.1.
|
4
|
+
table_on_steroids (0.1.1.14)
|
5
5
|
bootstrap-datepicker-rails (~> 1)
|
6
6
|
bootstrap-select-rails (~> 1.3)
|
7
7
|
kaminari (~> 1.1)
|
@@ -9,74 +9,77 @@ PATH
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
actionpack (6.
|
13
|
-
actionview (= 6.
|
14
|
-
activesupport (= 6.
|
15
|
-
rack (~> 2.0)
|
12
|
+
actionpack (6.1.4.7)
|
13
|
+
actionview (= 6.1.4.7)
|
14
|
+
activesupport (= 6.1.4.7)
|
15
|
+
rack (~> 2.0, >= 2.0.9)
|
16
16
|
rack-test (>= 0.6.3)
|
17
17
|
rails-dom-testing (~> 2.0)
|
18
18
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
19
|
-
actionview (6.
|
20
|
-
activesupport (= 6.
|
19
|
+
actionview (6.1.4.7)
|
20
|
+
activesupport (= 6.1.4.7)
|
21
21
|
builder (~> 3.1)
|
22
22
|
erubi (~> 1.4)
|
23
23
|
rails-dom-testing (~> 2.0)
|
24
24
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
25
|
-
activemodel (6.
|
26
|
-
activesupport (= 6.
|
27
|
-
activerecord (6.
|
28
|
-
activemodel (= 6.
|
29
|
-
activesupport (= 6.
|
30
|
-
activesupport (6.
|
25
|
+
activemodel (6.1.4.7)
|
26
|
+
activesupport (= 6.1.4.7)
|
27
|
+
activerecord (6.1.4.7)
|
28
|
+
activemodel (= 6.1.4.7)
|
29
|
+
activesupport (= 6.1.4.7)
|
30
|
+
activesupport (6.1.4.7)
|
31
31
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
32
|
-
i18n (>=
|
33
|
-
minitest (
|
34
|
-
tzinfo (~>
|
35
|
-
zeitwerk (~> 2.
|
36
|
-
bootstrap-datepicker-rails (1.
|
32
|
+
i18n (>= 1.6, < 2)
|
33
|
+
minitest (>= 5.1)
|
34
|
+
tzinfo (~> 2.0)
|
35
|
+
zeitwerk (~> 2.3)
|
36
|
+
bootstrap-datepicker-rails (1.10.0.1)
|
37
37
|
railties (>= 3.0)
|
38
38
|
bootstrap-select-rails (1.13.8)
|
39
|
-
builder (3.
|
40
|
-
concurrent-ruby (1.
|
41
|
-
crass (1.0.
|
39
|
+
builder (3.3.0)
|
40
|
+
concurrent-ruby (1.3.4)
|
41
|
+
crass (1.0.6)
|
42
42
|
diff-lcs (1.3)
|
43
|
-
erubi (1.
|
44
|
-
i18n (1.
|
43
|
+
erubi (1.13.0)
|
44
|
+
i18n (1.14.6)
|
45
45
|
concurrent-ruby (~> 1.0)
|
46
|
-
kaminari (1.
|
46
|
+
kaminari (1.2.2)
|
47
47
|
activesupport (>= 4.1.0)
|
48
|
-
kaminari-actionview (= 1.
|
49
|
-
kaminari-activerecord (= 1.
|
50
|
-
kaminari-core (= 1.
|
51
|
-
kaminari-actionview (1.
|
48
|
+
kaminari-actionview (= 1.2.2)
|
49
|
+
kaminari-activerecord (= 1.2.2)
|
50
|
+
kaminari-core (= 1.2.2)
|
51
|
+
kaminari-actionview (1.2.2)
|
52
52
|
actionview
|
53
|
-
kaminari-core (= 1.
|
54
|
-
kaminari-activerecord (1.
|
53
|
+
kaminari-core (= 1.2.2)
|
54
|
+
kaminari-activerecord (1.2.2)
|
55
55
|
activerecord
|
56
|
-
kaminari-core (= 1.
|
57
|
-
kaminari-core (1.
|
58
|
-
loofah (2.
|
56
|
+
kaminari-core (= 1.2.2)
|
57
|
+
kaminari-core (1.2.2)
|
58
|
+
loofah (2.22.0)
|
59
59
|
crass (~> 1.0.2)
|
60
|
-
nokogiri (>= 1.
|
61
|
-
method_source (
|
62
|
-
mini_portile2 (2.
|
63
|
-
minitest (5.
|
64
|
-
nokogiri (1.
|
65
|
-
mini_portile2 (~> 2.
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
60
|
+
nokogiri (>= 1.12.0)
|
61
|
+
method_source (1.1.0)
|
62
|
+
mini_portile2 (2.6.1)
|
63
|
+
minitest (5.15.0)
|
64
|
+
nokogiri (1.12.5)
|
65
|
+
mini_portile2 (~> 2.6.1)
|
66
|
+
racc (~> 1.4)
|
67
|
+
racc (1.8.1)
|
68
|
+
rack (2.2.9)
|
69
|
+
rack-test (2.1.0)
|
70
|
+
rack (>= 1.3)
|
71
|
+
rails-dom-testing (2.2.0)
|
72
|
+
activesupport (>= 5.0.0)
|
73
|
+
minitest
|
71
74
|
nokogiri (>= 1.6)
|
72
|
-
rails-html-sanitizer (1.
|
73
|
-
loofah (~> 2.
|
74
|
-
railties (6.
|
75
|
-
actionpack (= 6.
|
76
|
-
activesupport (= 6.
|
75
|
+
rails-html-sanitizer (1.5.0)
|
76
|
+
loofah (~> 2.19, >= 2.19.1)
|
77
|
+
railties (6.1.4.7)
|
78
|
+
actionpack (= 6.1.4.7)
|
79
|
+
activesupport (= 6.1.4.7)
|
77
80
|
method_source
|
78
|
-
rake (>= 0.
|
79
|
-
thor (
|
81
|
+
rake (>= 0.13)
|
82
|
+
thor (~> 1.0)
|
80
83
|
rake (10.5.0)
|
81
84
|
rspec (3.8.0)
|
82
85
|
rspec-core (~> 3.8.0)
|
@@ -91,11 +94,10 @@ GEM
|
|
91
94
|
diff-lcs (>= 1.2.0, < 2.0)
|
92
95
|
rspec-support (~> 3.8.0)
|
93
96
|
rspec-support (3.8.0)
|
94
|
-
thor (
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
zeitwerk (2.2.1)
|
97
|
+
thor (1.2.2)
|
98
|
+
tzinfo (2.0.6)
|
99
|
+
concurrent-ruby (~> 1.0)
|
100
|
+
zeitwerk (2.6.18)
|
99
101
|
|
100
102
|
PLATFORMS
|
101
103
|
ruby
|
data/README.md
CHANGED
@@ -123,6 +123,14 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
123
123
|
|
124
124
|
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/table_on_steroids. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
125
125
|
|
126
|
+
## Build and deploy a new version
|
127
|
+
|
128
|
+
1. Upgrade the version number
|
129
|
+
2. `gem build table_on_steroids` it will create a .gem file
|
130
|
+
3. `gem push table_on_steroids-[newversion].gem`
|
131
|
+
|
132
|
+
Adding an owner `gem owner --add {{email}} {{gem}}` (the person must have a https://rubygems.org/ account)
|
133
|
+
|
126
134
|
## License
|
127
135
|
|
128
136
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
@@ -39,7 +39,9 @@ module TableOnSteroids
|
|
39
39
|
OBJECTS_PER_PAGE = 50
|
40
40
|
end
|
41
41
|
|
42
|
-
def filter_and_order(objects, columns_on_steroid, global_search = nil, include_counts = false, all_pages = false, table_on_steroids = nil)
|
42
|
+
def filter_and_order(objects, columns_on_steroid, global_search = nil, include_counts = false, all_pages = false, table_on_steroids = nil, rows_to_display = nil)
|
43
|
+
limit = rows_to_display || OBJECTS_PER_PAGE
|
44
|
+
|
43
45
|
# execute the global search if you have one
|
44
46
|
if params[:search].present?
|
45
47
|
objects = global_search.call(objects, params[:search]) if global_search
|
@@ -85,29 +87,35 @@ module TableOnSteroids
|
|
85
87
|
return (include_counts ? [objects, 1, objects.count] : objects) if all_pages
|
86
88
|
|
87
89
|
# GO to specific object page
|
88
|
-
page = get_page(objects, params, table_on_steroids)
|
90
|
+
page = get_page(objects, params, table_on_steroids, limit)
|
89
91
|
|
90
92
|
if objects.is_a?(ActiveRecord::Base) || objects.is_a?(ActiveRecord::Relation)
|
91
|
-
objects = objects.page(page).per(
|
93
|
+
objects = objects.page(page).per(limit)
|
92
94
|
total_pages = objects.total_pages
|
93
95
|
total_count = objects.total_count
|
94
96
|
else
|
95
|
-
objects = Kaminari.paginate_array(objects).page(page).per(
|
97
|
+
objects = Kaminari.paginate_array(objects).page(page).per(limit)
|
96
98
|
total_pages = objects.total_pages
|
97
99
|
total_count = objects.total_count
|
98
100
|
end
|
99
101
|
include_counts ? [objects, total_pages, total_count, page] : objects
|
100
102
|
end
|
101
103
|
|
102
|
-
def table_csv(objects, columns_on_steroid)
|
104
|
+
def table_csv(objects, columns_on_steroid, client = false)
|
103
105
|
titles = []
|
106
|
+
value_lambda = :download_value_lambda
|
107
|
+
label = :download_label
|
108
|
+
if(client)
|
109
|
+
value_lambda = :client_download_value_lambda
|
110
|
+
label = :client_download_label
|
111
|
+
end
|
104
112
|
csvs = CSV.generate do |csv|
|
105
|
-
columns_on_steroid.select { |_c, v| v[
|
113
|
+
columns_on_steroid.select { |_c, v| v[value_lambda].present? }.each { |_c, v| (v[label].present? ? titles.push(*v[label]) : titles << v[:label]) }
|
106
114
|
csv << titles
|
107
115
|
objects.each do |o|
|
108
116
|
vals = []
|
109
|
-
columns_on_steroid.select { |_c, v| v[
|
110
|
-
vals.push(*v[
|
117
|
+
columns_on_steroid.select { |_c, v| v[value_lambda].present? }.each do |_c, v|
|
118
|
+
vals.push(*v[value_lambda].call(o))
|
111
119
|
end
|
112
120
|
csv << vals
|
113
121
|
end
|
@@ -219,7 +227,7 @@ module TableOnSteroids
|
|
219
227
|
objects
|
220
228
|
end
|
221
229
|
|
222
|
-
def get_page(objects, params, table_on_steroids)
|
230
|
+
def get_page(objects, params, table_on_steroids, limit)
|
223
231
|
active_record_object_fetch_opts = table_on_steroids&.dig(:active_record_object_fetch_opts)
|
224
232
|
key_lambda = table_on_steroids&.dig(:key_lambda)
|
225
233
|
return params[:page] unless active_record_object_fetch_opts && key_lambda
|
@@ -228,7 +236,7 @@ module TableOnSteroids
|
|
228
236
|
return params[:page] unless object
|
229
237
|
|
230
238
|
index = objects.index { |o| key_lambda.call(o) == key_lambda.call(object) }
|
231
|
-
index ? index /
|
239
|
+
index ? index / limit + 1 : params[:page]
|
232
240
|
end
|
233
241
|
end
|
234
242
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: table_on_steroids
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.1.
|
4
|
+
version: 0.1.1.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marieke Gueye
|
8
8
|
- Matt Hiatt
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2024-10-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bootstrap-datepicker-rails
|
@@ -136,7 +136,7 @@ homepage: http://www.github.com/mariekou
|
|
136
136
|
licenses:
|
137
137
|
- MIT
|
138
138
|
metadata: {}
|
139
|
-
post_install_message:
|
139
|
+
post_install_message:
|
140
140
|
rdoc_options: []
|
141
141
|
require_paths:
|
142
142
|
- lib
|
@@ -151,9 +151,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
153
|
requirements: []
|
154
|
-
rubyforge_project:
|
155
|
-
rubygems_version: 2.7.
|
156
|
-
signing_key:
|
154
|
+
rubyforge_project:
|
155
|
+
rubygems_version: 2.7.6.2
|
156
|
+
signing_key:
|
157
157
|
specification_version: 4
|
158
158
|
summary: Create awesome tables for rails
|
159
159
|
test_files: []
|