five-two-nw-olivander 0.1.2.7 → 0.1.2.8
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 +4 -4
- data/app/controllers/concerns/olivander/resources/route_builder.rb +15 -1
- data/app/datatables/olivander/datatable.rb +24 -0
- data/app/views/application/index.html.haml +2 -0
- data/app/views/effective/resource/_actions_dropleft.html.haml +3 -6
- data/app/views/layouts/olivander/adminlte/_sidebar.html.haml +1 -1
- data/lib/five-two-nw-olivander.rb +1 -0
- 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: 3f3115b1794baed9344d980ed505a3df7d1ae0cee954e4896163618a91d47f58
|
4
|
+
data.tar.gz: '09d31e3619bfa1d7111077c3be1c9f5c0005a1417dd041bc68aa71bf32014988'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e34e263e6a3b6788b7764882d65e0caa54f5ca0c99109f3908c7d3c5f42af2a7328bc35fe2a6904643b6c624b9ca1ba3fcbeee671e5dd5f8a86a8b59dc5a58d
|
7
|
+
data.tar.gz: 18d6f99fba59c05f75b2c1e5394496be073965270682d778111a735600303734801c2e821a95cb41c62d0207bdfd9f8b71fc874fe0dbade368224b9df6957361
|
@@ -1,7 +1,9 @@
|
|
1
1
|
module Olivander
|
2
2
|
module Resources
|
3
3
|
class ResourceAction
|
4
|
-
attr_accessor :sym, :action, :verb, :confirm, :turbo_frame, :collection,
|
4
|
+
attr_accessor :sym, :action, :verb, :confirm, :turbo_frame, :collection,
|
5
|
+
:controller, :crud_action, :show_in_form, :show_in_datatable,
|
6
|
+
:no_route, :path_helper
|
5
7
|
|
6
8
|
def initialize(sym, action: nil, controller: nil, verb: :get, confirm: false, turbo_frame: nil, collection: false, crud_action: false,
|
7
9
|
show_in_form: true, show_in_datatable: true, no_route: false)
|
@@ -83,6 +85,7 @@ module Olivander
|
|
83
85
|
included do
|
84
86
|
class_attribute :resources, default: {}
|
85
87
|
class_attribute :current_resource
|
88
|
+
class_attribute :last_path_helper
|
86
89
|
end
|
87
90
|
|
88
91
|
class_methods do
|
@@ -107,6 +110,13 @@ module Olivander
|
|
107
110
|
build_resource_routes(mapper)
|
108
111
|
end
|
109
112
|
|
113
|
+
def set_controller_and_helper(a)
|
114
|
+
last_route = Rails.application.routes.routes.last
|
115
|
+
a.controller = last_route.defaults[:controller]
|
116
|
+
a.path_helper = last_route.name.blank? ? last_path_helper : "#{last_route.name}_path"
|
117
|
+
self.last_path_helper = a.path_helper
|
118
|
+
end
|
119
|
+
|
110
120
|
def build_resource_routes(mapper)
|
111
121
|
resources.keys.each do |k|
|
112
122
|
r = resources[k]
|
@@ -118,9 +128,11 @@ module Olivander
|
|
118
128
|
|
119
129
|
if ba.confirm
|
120
130
|
mapper.get ba.action, action: "confirm_#{ba.action}"
|
131
|
+
set_controller_and_helper(ba)
|
121
132
|
mapper.post ba.action
|
122
133
|
else
|
123
134
|
mapper.send(ba.verb, ba.action)
|
135
|
+
set_controller_and_helper(ba)
|
124
136
|
end
|
125
137
|
end
|
126
138
|
end
|
@@ -134,9 +146,11 @@ module Olivander
|
|
134
146
|
next if ma.no_route
|
135
147
|
if ma.confirm
|
136
148
|
mapper.get ma.action, action: "confirm_#{ma.action}"
|
149
|
+
set_controller_and_helper(ma)
|
137
150
|
mapper.post ma.action
|
138
151
|
else
|
139
152
|
mapper.send(ma.verb, ma.action)
|
153
|
+
set_controller_and_helper(ma)
|
140
154
|
end
|
141
155
|
end
|
142
156
|
end
|
@@ -14,5 +14,29 @@ module Olivander
|
|
14
14
|
link_to r.send(field), send(path, args)
|
15
15
|
end
|
16
16
|
end
|
17
|
+
|
18
|
+
def self.auto_datatable(klazz, link_path: nil, only: [])
|
19
|
+
collection do
|
20
|
+
klazz.all
|
21
|
+
end
|
22
|
+
|
23
|
+
datatable do
|
24
|
+
bulk_actions_col
|
25
|
+
klazz.new.attributes.each do |att|
|
26
|
+
key = att[0]
|
27
|
+
next if only.size.positive? && !only.include?(key)
|
28
|
+
sym = key.gsub('_id', '').to_sym
|
29
|
+
visible = !['created', 'updated', 'created_at', 'updated_at', 'deleted_at', 'current_user', 'current_action'].include?(key)
|
30
|
+
if link_path.present? && sym == :id
|
31
|
+
link_col sym, link_path, :id
|
32
|
+
elsif link_path.present? && sym == :name
|
33
|
+
link_col sym, link_path, [:id, :name]
|
34
|
+
else
|
35
|
+
col sym, visible: visible
|
36
|
+
end
|
37
|
+
end
|
38
|
+
actions_col
|
39
|
+
end
|
40
|
+
end
|
17
41
|
end
|
18
42
|
end
|
@@ -7,6 +7,7 @@
|
|
7
7
|
- keys = @datatable._charts.keys
|
8
8
|
- ks = keys.size
|
9
9
|
- if ks.positive?
|
10
|
+
%br
|
10
11
|
.row
|
11
12
|
- @datatable._charts.keys.each do |k|
|
12
13
|
%div{ class: "#{col_class_num('xl', ks, 3)} #{col_class_num('lg', ks, 2)} #{col_class_num('md', ks, 6)} #{col_class_num('sm', ks, 6)}"}
|
@@ -21,6 +22,7 @@
|
|
21
22
|
|
22
23
|
- if @datatable
|
23
24
|
= content_for :datatable_charts
|
25
|
+
|
24
26
|
.row
|
25
27
|
.col-12
|
26
28
|
.card
|
@@ -1,7 +1,4 @@
|
|
1
|
-
-
|
2
|
-
- parts = datatable.class.name.split('::')
|
3
|
-
- parts[parts.size-1] = 'Controller'
|
4
|
-
- parts.join('::').constantize.new.build_context
|
1
|
+
- route_builder = @context&.route_builder || datatable.class::ROUTE_BUILDER
|
5
2
|
= dropdown(variation: :dropleft, btn_class: btn_class) do
|
6
|
-
- authorized_resource_actions(
|
7
|
-
= dropdown_link_to a.sym,
|
3
|
+
- authorized_resource_actions(route_builder, resource, for_action: action_name).select{ |x| x.show_in_datatable }.each do |a|
|
4
|
+
= dropdown_link_to a.sym, send(a.path_helper, resource.id)
|
@@ -11,7 +11,7 @@
|
|
11
11
|
.image
|
12
12
|
%img.img-circle.elevation-2{:alt => "User Image", :src => image_path(user_image_path(nil))}/
|
13
13
|
.info
|
14
|
-
|
14
|
+
= link_to current_erp_user, destroy_erp_user_session_path, method: :delete, class: 'd-block'
|
15
15
|
/ SidebarSearch Form
|
16
16
|
.form-inline
|
17
17
|
.input-group{"data-widget" => "sidebar-search"}
|
data/lib/olivander/version.rb
CHANGED