table_on_steroids 0.1.1.12 → 0.1.1.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7465e38f859d0397ee8ad0eed777e2a2b661b2e0a3d4b7952f4ebb9d7c69a610
4
- data.tar.gz: 5a8e76b9f9b291096e01f0cda446c10cb49cdbfc65ccd47ef1b5c490d815a039
3
+ metadata.gz: 2f24d4f105e27626f6ac9038284f6ddff75784239fd7004fa5146cbb57c0c134
4
+ data.tar.gz: e1b9627cf54ffc485856845972d776b2614663a21cd812cf7c8030a8a510ee03
5
5
  SHA512:
6
- metadata.gz: 571dc4f5dbe9f349c43946354e45658e4e2958d972169fffbe0be804bbaeef5e1be8eda93541b82b0712e4cdc0ad82c927ba3c4327b51e3b01cda3ae8f0d2173
7
- data.tar.gz: 5666920239c588d56c687a2f599d8a4db97e8ff17a47d597138f0b624d996005dc2844f1dbdbede19ca2d10063fb1e1e32b55ff4a6c20c595778465ec211cef2
6
+ metadata.gz: 3f506dea75e687c7240cdb61d10806a504cca35f311ce1213e6c51b514ac259024ecd644e9a1120c10d167755c6c470e16c9021ddb8bb00d7973ebd09dc77835
7
+ data.tar.gz: 5fb0e6809e49d51a9cce6a65cc8c4d5f8fddd38558b510e0feb0f03029197e1f6f286f6ee02479b735c318f45ea2cc9931b72580a63e25a49c4756a3b752caa2
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,10 @@ 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
+
44
+ limit = rows_to_display || OBJECTS_PER_PAGE
45
+
43
46
  # execute the global search if you have one
44
47
  if params[:search].present?
45
48
  objects = global_search.call(objects, params[:search]) if global_search
@@ -85,14 +88,14 @@ module TableOnSteroids
85
88
  return (include_counts ? [objects, 1, objects.count] : objects) if all_pages
86
89
 
87
90
  # GO to specific object page
88
- page = get_page(objects, params, table_on_steroids)
91
+ page = get_page(objects, params, table_on_steroids, limit)
89
92
 
90
93
  if objects.is_a?(ActiveRecord::Base) || objects.is_a?(ActiveRecord::Relation)
91
- objects = objects.page(page).per(OBJECTS_PER_PAGE)
94
+ objects = objects.page(page).per(limit)
92
95
  total_pages = objects.total_pages
93
96
  total_count = objects.total_count
94
97
  else
95
- objects = Kaminari.paginate_array(objects).page(page).per(OBJECTS_PER_PAGE)
98
+ objects = Kaminari.paginate_array(objects).page(page).per(limit)
96
99
  total_pages = objects.total_pages
97
100
  total_count = objects.total_count
98
101
  end
@@ -219,7 +222,7 @@ module TableOnSteroids
219
222
  objects
220
223
  end
221
224
 
222
- def get_page(objects, params, table_on_steroids)
225
+ def get_page(objects, params, table_on_steroids, limit)
223
226
  active_record_object_fetch_opts = table_on_steroids&.dig(:active_record_object_fetch_opts)
224
227
  key_lambda = table_on_steroids&.dig(:key_lambda)
225
228
  return params[:page] unless active_record_object_fetch_opts && key_lambda
@@ -228,7 +231,7 @@ module TableOnSteroids
228
231
  return params[:page] unless object
229
232
 
230
233
  index = objects.index { |o| key_lambda.call(o) == key_lambda.call(object) }
231
- index ? index / OBJECTS_PER_PAGE + 1 : params[:page]
234
+ index ? index / limit + 1 : params[:page]
232
235
  end
233
236
  end
234
237
  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.13'
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.13
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-06-13 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:
154
+ rubyforge_project:
155
155
  rubygems_version: 2.7.7
156
- signing_key:
156
+ signing_key:
157
157
  specification_version: 4
158
158
  summary: Create awesome tables for rails
159
159
  test_files: []