effective_datatables 2.1.8 → 2.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/effective/active_record_datatable_tool.rb +8 -1
- data/app/models/effective/datatable.rb +1 -1
- data/app/models/effective/effective_datatable/options.rb +6 -2
- data/app/models/effective/effective_datatable/rendering.rb +7 -1
- data/lib/effective_datatables/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: cb5282c6fc8d0dfa572243a3d922182600bf611a
|
4
|
+
data.tar.gz: 2a176f9e34f0bc71180bb66f6b91699306e1ee7a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c32b379fe3f045efecf295350e5d2385802c60d8f2e95d293bfa6523ba938540fb8c110e39bb2c0f100ce59630f7ebbf2813c3f7a02231e3203f1bd7e9cd703c
|
7
|
+
data.tar.gz: 9fa36118ddc8e3427589f0f6a642b9305b5855cec61176885d77c97357ddd874d1d7fbd71c67d985d85f68fe474fb50dd6ef0635ef65f007eceebb46e7342402
|
@@ -2,7 +2,7 @@ module Effective
|
|
2
2
|
class ActiveRecordDatatableTool
|
3
3
|
attr_accessor :table_columns
|
4
4
|
|
5
|
-
delegate :order_name, :order_direction, :page, :per_page, :search_column, :to => :@datatable
|
5
|
+
delegate :order_name, :order_direction, :page, :per_page, :search_column, :collection_class, :to => :@datatable
|
6
6
|
|
7
7
|
def initialize(datatable, table_columns)
|
8
8
|
@datatable = datatable
|
@@ -82,6 +82,13 @@ module Effective
|
|
82
82
|
else
|
83
83
|
collection.public_send(sql_op, "#{column} = :term", term: deobfuscated_id)
|
84
84
|
end
|
85
|
+
when :effective_address
|
86
|
+
ids = Effective::Address
|
87
|
+
.where('addressable_type = ?', collection_class.name)
|
88
|
+
.where('address1 ILIKE :term OR address2 ILIKE :term OR city ILIKE :term OR postal_code ILIKE :term OR state_code = :code OR country_code = :code', term: "%#{term}%", code: term)
|
89
|
+
.pluck(:addressable_id)
|
90
|
+
|
91
|
+
collection.public_send(sql_op, id: ids)
|
85
92
|
when :effective_roles
|
86
93
|
collection.with_role(term)
|
87
94
|
when :datetime, :date
|
@@ -64,6 +64,8 @@ module Effective
|
|
64
64
|
end
|
65
65
|
elsif has_manys.key?(name)
|
66
66
|
:has_many
|
67
|
+
elsif name.include?('_address') && (collection_class.new rescue nil).respond_to?(:effective_addresses)
|
68
|
+
:effective_address
|
67
69
|
elsif sql_column.try(:type).present?
|
68
70
|
sql_column.type
|
69
71
|
else
|
@@ -73,8 +75,8 @@ module Effective
|
|
73
75
|
|
74
76
|
cols[name][:class] = "col-#{cols[name][:type]} col-#{name} #{cols[name][:class]}".strip
|
75
77
|
|
76
|
-
# We can't really sort a HasMany field
|
77
|
-
if cols[name][:type]
|
78
|
+
# We can't really sort a HasMany or EffectiveAddress field
|
79
|
+
if [:has_many, :effective_address].include?(cols[name][:type])
|
78
80
|
cols[name][:sortable] = false
|
79
81
|
end
|
80
82
|
|
@@ -157,6 +159,8 @@ module Effective
|
|
157
159
|
end
|
158
160
|
)
|
159
161
|
}
|
162
|
+
when :effective_address
|
163
|
+
{type: :string}
|
160
164
|
when :effective_roles
|
161
165
|
{type: :select, values: EffectiveRoles.roles}
|
162
166
|
when :integer
|
@@ -121,8 +121,10 @@ module Effective
|
|
121
121
|
(obj.send(name).to_a rescue [])
|
122
122
|
elsif opts[:type] == :obfuscated_id
|
123
123
|
(obj.send(:to_param) rescue nil).to_s
|
124
|
+
elsif opts[:type] == :effective_address
|
125
|
+
(Array(obj.send(name)) rescue [])
|
124
126
|
elsif opts[:type] == :effective_roles
|
125
|
-
(obj.send(:roles) rescue [])
|
127
|
+
(obj.send(:roles) rescue [])
|
126
128
|
elsif obj.kind_of?(Array) # Array backed collection
|
127
129
|
obj[opts[:array_index]]
|
128
130
|
else
|
@@ -154,6 +156,10 @@ module Effective
|
|
154
156
|
row[index] = value.map { |v| v.to_s }.join('<br>')
|
155
157
|
end
|
156
158
|
end
|
159
|
+
when :effective_address
|
160
|
+
row[index] = value.map { |addr| addr.to_html }.join('<br>')
|
161
|
+
when :effective_roles
|
162
|
+
row[index] = value.join(', ')
|
157
163
|
when :datetime
|
158
164
|
row[index] = value.strftime(EffectiveDatatables.datetime_format) rescue BLANK
|
159
165
|
when :date
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_datatables
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.9
|
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: 2015-09-
|
11
|
+
date: 2015-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|