five-two-nw-olivander 0.1.2.6 → 0.1.2.8
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 +15 -1
- data/app/datatables/olivander/datatable.rb +24 -0
- data/app/views/application/index.html.haml +24 -1
- 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 +2 -2
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
|
@@ -1,5 +1,28 @@
|
|
1
1
|
- resource = (@_effective_resource || Effective::Resource.new(controller_path))
|
2
2
|
|
3
|
+
- if @datatable
|
4
|
+
- content_for :datatable do
|
5
|
+
= render_datatable(@datatable, charts: false)
|
6
|
+
- content_for :datatable_charts do
|
7
|
+
- keys = @datatable._charts.keys
|
8
|
+
- ks = keys.size
|
9
|
+
- if ks.positive?
|
10
|
+
%br
|
11
|
+
.row
|
12
|
+
- @datatable._charts.keys.each do |k|
|
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)}"}
|
14
|
+
.card.card-secondary
|
15
|
+
.card-header
|
16
|
+
%h3.card-title= I18n.t([@datatable.class.name.underscore, 'charts', k].join('.'))
|
17
|
+
.card-tools.text-right
|
18
|
+
%button.btn.btn-tool{ type: :button, 'data-card-widget': :maximize }
|
19
|
+
%i.fas.fa-expand
|
20
|
+
.card-body
|
21
|
+
= render_datatable_chart(@datatable, k)
|
22
|
+
|
23
|
+
- if @datatable
|
24
|
+
= content_for :datatable_charts
|
25
|
+
|
3
26
|
.row
|
4
27
|
.col-12
|
5
28
|
.card
|
@@ -9,7 +32,7 @@
|
|
9
32
|
= resource_form_actions(@context.route_builder, resource.klass, for_action: :index)
|
10
33
|
.card-body
|
11
34
|
- if @datatable
|
12
|
-
=
|
35
|
+
= content_for :datatable
|
13
36
|
|
14
37
|
- elsif instance_variable_get('@' + resource.plural_name).respond_to?(:to_partial_path)
|
15
38
|
= render instance_variable_get('@' + resource.plural_name)
|
@@ -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
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.8
|
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-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chartkick
|