five-two-nw-olivander 0.1.2.3 → 0.1.2.4
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d551785ee277728e208fb537527d00e201b93b89f796de075295f271c90ff879
|
4
|
+
data.tar.gz: f079e183a76a7724c16099542aeaef9159f5d4ff64ef227267a8de6dcd03b7c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1abaa3d2a03cb74f5d38077e2070a90ca63a12f27799a6d000fdb3506272c9890b284fbc76a59049bd1b5fe1766d51f11658f96fe28298baf83e80ab7436719e
|
7
|
+
data.tar.gz: dadd557fabc44933a35bf795173c37d3753b7f40cfae8fa2979978923b78312904e96c8a66e12da01a46fbb24917f22476a5ca72ea815f7358f56fc7766a6a90
|
@@ -17,18 +17,18 @@ module Olivander
|
|
17
17
|
"avatar#{SecureRandom.random_number(4)}.png"
|
18
18
|
end
|
19
19
|
|
20
|
-
def authorized_resource_actions(resource, for_action: :show)
|
20
|
+
def authorized_resource_actions(route_builder, resource, for_action: :show)
|
21
21
|
plural_name = resource.is_a?(Class) ? resource.table_name : resource.class.table_name
|
22
|
-
routed_resource =
|
22
|
+
routed_resource = route_builder.resources[plural_name.to_sym]
|
23
23
|
actions = resource.is_a?(Class) ?
|
24
24
|
(routed_resource.unpersisted_crud_actions | routed_resource.collection_actions) :
|
25
25
|
(resource.persisted? ? (routed_resource.persisted_crud_actions | routed_resource.member_actions): [])
|
26
26
|
actions.reject{ |a| a.sym == for_action }
|
27
27
|
end
|
28
28
|
|
29
|
-
def resource_form_actions(resource, for_action: :show)
|
29
|
+
def resource_form_actions(route_builder, resource, for_action: :show)
|
30
30
|
[].tap do |output|
|
31
|
-
authorized_resource_actions(resource, for_action: for_action).select{ |x| x.show_in_form }.each do |a|
|
31
|
+
authorized_resource_actions(route_builder, resource, for_action: for_action).select{ |x| x.show_in_form }.each do |a|
|
32
32
|
output << link_to(a.sym, {controller: a.controller, action: a.action}, method: a.verb, class: 'btn btn-primary', data: { turbo: true })
|
33
33
|
end
|
34
34
|
end.join(' ').html_safe
|
@@ -3,7 +3,7 @@
|
|
3
3
|
.card
|
4
4
|
.card-header
|
5
5
|
.card-tools
|
6
|
-
= resource_form_actions(@resource, for_action: action_name.to_sym)
|
6
|
+
= resource_form_actions(@context.route_builder, @resource, for_action: action_name.to_sym)
|
7
7
|
.card-body
|
8
8
|
=f.error_notification
|
9
9
|
=f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present?
|
@@ -6,7 +6,7 @@
|
|
6
6
|
.card-header
|
7
7
|
%h3.card-title= @page_title
|
8
8
|
.card-tools
|
9
|
-
= resource_form_actions(resource.klass, for_action: :index)
|
9
|
+
= resource_form_actions(@context.route_builder, resource.klass, for_action: :index)
|
10
10
|
.card-body
|
11
11
|
- if @datatable
|
12
12
|
= render_datatable(@datatable)
|
data/lib/olivander/version.rb
CHANGED