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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7465e38f859d0397ee8ad0eed777e2a2b661b2e0a3d4b7952f4ebb9d7c69a610
4
- data.tar.gz: 5a8e76b9f9b291096e01f0cda446c10cb49cdbfc65ccd47ef1b5c490d815a039
3
+ metadata.gz: f0ba364a74ea76311ca1e2772cef86408871a3756499e82793fa63a4f8b95da3
4
+ data.tar.gz: fe1b250ade931bf258446c94ec756ef969a75d536d89a35f2e5375e6f6bedb7d
5
5
  SHA512:
6
- metadata.gz: 571dc4f5dbe9f349c43946354e45658e4e2958d972169fffbe0be804bbaeef5e1be8eda93541b82b0712e4cdc0ad82c927ba3c4327b51e3b01cda3ae8f0d2173
7
- data.tar.gz: 5666920239c588d56c687a2f599d8a4db97e8ff17a47d597138f0b624d996005dc2844f1dbdbede19ca2d10063fb1e1e32b55ff4a6c20c595778465ec211cef2
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.10)
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.0.1)
13
- actionview (= 6.0.1)
14
- activesupport (= 6.0.1)
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.0.1)
20
- activesupport (= 6.0.1)
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.0.1)
26
- activesupport (= 6.0.1)
27
- activerecord (6.0.1)
28
- activemodel (= 6.0.1)
29
- activesupport (= 6.0.1)
30
- activesupport (6.0.1)
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 (>= 0.7, < 2)
33
- minitest (~> 5.1)
34
- tzinfo (~> 1.1)
35
- zeitwerk (~> 2.2)
36
- bootstrap-datepicker-rails (1.8.0.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.2.3)
40
- concurrent-ruby (1.1.5)
41
- crass (1.0.5)
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.9.0)
44
- i18n (1.7.0)
43
+ erubi (1.13.0)
44
+ i18n (1.14.6)
45
45
  concurrent-ruby (~> 1.0)
46
- kaminari (1.1.1)
46
+ kaminari (1.2.2)
47
47
  activesupport (>= 4.1.0)
48
- kaminari-actionview (= 1.1.1)
49
- kaminari-activerecord (= 1.1.1)
50
- kaminari-core (= 1.1.1)
51
- kaminari-actionview (1.1.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.1.1)
54
- kaminari-activerecord (1.1.1)
53
+ kaminari-core (= 1.2.2)
54
+ kaminari-activerecord (1.2.2)
55
55
  activerecord
56
- kaminari-core (= 1.1.1)
57
- kaminari-core (1.1.1)
58
- loofah (2.3.1)
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.5.9)
61
- method_source (0.9.2)
62
- mini_portile2 (2.4.0)
63
- minitest (5.13.0)
64
- nokogiri (1.10.5)
65
- mini_portile2 (~> 2.4.0)
66
- rack (2.0.7)
67
- rack-test (1.1.0)
68
- rack (>= 1.0, < 3)
69
- rails-dom-testing (2.0.3)
70
- activesupport (>= 4.2.0)
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.3.0)
73
- loofah (~> 2.3)
74
- railties (6.0.1)
75
- actionpack (= 6.0.1)
76
- activesupport (= 6.0.1)
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.8.7)
79
- thor (>= 0.20.3, < 2.0)
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 (0.20.3)
95
- thread_safe (0.3.6)
96
- tzinfo (1.2.5)
97
- thread_safe (~> 0.1)
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(OBJECTS_PER_PAGE)
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(OBJECTS_PER_PAGE)
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[:download_value_lambda].present? }.each { |_c, v| (v[:download_label].present? ? titles.push(*v[:download_label]) : titles << v[:label]) }
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[:download_value_lambda].present? }.each do |_c, v|
110
- vals.push(*v[:download_value_lambda].call(o))
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 / OBJECTS_PER_PAGE + 1 : params[:page]
239
+ index ? index / limit + 1 : params[:page]
232
240
  end
233
241
  end
234
242
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TableOnSteroids
4
- VERSION = '0.1.1.12'
4
+ VERSION = '0.1.1.14'
5
5
  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.12
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: 2020-02-04 00:00:00.000000000 Z
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.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: []