effective_resources 0.3.12 → 0.3.13

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
  SHA1:
3
- metadata.gz: e08db419b1fd1d98f096c728b8f2d9c63e344a93
4
- data.tar.gz: d25316c81e2d263d98a5f7f128387f641d3d6000
3
+ metadata.gz: eab2acea54c68e25f1d066485fb00763295982e8
4
+ data.tar.gz: beebb25a6052cbd33d9bfcb67bea42c8124c6a6e
5
5
  SHA512:
6
- metadata.gz: f3d0ed78a2b52b575d41221c862c40b048621215baaed5b439103e44e4df52ac0872700b5e1cbf705249bfa6ca9057e4a0faae450533527bce12e2a9a3ed64ea
7
- data.tar.gz: 3cf544d682c6433fb86fa0885b3aadb570bedbe741d40b428f5a6bccd134bb1fde982b7d121e2608ef307dc2ad9a01f0308d42278014ca8c068d290c63dc315b
6
+ metadata.gz: 173ea246c8e6dca6f05a31d0d0a715f9273682b04ce2d779a9e50c5aef12b6549193eda7cc36c0198642d68a5b3e6a66f86134fc4ae4d62df94cc0ae88fdb5e7
7
+ data.tar.gz: d987ab50595f08fc4465af85dfabdbf0f5cd971cf029b403a4792995c7625c4d179991404b613b0b54b8fbe18ef5439f40204f02bc33250e6cfda34606dfda1d
@@ -36,8 +36,9 @@ module Effective
36
36
  end
37
37
 
38
38
  # This is for EffectiveDatatables (col as:)
39
+ # Might be :name, or 'users.name'
39
40
  def sql_type(name)
40
- name = name.to_s
41
+ name = name.to_s.split('.').first
41
42
 
42
43
  if belongs_to_polymorphic(name)
43
44
  :belongs_to_polymorphic
@@ -66,7 +67,10 @@ module Effective
66
67
 
67
68
  # This tries to figure out the column we should order this collection by.
68
69
  # Whatever would match up with the .to_s
70
+ # Unless it's set from outside by datatables...
69
71
  def sort_column
72
+ return @_sort_column if @_sort_column
73
+
70
74
  ['name', 'title', 'label', 'subject', 'full_name', 'first_name', 'email', 'description'].each do |name|
71
75
  return name if column_names.include?(name)
72
76
  end
@@ -74,12 +78,24 @@ module Effective
74
78
  klass.primary_key
75
79
  end
76
80
 
81
+ def sort_column=(name)
82
+ raise "unknown sort column: #{name}" unless column_names.include?(name)
83
+ @_sort_column = name
84
+ end
85
+
77
86
  # Any string or text columns
78
87
  # TODO: filter out _type columns for polymorphic
79
88
  def search_columns
89
+ return @_search_columns if @_search_columns
80
90
  columns.map { |column| column.name if [:string, :text].include?(column.type) }.compact
81
91
  end
82
92
 
93
+ def search_columns=(name)
94
+ names = Array(name)
95
+ names.each { |name| raise "unknown search column: #{name}" unless column_names.include?(name) }
96
+ @_search_columns = names
97
+ end
98
+
83
99
  private
84
100
 
85
101
  def postgres?
@@ -1,3 +1,3 @@
1
1
  module EffectiveResources
2
- VERSION = '0.3.12'.freeze
2
+ VERSION = '0.3.13'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_resources
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.12
4
+ version: 0.3.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-07 00:00:00.000000000 Z
11
+ date: 2017-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails