grid_table 1.6.1 → 1.6.2

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
  SHA1:
3
- metadata.gz: c843eeb9f6d384ec2eb913cfb9905bab4f76d8cd
4
- data.tar.gz: ad7315974f039626839507cf7eab48d2a1f205b9
3
+ metadata.gz: ebb97df01dafa004b68c62d795004287b6a73b46
4
+ data.tar.gz: 027df09f8b0bd79d1ab4df792735dc4305b564fc
5
5
  SHA512:
6
- metadata.gz: 3953b34a9f7593239d3aa0f0751f87345d86dafd652d7025d3b6d1049d2b853688d623175c9a24aabc2752022abe4b47e751dadee63213951aed2c13101b25ce
7
- data.tar.gz: f476cb6291674788a343582b9ab4db413e1a3dbe42ce95637e839c613210b038f8d9e820e9346021f8a648d1bf37421be76cec6479cda9c366721bbdd88833ad
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
@@ -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
- @records = @records.select(@controls.map(&:select).push('*').join(','))
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!
@@ -1,3 +1,3 @@
1
1
  module GridTable
2
- VERSION = '1.6.1'.freeze
2
+ VERSION = '1.6.2'.freeze
3
3
  end
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.1
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-16 00:00:00.000000000 Z
12
+ date: 2017-10-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler