five-two-nw-olivander 0.1.2.10 → 0.1.2.11

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
  SHA256:
3
- metadata.gz: 27eeceb116bacdfc914171167f209c9b09305a164e271ad5894fbc1ad78e0e1e
4
- data.tar.gz: 4ef6d96a61a6ff296259441091813d1e7b9f513e11d47d2dd1cde96cc4faa4be
3
+ metadata.gz: 646461db1504efbb35c466f41a39995598c41af6379f0c4e774604df8fe06751
4
+ data.tar.gz: 87e8135af0ceb0082d12413cd37b81aab648140ab485f5fb3ed2b0a208061c43
5
5
  SHA512:
6
- metadata.gz: ed49ba1c5d32c9ab8ef88bfdad416342cf80dd0eda3a0e1600db2e0c38bc5f97c6bdb8a929270ffa2d79768589719ba337a1f761e4cda5af64c939dfc0f24c75
7
- data.tar.gz: f6717a1d889709cdb655d5b848e8a84aa7c1cfa62ecb112ce159835980ced10ecd332d8413a627af642207a8ef69059ad206ed3271c0e025f7779223af21db3f
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
- klazz.new.attributes.each do |att|
26
- key = att[0]
27
- next if only.size.positive? && !only.include?(key)
34
+ attributes.each do |key|
35
+ puts "handling key: #{key}"
36
+
28
37
  sym = key.gsub('_id', '').to_sym
29
- visible = !['created', 'updated', 'created_at', 'updated_at', 'deleted_at', 'current_user', 'current_action'].include?(key)
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, [:id, :name]
42
+ link_col sym, link_path, %i[id name]
34
43
  else
35
44
  col sym, visible: visible
36
45
  end
@@ -1,3 +1,3 @@
1
1
  module Olivander
2
- VERSION = "0.1.2.10"
2
+ VERSION = "0.1.2.11"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: five-two-nw-olivander
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2.10
4
+ version: 0.1.2.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Dennis