five-two-nw-olivander 0.1.2.10 → 0.1.2.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/datatables/olivander/datatable.rb +12 -6
- data/lib/olivander/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95371b71e1db9de5a935b1ecf9834a1b802a5a71c8960bd876a0c6e22ed849e5
|
4
|
+
data.tar.gz: f336a7acda0c1918f4a4a7d0dfdd672e4bdf6d68464172046b49539a27b573ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6eaa2e44f71c887a9879f76a8516c509b27579ae6e5597fcccdca9f92947ef6ecf14b18a0386e19f6cb04732c7ad05b19b5d1f65464937e56deb7b3037f42967
|
7
|
+
data.tar.gz: a5123ae21498c52619c763866f930b40465efb1387010a71d92abdb7dea67d7664725f530d4d46e4adb6b86fd9ae0342a0f996a64bfcbcbd1612c8479105707b
|
@@ -15,22 +15,28 @@ module Olivander
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
def self.auto_datatable(klazz, link_path: nil, only: [])
|
18
|
+
def self.auto_datatable(klazz, link_path: nil, only: [], except: [], hide: [], show: [])
|
19
|
+
Rails.logger.debug "initializing datatable for #{klazz}"
|
20
|
+
|
21
|
+
attributes = klazz.new.attributes.collect{ |x| x[0] }
|
22
|
+
attributes &&= only if only.size.positive?
|
23
|
+
attributes -= except if except.size.positive?
|
24
|
+
|
25
|
+
default_hidden = %w[id created updated created_at updated_at deleted_at current_user current_action]
|
26
|
+
|
19
27
|
collection do
|
20
28
|
klazz.all
|
21
29
|
end
|
22
30
|
|
23
31
|
datatable do
|
24
32
|
bulk_actions_col
|
25
|
-
|
26
|
-
key = att[0]
|
27
|
-
next if only.size.positive? && !only.include?(key)
|
33
|
+
attributes.each do |key|
|
28
34
|
sym = key.gsub('_id', '').to_sym
|
29
|
-
visible =
|
35
|
+
visible = show.include?(key) || !(default_hidden.include?(key) || hide.include?(key))
|
30
36
|
if link_path.present? && sym == :id
|
31
37
|
link_col sym, link_path, :id
|
32
38
|
elsif link_path.present? && sym == :name
|
33
|
-
link_col sym, link_path, [
|
39
|
+
link_col sym, link_path, %i[id name]
|
34
40
|
else
|
35
41
|
col sym, visible: visible
|
36
42
|
end
|
data/lib/olivander/version.rb
CHANGED