five-two-nw-olivander 0.1.2.51 → 0.1.2.53
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/controllers/datatable_index_charts_controller.js +16 -0
- data/app/controllers/concerns/olivander/resources/route_builder.rb +39 -5
- data/app/views/application/_resource_form_actions.html.haml +2 -6
- data/app/views/effective/resource/_actions_dropleft.html.haml +1 -2
- data/config/importmap.rb +1 -0
- data/lib/olivander/engine.rb +5 -1
- data/lib/olivander/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 632378da94b2fa416a7e6108084b417e89d0c3cf80ed6977c952296e808102de
|
4
|
+
data.tar.gz: d6b59b0877cc908bbb0da4ddb0ffe4acac4ef0195e7c3a5659cdf167760b1dd5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4342053f522cb69b4853def238a22cecf0d70927384fd6ddc12c8794d546c054b5594a5000aae0186f512438bb4e0b822f89b2abaf1bda5f9f9d057e213a635
|
7
|
+
data.tar.gz: 1452432fe2d9c5e3469f4878a7f3984ed99e19d54cdfd645eb549f8f04770b760865b0e444731c7cc261456f5904e4b29c91586fe000fb8279b4770712af4174
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import { Controller } from "@hotwired/stimulus"
|
2
|
+
|
3
|
+
// Connects to data-controller="datatable-index-charts"
|
4
|
+
export default class extends Controller {
|
5
|
+
connect() {
|
6
|
+
var self = this
|
7
|
+
|
8
|
+
$(".effective-datatable").on("draw.dt", function(e, dt, type, indexes) {
|
9
|
+
var jsonCharts = dt.json.charts
|
10
|
+
for (var chart in jsonCharts) {
|
11
|
+
var chartkickChart = Chartkick.charts[chart]
|
12
|
+
chartkickChart.redraw()
|
13
|
+
}
|
14
|
+
});
|
15
|
+
}
|
16
|
+
}
|
@@ -3,10 +3,12 @@ module Olivander
|
|
3
3
|
class ResourceAction
|
4
4
|
attr_accessor :sym, :action, :verb, :confirm, :turbo_frame, :collection,
|
5
5
|
:controller, :crud_action, :show_in_form, :show_in_datatable,
|
6
|
-
:no_route, :path_helper
|
6
|
+
:no_route, :path_helper, :confirm_with
|
7
7
|
|
8
|
-
def initialize(sym, action: nil, controller: nil, verb: :get, confirm: false,
|
9
|
-
|
8
|
+
def initialize(sym, action: nil, controller: nil, verb: :get, confirm: false,
|
9
|
+
turbo_frame: nil, collection: false, crud_action: false,
|
10
|
+
show_in_form: true, show_in_datatable: true, no_route: false,
|
11
|
+
path_helper: nil, confirm_with: nil)
|
10
12
|
self.sym = sym
|
11
13
|
self.action = action || sym
|
12
14
|
self.controller = controller
|
@@ -19,6 +21,35 @@ module Olivander
|
|
19
21
|
self.show_in_datatable = show_in_datatable
|
20
22
|
self.no_route = no_route
|
21
23
|
self.path_helper = path_helper
|
24
|
+
self.confirm_with = confirm_with
|
25
|
+
end
|
26
|
+
|
27
|
+
def args_hash(options = nil)
|
28
|
+
{}.tap do |h|
|
29
|
+
h.merge!(method: verb) if turbo_frame.blank?
|
30
|
+
h.merge!(data: data_hash)
|
31
|
+
h.merge!(options) if options.present?
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def data_hash
|
36
|
+
{}.tap do |h|
|
37
|
+
h.merge!(turbo: true, turbo_method: verb, turbo_frame: turbo_frame) if turbo_frame.present?
|
38
|
+
|
39
|
+
message = confirmation_message
|
40
|
+
h.merge!(confirm_key => message) unless message.blank?
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def confirm_key
|
45
|
+
turbo_frame.present? ? :turbo_confirm : :confirm
|
46
|
+
end
|
47
|
+
|
48
|
+
def confirmation_message
|
49
|
+
return confirm_with if confirm_with.present?
|
50
|
+
return I18n.t('activerecord.actions.delete-confirmation') if verb == :delete
|
51
|
+
|
52
|
+
nil
|
22
53
|
end
|
23
54
|
end
|
24
55
|
|
@@ -99,13 +130,16 @@ module Olivander
|
|
99
130
|
end
|
100
131
|
|
101
132
|
def action(sym, verb: :get, confirm: false, turbo_frame: nil, collection: false, show_in_datatable: true,
|
102
|
-
show_in_form: true, no_route: false, controller: nil, action: nil, path_helper: nil
|
133
|
+
show_in_form: true, no_route: false, controller: nil, action: nil, path_helper: nil,
|
134
|
+
confirm_with: nil
|
135
|
+
)
|
103
136
|
raise 'Must be invoked in a resource block' unless current_resource.present?
|
104
137
|
|
105
138
|
controller ||= current_resource.model
|
106
139
|
current_resource.actions << ResourceAction.new(
|
107
140
|
sym, action: action, controller: controller, verb: verb, confirm: confirm, turbo_frame: turbo_frame, collection: collection,
|
108
|
-
show_in_datatable: show_in_datatable, show_in_form: show_in_form, no_route: no_route, path_helper: path_helper
|
141
|
+
show_in_datatable: show_in_datatable, show_in_form: show_in_form, no_route: no_route, path_helper: path_helper,
|
142
|
+
confirm_with: confirm_with
|
109
143
|
)
|
110
144
|
end
|
111
145
|
|
@@ -7,10 +7,6 @@
|
|
7
7
|
%i.fa{ class: I18n.t(icon_key)}
|
8
8
|
= resource_form_action_label(@resource, a.sym)
|
9
9
|
|
10
|
-
|
11
|
-
=
|
12
|
-
= yield cf_sym
|
13
|
-
- else
|
14
|
-
= link_to({ controller: a.controller, action: a.action }, class: 'btn btn-tool', data: { turbo: true, turbo_method: a.verb, turbo_frame: a.turbo_frame }) do
|
15
|
-
= yield cf_sym
|
10
|
+
= link_to({ controller: a.controller, action: a.action }, a.args_hash(class: 'btn btn-tool')) do
|
11
|
+
= yield cf_sym
|
16
12
|
|
@@ -19,8 +19,7 @@
|
|
19
19
|
= dropdown_link_to resource_form_action_label(resource, a.sym), path, data: data, method: a.verb
|
20
20
|
- crud_actions.each do |a|
|
21
21
|
- path = a.path_helper.is_a?(Proc) ? a.path_helper.call(resource) : send(a.path_helper, resource.id)
|
22
|
-
- data = a.turbo_frame.present? ? { turbo: true, turbo_frame: a.turbo_frame } : {}
|
23
22
|
- icon_class = (a.verb == :delete ? '' : '')
|
24
|
-
= link_to path,
|
23
|
+
= link_to path, a.args_hash(title: resource_form_action_label(resource, a.sym), class: "btn btn-sm #{icon_class}") do
|
25
24
|
%i{ class: resource_form_action_icon(resource, a.sym), style: 'display: block; font-size: 10px' }
|
26
25
|
%span{ style: 'font-size: 12px' }= resource_form_action_label(resource, a.sym)
|
data/config/importmap.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
pin_all_from "..app/javascript/controllers", under: "controllers"
|
data/lib/olivander/engine.rb
CHANGED
@@ -3,7 +3,7 @@ module Olivander
|
|
3
3
|
isolate_namespace Olivander
|
4
4
|
|
5
5
|
initializer "olivander.assets.precompile" do |app|
|
6
|
-
app.config.assets.precompile += %w[adminlte.js adminlte.css avatar0.png avatar1.png avatar2.png avatar3.png avatar4.png]
|
6
|
+
app.config.assets.precompile += %w[adminlte.js datatable_index_charts_controller.js adminlte.css avatar0.png avatar1.png avatar2.png avatar3.png avatar4.png]
|
7
7
|
end
|
8
8
|
|
9
9
|
initializer "olivander.action_controller" do |app|
|
@@ -11,5 +11,9 @@ module Olivander
|
|
11
11
|
helper Olivander::ApplicationHelper
|
12
12
|
end
|
13
13
|
end
|
14
|
+
|
15
|
+
initializer "olivander.importmap", before: "importmap" do |app|
|
16
|
+
app.config.importmap.paths << Engine.root.join('config/importmap.rb')
|
17
|
+
end
|
14
18
|
end
|
15
19
|
end
|
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.53
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Dennis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-01-
|
11
|
+
date: 2024-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chartkick
|
@@ -204,6 +204,7 @@ files:
|
|
204
204
|
- app/assets/javascripts/adminlte/plugins/tempusdominus-bootstrap-4/css/tempusdominus-bootstrap-4.min.css
|
205
205
|
- app/assets/javascripts/adminlte/plugins/tempusdominus-bootstrap-4/js/tempusdominus-bootstrap-4.min.js
|
206
206
|
- app/assets/javascripts/adminlte/select2_defaults.coffee
|
207
|
+
- app/assets/javascripts/controllers/datatable_index_charts_controller.js
|
207
208
|
- app/assets/stylesheets/adminlte.css
|
208
209
|
- app/assets/stylesheets/fa-fix.scss
|
209
210
|
- app/assets/stylesheets/olivander/application.css
|
@@ -251,6 +252,7 @@ files:
|
|
251
252
|
- app/views/layouts/olivander/adminlte/login.html.haml
|
252
253
|
- app/views/layouts/olivander/adminlte/main.html.haml
|
253
254
|
- app/views/layouts/olivander/application.html.haml
|
255
|
+
- config/importmap.rb
|
254
256
|
- config/initializers/simple_form.rb
|
255
257
|
- config/locales/simple_form.en.yml
|
256
258
|
- config/routes.rb
|