five-two-nw-olivander 0.1.2.10 → 0.1.2.11
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 +15 -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: 646461db1504efbb35c466f41a39995598c41af6379f0c4e774604df8fe06751
|
4
|
+
data.tar.gz: 87e8135af0ceb0082d12413cd37b81aab648140ab485f5fb3ed2b0a208061c43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d531d6cca6f76ee6fc63b5cff0cee413b65b2af44f2e61c4a49875e5b513303b7be40ffed8f9580c54a59934d5196bc64cf5bf947490912f42e36354cb88e11
|
7
|
+
data.tar.gz: b010327c42b8b6d5fe4b54d8d7b5e8a327922bb31c0ab3fef168033dec98a654b9a46a91a15ff2d3221f67798172494c9d626a879d067f617bc77a0c7c196eca
|
@@ -15,22 +15,31 @@ 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.select{ |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
|
32
|
+
puts 'and also too'
|
24
33
|
bulk_actions_col
|
25
|
-
|
26
|
-
key
|
27
|
-
|
34
|
+
attributes.each do |key|
|
35
|
+
puts "handling key: #{key}"
|
36
|
+
|
28
37
|
sym = key.gsub('_id', '').to_sym
|
29
|
-
visible =
|
38
|
+
visible = show.include?(key) || !(default_hidden.include?(key) || hide.include?(key))
|
30
39
|
if link_path.present? && sym == :id
|
31
40
|
link_col sym, link_path, :id
|
32
41
|
elsif link_path.present? && sym == :name
|
33
|
-
link_col sym, link_path, [
|
42
|
+
link_col sym, link_path, %i[id name]
|
34
43
|
else
|
35
44
|
col sym, visible: visible
|
36
45
|
end
|
data/lib/olivander/version.rb
CHANGED