five-two-nw-olivander 0.1.2.12 → 0.1.2.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/concerns/olivander/resources/route_builder.rb +5 -3
- data/app/datatables/olivander/datatable.rb +7 -6
- data/app/helpers/olivander/application_helper.rb +4 -1
- data/app/views/application/index.html.haml +4 -1
- data/app/views/effective/resource/_actions_dropleft.html.haml +2 -1
- data/lib/olivander/version.rb +1 -1
- metadata +2 -3
- data/app/datatables/test_datatable.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '05099f9c49667c865027fd2291a2c87caa0b4067d1a5a42bf486717f02076980'
|
4
|
+
data.tar.gz: 7846c476cf57f4a5016208c8776c8dc77fd676a3ddfa8396560f16273e396602
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89997456c2a356285ff8d4b5574ca4efe865773a627962620052533be21e7bd086807ae8472c9af2ba5a7e8a4baedfc425d0e55ac9733c7ccdccf516e5251d3b
|
7
|
+
data.tar.gz: '028cb6fa2eda1c411230cc227fe6eaa252885ce88bea190095fe6c5cd80b46379d4bf880b1f6e03d6e9122171ea8bfd6697b0a98dc3ec1467fe2a55b4c52efa7'
|
@@ -6,7 +6,7 @@ module Olivander
|
|
6
6
|
:no_route, :path_helper
|
7
7
|
|
8
8
|
def initialize(sym, action: nil, controller: nil, verb: :get, confirm: false, turbo_frame: nil, collection: false, crud_action: false,
|
9
|
-
show_in_form: true, show_in_datatable: true, no_route: false)
|
9
|
+
show_in_form: true, show_in_datatable: true, no_route: false, path_helper: nil)
|
10
10
|
self.sym = sym
|
11
11
|
self.action = action || sym
|
12
12
|
self.controller = controller
|
@@ -18,6 +18,7 @@ module Olivander
|
|
18
18
|
self.show_in_form = show_in_form
|
19
19
|
self.show_in_datatable = show_in_datatable
|
20
20
|
self.no_route = no_route
|
21
|
+
self.path_helper = path_helper
|
21
22
|
end
|
22
23
|
end
|
23
24
|
|
@@ -96,13 +97,14 @@ module Olivander
|
|
96
97
|
self.current_resource = nil
|
97
98
|
end
|
98
99
|
|
99
|
-
def action(sym, verb: :get, confirm: false, turbo_frame: nil, collection: false, show_in_datatable: true,
|
100
|
+
def action(sym, verb: :get, confirm: false, turbo_frame: nil, collection: false, show_in_datatable: true,
|
101
|
+
show_in_form: true, no_route: false, controller: nil, action: nil, path_helper: nil)
|
100
102
|
raise 'Must be invoked in a resource block' unless current_resource.present?
|
101
103
|
|
102
104
|
controller ||= current_resource.model
|
103
105
|
current_resource.actions << ResourceAction.new(
|
104
106
|
sym, action: action, controller: controller, verb: verb, confirm: confirm, turbo_frame: turbo_frame, collection: collection,
|
105
|
-
show_in_datatable: show_in_datatable, show_in_form: show_in_form, no_route: no_route
|
107
|
+
show_in_datatable: show_in_datatable, show_in_form: show_in_form, no_route: no_route, path_helper: path_helper
|
106
108
|
)
|
107
109
|
end
|
108
110
|
|
@@ -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,7 +15,7 @@ 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
21
|
attributes = klazz.new.attributes.collect{ |x| x[0] }
|
@@ -25,18 +25,19 @@ module Olivander
|
|
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
|
+
order(order_by[0], order_by[1]) if order_by.size == 2
|
32
33
|
bulk_actions_col
|
33
34
|
attributes.each do |key|
|
34
35
|
sym = key.gsub('_id', '').to_sym
|
35
36
|
visible = show.include?(key) || !(default_hidden.include?(key) || hide.include?(key))
|
36
37
|
if link_path.present? && sym == :id
|
37
|
-
link_col sym, link_path, :id
|
38
|
+
link_col sym, link_path, :id, visible: visible
|
38
39
|
elsif link_path.present? && sym == :name
|
39
|
-
link_col sym, link_path, %i[id name]
|
40
|
+
link_col sym, link_path, %i[id name], visible: visible
|
40
41
|
else
|
41
42
|
col sym, visible: visible
|
42
43
|
end
|
@@ -18,8 +18,11 @@ module Olivander
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def authorized_resource_actions(route_builder, resource, for_action: :show)
|
21
|
-
|
21
|
+
raw_name = resource.is_a?(Class) ? resource.name : resource.class.name
|
22
|
+
plural_name = raw_name.demodulize.underscore.pluralize
|
22
23
|
routed_resource = route_builder.resources[plural_name.to_sym]
|
24
|
+
return [] if routed_resource.nil?
|
25
|
+
|
23
26
|
actions = resource.is_a?(Class) ?
|
24
27
|
(routed_resource.unpersisted_crud_actions | routed_resource.collection_actions.select{ |x| !x.crud_action }) :
|
25
28
|
(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,4 +1,5 @@
|
|
1
1
|
- route_builder = @context&.route_builder || datatable.class::ROUTE_BUILDER
|
2
2
|
= dropdown(variation: :dropleft, btn_class: btn_class) do
|
3
3
|
- authorized_resource_actions(route_builder, resource, for_action: action_name).select{ |x| x.show_in_datatable }.each do |a|
|
4
|
-
=
|
4
|
+
- path = a.path_helper.is_a?(Proc) ? a.path_helper.call(resource) : send(a.path_helper, resource.id)
|
5
|
+
= dropdown_link_to a.sym, path
|
data/lib/olivander/version.rb
CHANGED
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.
|
4
|
+
version: 0.1.2.14
|
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-
|
11
|
+
date: 2023-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chartkick
|
@@ -189,7 +189,6 @@ files:
|
|
189
189
|
- app/controllers/concerns/olivander/resources/route_builder.rb
|
190
190
|
- app/controllers/olivander/application_controller.rb
|
191
191
|
- app/datatables/olivander/datatable.rb
|
192
|
-
- app/datatables/test_datatable.rb
|
193
192
|
- app/helpers/olivander/application_helper.rb
|
194
193
|
- app/jobs/olivander/application_job.rb
|
195
194
|
- app/mailers/olivander/application_mailer.rb
|