grid_table 1.6.1 → 1.6.2
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/lib/grid_table/controller.rb +1 -1
- data/lib/grid_table/table.rb +8 -4
- data/lib/grid_table/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ebb97df01dafa004b68c62d795004287b6a73b46
|
4
|
+
data.tar.gz: 027df09f8b0bd79d1ab4df792735dc4305b564fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d6636c0685cc9e98edc4067e30eea3ef0358f0c5fed81faa6c958a20ea5f0d6d1902124db5218613a4d14c15af7450d90ebc33a929d67ceeb807ffd08e50027
|
7
|
+
data.tar.gz: 266d25532cfba73371d79b5709b56c01aabf04084b4cbe85e5c9b576e0627cdb6c71a51e506f22660988b789fc4ed506be012859e6f9798073e4c3f91ec5ea61
|
@@ -2,7 +2,7 @@ module GridTable
|
|
2
2
|
module Controller
|
3
3
|
def grid_table_for(resource, params, options = {})
|
4
4
|
grid_table = resource.grid_table
|
5
|
-
grid_table.populate!(resource, params)
|
5
|
+
grid_table.populate!(resource, params, options)
|
6
6
|
|
7
7
|
if block_given?
|
8
8
|
yield grid_table.records, grid_table.total_rows
|
data/lib/grid_table/table.rb
CHANGED
@@ -18,14 +18,15 @@ class GridTable::Table
|
|
18
18
|
)
|
19
19
|
end
|
20
20
|
|
21
|
-
def populate!(resource, params)
|
21
|
+
def populate!(resource, params, options)
|
22
22
|
# In Rails 5 ActionController::Parameters returns an object rather than a hash
|
23
23
|
# It provides the to_h method in order to return a hash (with indifferent access) of safe parameters
|
24
24
|
# Rails 4 and below returns a regular hash so we need to account for that
|
25
25
|
@params = params.to_h.with_indifferent_access
|
26
26
|
@records = resource
|
27
|
+
aggregate = options[:aggregate] || false
|
27
28
|
|
28
|
-
select
|
29
|
+
select(aggregate: aggregate)
|
29
30
|
filter! unless params[:skip_filtering]
|
30
31
|
@total_rows = @records.length
|
31
32
|
sort! unless params[:skip_sorting]
|
@@ -62,8 +63,11 @@ class GridTable::Table
|
|
62
63
|
end
|
63
64
|
end
|
64
65
|
|
65
|
-
def select
|
66
|
-
|
66
|
+
def select(aggregate: false)
|
67
|
+
select_fields = @controls.map(&:select)
|
68
|
+
select_fields.push('*') unless aggregate
|
69
|
+
|
70
|
+
@records = @records.select(select_fields.join(','))
|
67
71
|
end
|
68
72
|
|
69
73
|
def sort!
|
data/lib/grid_table/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grid_table
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Principe
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-10-
|
12
|
+
date: 2017-10-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|