five-two-nw-olivander 0.1.2.11 → 0.1.2.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 646461db1504efbb35c466f41a39995598c41af6379f0c4e774604df8fe06751
4
- data.tar.gz: 87e8135af0ceb0082d12413cd37b81aab648140ab485f5fb3ed2b0a208061c43
3
+ metadata.gz: 3fafc0f233f53a5a60c3be296bc128cbbb3700959f82b05cf41029ac144c6a89
4
+ data.tar.gz: d6a987479ebe1d30a5f4671a0ca6ede3912f852e1c9cb2e549053802dc42340e
5
5
  SHA512:
6
- metadata.gz: 8d531d6cca6f76ee6fc63b5cff0cee413b65b2af44f2e61c4a49875e5b513303b7be40ffed8f9580c54a59934d5196bc64cf5bf947490912f42e36354cb88e11
7
- data.tar.gz: b010327c42b8b6d5fe4b54d8d7b5e8a327922bb31c0ab3fef168033dec98a654b9a46a91a15ff2d3221f67798172494c9d626a879d067f617bc77a0c7c196eca
6
+ metadata.gz: 2aafa57f69b573299d2857fa04ebe05db1407c0c83c1657c54afbe6eda6e164caf670909e53e30362b2e952d666648126a97b463f50ecd116d9384d7c48c9993
7
+ data.tar.gz: 8b3d2b995b2afa004fc2bb2fe313a1aabf448d638ddd45d5ff24fe33bf04674b6be97afe1b67c636fd612a478e6ed75190daddd9b42271fc8e0f64e29d691831
@@ -1,7 +1,7 @@
1
1
  module Olivander
2
2
  class Datatable < Effective::Datatable
3
- def link_col(field, path, path_args)
4
- dsl_tool.col(field) do |r|
3
+ def link_col(field, path, path_args, visible: true)
4
+ dsl_tool.col(field, visible: visible) do |r|
5
5
  args = [].tap do |arr|
6
6
  if path_args.is_a? Array
7
7
  path_args.each do |arg|
@@ -15,31 +15,29 @@ module Olivander
15
15
  end
16
16
  end
17
17
 
18
- def self.auto_datatable(klazz, link_path: nil, only: [], except: [], hide: [], show: [])
18
+ def self.auto_datatable(klazz, collection: nil, link_path: nil, only: [], except: [], hide: [], show: [], order_by: [])
19
19
  Rails.logger.debug "initializing datatable for #{klazz}"
20
20
 
21
- attributes = klazz.new.attributes.select{ |x| x[0] }
21
+ attributes = klazz.new.attributes.collect{ |x| x[0] }
22
22
  attributes &&= only if only.size.positive?
23
23
  attributes -= except if except.size.positive?
24
24
 
25
25
  default_hidden = %w[id created updated created_at updated_at deleted_at current_user current_action]
26
26
 
27
27
  collection do
28
- klazz.all
28
+ collection.nil? ? klazz.all : collection
29
29
  end
30
30
 
31
31
  datatable do
32
- puts 'and also too'
32
+ order(order_by[0], order_by[1]) if order_by.size == 2
33
33
  bulk_actions_col
34
34
  attributes.each do |key|
35
- puts "handling key: #{key}"
36
-
37
35
  sym = key.gsub('_id', '').to_sym
38
36
  visible = show.include?(key) || !(default_hidden.include?(key) || hide.include?(key))
39
37
  if link_path.present? && sym == :id
40
- link_col sym, link_path, :id
38
+ link_col sym, link_path, :id, visible: visible
41
39
  elsif link_path.present? && sym == :name
42
- link_col sym, link_path, %i[id name]
40
+ link_col sym, link_path, %i[id name], visible: visible
43
41
  else
44
42
  col sym, visible: visible
45
43
  end
@@ -20,6 +20,8 @@ module Olivander
20
20
  def authorized_resource_actions(route_builder, resource, for_action: :show)
21
21
  plural_name = resource.is_a?(Class) ? resource.table_name : resource.class.table_name
22
22
  routed_resource = route_builder.resources[plural_name.to_sym]
23
+ return [] if routed_resource.nil?
24
+
23
25
  actions = resource.is_a?(Class) ?
24
26
  (routed_resource.unpersisted_crud_actions | routed_resource.collection_actions.select{ |x| !x.crud_action }) :
25
27
  (resource.persisted? ? (routed_resource.persisted_crud_actions | routed_resource.member_actions.select{ |x| !x.crud_action }): [])
@@ -20,7 +20,6 @@
20
20
  .card-body
21
21
  = render_datatable_chart(@datatable, k)
22
22
 
23
- - if @datatable
24
23
  = content_for :datatable_charts
25
24
 
26
25
  .row
@@ -46,3 +45,7 @@
46
45
  %p or include Effective::CrudController in your controller
47
46
  -# .card-footer
48
47
 
48
+ - begin
49
+ = render partial: 'index_additional'
50
+ - rescue ActionView::MissingTemplate
51
+ - Rails.logger.debug "did not find additional index partial"
@@ -1,3 +1,3 @@
1
1
  module Olivander
2
- VERSION = "0.1.2.11"
2
+ VERSION = "0.1.2.13"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
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.11
4
+ version: 0.1.2.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Dennis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-06 00:00:00.000000000 Z
11
+ date: 2023-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chartkick