five-two-nw-olivander 0.2.0.36 → 0.2.0.38
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/adminlte/datatable.fix.js +3 -0
- data/app/assets/stylesheets/adminlte.css +3 -2
- data/app/controllers/concerns/olivander/resources/route_builder.rb +48 -42
- data/app/datatables/olivander/datatable.rb +3 -3
- 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: 9bd58e03477da793320172cd5573cbcf620bb80718dd0738c81fc4bb43f7ba77
|
4
|
+
data.tar.gz: 73051678eacddbd98c9837807cf3927aceb7f007495e6707df8ca3c86cae71b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d065f3f59f8c589faaa0bf14382aeac4ad5f53c1d990f8222943dee86f6fd8e74d259bf722db00a3d138e252270fe129e5d1d1453683c8b6410daed7307eabbb
|
7
|
+
data.tar.gz: ac20459dab97139df83767b3cd7cbe1b49b265ce212d2e5eedcd813e8fd4e8294f9fa551d5aa33acf8eef43cfb727d0125306f7238f4e519aa52db922e207679
|
@@ -29,6 +29,9 @@
|
|
29
29
|
$(document).ready(function(e) {
|
30
30
|
return destroySelect2s();
|
31
31
|
});
|
32
|
+
$(document).on('page:change', function() {
|
33
|
+
return destroySelect2s();
|
34
|
+
});
|
32
35
|
|
33
36
|
// $(document).ready(function(e) {
|
34
37
|
// return $('.effective-datatables-filters input').click(function() {
|
@@ -13,6 +13,7 @@
|
|
13
13
|
*= require 'adminlte/plugins/tempusdominus-bootstrap-4/css/tempusdominus-bootstrap-4.min'
|
14
14
|
*= require 'adminlte/plugins/icheck-bootstrap/icheck-bootstrap.min'
|
15
15
|
*= require 'adminlte/plugins/jqvmap/jqvmap.min'
|
16
|
+
*= require effective_datatables
|
16
17
|
*= require 'adminlte/dist/css/adminlte.min'
|
17
18
|
*= require 'adminlte/plugins/overlayScrollbars/css/OverlayScrollbars.min'
|
18
19
|
*= require 'adminlte/plugins/daterangepicker/daterangepicker'
|
@@ -25,7 +26,6 @@
|
|
25
26
|
*= require 'adminlte/plugins/ekko-lightbox/ekko-lightbox.css'
|
26
27
|
*= require 'adminlte/plugins/bootstrap-colorpicker/css/bootstrap-colorpicker.min.css'
|
27
28
|
*= require 'adminlte/plugins/bootstrap-switch/css/bootstrap-switch.min.css'
|
28
|
-
*= require effective_datatables
|
29
29
|
*= require_tree .
|
30
30
|
*= require_self
|
31
31
|
*/
|
@@ -47,4 +47,5 @@ ul.no-bullets {
|
|
47
47
|
list-style-type: none; /* Remove bullets */
|
48
48
|
padding: 0; /* Remove padding */
|
49
49
|
margin: 0; /* Remove margins */
|
50
|
-
}
|
50
|
+
}
|
51
|
+
table.dataTable.table-striped > tbody > tr:nth-of-type(2n+1) { background: rgba(0, 0, 0, 0.05); }
|
@@ -3,39 +3,47 @@ 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, :confirm_with, :primary
|
6
|
+
:no_route, :path_helper, :confirm_with, :primary,
|
7
|
+
:turbo, :html_attributes
|
7
8
|
|
8
|
-
def initialize(sym,
|
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, primary: nil)
|
9
|
+
def initialize(sym, **kwargs)
|
12
10
|
self.sym = sym
|
13
|
-
self.action = action || sym
|
14
|
-
self.controller = controller
|
15
|
-
self.verb = verb
|
16
|
-
self.confirm = confirm
|
17
|
-
self.turbo_frame = turbo_frame
|
18
|
-
self.
|
19
|
-
self.
|
20
|
-
self.
|
21
|
-
self.
|
22
|
-
self.
|
23
|
-
self.
|
24
|
-
self.
|
25
|
-
self.
|
11
|
+
self.action = kwargs[:action] || sym
|
12
|
+
self.controller = kwargs[:controller]
|
13
|
+
self.verb = kwargs[:verb] || :get
|
14
|
+
self.confirm = kwargs[:confirm] || false
|
15
|
+
self.turbo_frame = kwargs[:turbo_frame]
|
16
|
+
self.turbo = kwargs[:turbo] == true ? true : !turbo_frame.blank?
|
17
|
+
self.collection = default_if_not_present(kwargs[:collection], false)
|
18
|
+
self.crud_action = default_if_not_present(kwargs[:crud_action], false)
|
19
|
+
self.show_in_form = default_if_not_present(kwargs[:show_in_form], true)
|
20
|
+
self.show_in_datatable = default_if_not_present(kwargs[:show_in_datatable], true)
|
21
|
+
self.no_route = default_if_not_present(kwargs[:no_route], false)
|
22
|
+
self.path_helper = kwargs[:path_helper]
|
23
|
+
self.confirm_with = kwargs[:confirm_with]
|
24
|
+
self.primary = kwargs[:primary] || crud_action
|
25
|
+
self.html_attributes = kwargs[:html_attributes]
|
26
|
+
end
|
27
|
+
|
28
|
+
def default_if_not_present(value, default)
|
29
|
+
return value unless value.nil?
|
30
|
+
|
31
|
+
default
|
26
32
|
end
|
27
33
|
|
28
34
|
def args_hash(options = nil)
|
29
35
|
{}.tap do |h|
|
30
|
-
h.merge!(method: verb)
|
36
|
+
h.merge!(method: verb) unless turbo
|
31
37
|
h.merge!(data: data_hash)
|
38
|
+
h.merge!(html_attributes) if html_attributes
|
32
39
|
h.merge!(options) if options.present?
|
33
40
|
end
|
34
41
|
end
|
35
42
|
|
36
43
|
def data_hash
|
37
44
|
{}.tap do |h|
|
38
|
-
h.merge!(turbo: true, turbo_method: verb
|
45
|
+
h.merge!(turbo: true, turbo_method: verb) if turbo
|
46
|
+
h.merge!(turbo_frame: turbo_frame) if turbo_frame.present?
|
39
47
|
|
40
48
|
message = confirmation_message
|
41
49
|
h.merge!(confirm_key => message) unless message.blank?
|
@@ -43,7 +51,7 @@ module Olivander
|
|
43
51
|
end
|
44
52
|
|
45
53
|
def confirm_key
|
46
|
-
|
54
|
+
turbo ? :turbo_confirm : :confirm
|
47
55
|
end
|
48
56
|
|
49
57
|
def confirmation_message
|
@@ -63,7 +71,9 @@ module Olivander
|
|
63
71
|
self.actions = []
|
64
72
|
%i[index new create edit show update destroy].each do |ca|
|
65
73
|
next unless crud_actions.include?(ca)
|
66
|
-
|
74
|
+
|
75
|
+
actions << ResourceAction.new(ca, controller: model, verb: resolve_crud_action_verb(ca),
|
76
|
+
collection: resolve_crud_action_collection(ca), crud_action: true)
|
67
77
|
end
|
68
78
|
end
|
69
79
|
|
@@ -85,29 +95,29 @@ module Olivander
|
|
85
95
|
end
|
86
96
|
|
87
97
|
def crud_actions
|
88
|
-
actions.select{ |x| x.crud_action }
|
98
|
+
actions.select { |x| x.crud_action }
|
89
99
|
end
|
90
100
|
|
91
101
|
def member_actions
|
92
|
-
actions.select{ |x| !x.collection }
|
102
|
+
actions.select { |x| !x.collection }
|
93
103
|
end
|
94
104
|
|
95
105
|
def collection_actions
|
96
|
-
actions.select{ |x| x.collection }
|
106
|
+
actions.select { |x| x.collection }
|
97
107
|
end
|
98
108
|
|
99
109
|
def datatable_bulk_actions
|
100
|
-
collection_actions.select{ |x| x.show_in_datatable && !x.crud_action }
|
110
|
+
collection_actions.select { |x| x.show_in_datatable && !x.crud_action }
|
101
111
|
end
|
102
112
|
|
103
113
|
def unpersisted_crud_actions
|
104
114
|
allowed = %i[index new]
|
105
|
-
crud_actions.select{ |x| allowed.include?(x.sym) }
|
115
|
+
crud_actions.select { |x| allowed.include?(x.sym) }
|
106
116
|
end
|
107
117
|
|
108
118
|
def persisted_crud_actions
|
109
119
|
allowed = %i[show edit destroy]
|
110
|
-
crud_actions.select{ |x| allowed.include?(x.sym) }
|
120
|
+
crud_actions.select { |x| allowed.include?(x.sym) }
|
111
121
|
end
|
112
122
|
end
|
113
123
|
|
@@ -123,25 +133,18 @@ module Olivander
|
|
123
133
|
end
|
124
134
|
|
125
135
|
class_methods do
|
126
|
-
def resource(model, only: DEFAULT_CRUD_ACTIONS, except: [], namespaces: []
|
136
|
+
def resource(model, only: DEFAULT_CRUD_ACTIONS, except: [], namespaces: [])
|
127
137
|
self.current_resource = RoutedResource.new(model, namespaces, DEFAULT_CRUD_ACTIONS & (only - except))
|
128
138
|
yield if block_given?
|
129
139
|
resources[model] = current_resource
|
130
140
|
self.current_resource = nil
|
131
141
|
end
|
132
142
|
|
133
|
-
def action(sym,
|
134
|
-
show_in_form: true, no_route: false, controller: nil, action: nil, path_helper: nil,
|
135
|
-
confirm_with: nil, primary: nil
|
136
|
-
)
|
143
|
+
def action(sym, **kwargs)
|
137
144
|
raise 'Must be invoked in a resource block' unless current_resource.present?
|
138
145
|
|
139
|
-
controller ||= current_resource.model
|
140
|
-
current_resource.actions << ResourceAction.new(
|
141
|
-
sym, action: action, controller: controller, verb: verb, confirm: confirm, turbo_frame: turbo_frame, collection: collection,
|
142
|
-
show_in_datatable: show_in_datatable, show_in_form: show_in_form, no_route: no_route, path_helper: path_helper,
|
143
|
-
confirm_with: confirm_with, primary: primary
|
144
|
-
)
|
146
|
+
kwargs[:controller] ||= current_resource.model
|
147
|
+
current_resource.actions << ResourceAction.new(sym, **kwargs)
|
145
148
|
end
|
146
149
|
|
147
150
|
def build_routes(mapper)
|
@@ -185,13 +188,16 @@ module Olivander
|
|
185
188
|
end
|
186
189
|
end
|
187
190
|
|
188
|
-
|
189
|
-
mapper.
|
190
|
-
|
191
|
+
if r.collection_actions.select { |x| x.action == :new }.size.positive?
|
192
|
+
mapper.new do
|
193
|
+
mapper.get :new
|
194
|
+
end
|
195
|
+
end
|
191
196
|
|
192
197
|
mapper.member do
|
193
198
|
r.member_actions.each do |ma|
|
194
199
|
next if ma.no_route
|
200
|
+
|
195
201
|
if ma.confirm
|
196
202
|
mapper.get ma.action, action: "confirm_#{ma.action}"
|
197
203
|
set_controller_and_helper(ma)
|
@@ -19,7 +19,7 @@ module Olivander
|
|
19
19
|
Rails.logger.debug "initializing datatable for #{klazz}"
|
20
20
|
|
21
21
|
instance = klazz.new
|
22
|
-
klazz_attributes = instance.attributes.collect{ |x| x[0] }
|
22
|
+
klazz_attributes = instance.attributes.collect { |x| x[0] }
|
23
23
|
column_attributes = klazz_attributes
|
24
24
|
column_attributes &&= only if only.size.positive?
|
25
25
|
column_attributes -= except if except.size.positive?
|
@@ -64,7 +64,7 @@ module Olivander
|
|
64
64
|
order(order_by[0], order_by[1]) if order_by.size == 2
|
65
65
|
# bulk_actions_col if datatable._bulk_actions.size.positive?
|
66
66
|
|
67
|
-
#TODO: use columns from model here instead of attributes keys
|
67
|
+
# TODO: use columns from model here instead of attributes keys
|
68
68
|
column_attributes.each do |key|
|
69
69
|
label = field_label_for(klazz, key)
|
70
70
|
sym = key.gsub('_id', '')
|
@@ -76,7 +76,7 @@ module Olivander
|
|
76
76
|
col sym, visible: visible, action: :show
|
77
77
|
elsif sym.include?('.')
|
78
78
|
col sym, visible: visible, label: label
|
79
|
-
elsif klazz.columns.select{ |x| x.name == key }.first&.type == :boolean
|
79
|
+
elsif klazz.columns.select { |x| x.name == key }.first&.type == :boolean
|
80
80
|
col sym, visible: visible, label: label do |c|
|
81
81
|
val = c.send(sym)
|
82
82
|
icon_class = val ? 'fa-check text-success' : 'fa-times text-danger'
|
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.2.0.
|
4
|
+
version: 0.2.0.38
|
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-10-
|
11
|
+
date: 2024-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chartkick
|