five-two-nw-olivander 0.1.2.34 → 0.1.2.36
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 +17 -13
- data/app/helpers/olivander/application_helper.rb +2 -1
- data/app/views/application/_resource_form_actions.html.haml +10 -2
- data/app/views/effective/resource/_actions_dropleft.html.haml +2 -1
- 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: 3e55a54429f0d10d6f23e477b5615cb32f1c2cbbccbd6a622b73f2cb07b70131
|
4
|
+
data.tar.gz: 04d1f0ee790725256e7a65b93c20baf0c2199fe7c3dbfbc5b7f576f6decf93bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a9555b4ebbfdbd0d55df3c3a0ec03b7e48ccd0be00fd1c25700511ae2bc2085451d3d0d023bb340cd6b1a5a0e8131b3c58311dcd33c6befa2c195ead6cbcc34
|
7
|
+
data.tar.gz: dfb311cdc4987aaf562859af28e0d81d2beb944fe75fdfad53fede0045f42ffd925e6ebff562e72b0a4e9c57dff8e93068af88349be2923a14c430346cef7448
|
@@ -23,10 +23,11 @@ module Olivander
|
|
23
23
|
end
|
24
24
|
|
25
25
|
class RoutedResource
|
26
|
-
attr_accessor :model, :actions
|
26
|
+
attr_accessor :model, :namespaces, :actions
|
27
27
|
|
28
|
-
def initialize(model, crud_actions)
|
28
|
+
def initialize(model, namespaces, crud_actions)
|
29
29
|
self.model = model
|
30
|
+
self.namespaces = namespaces
|
30
31
|
self.actions = []
|
31
32
|
%i[index new create edit show update destroy].each do |ca|
|
32
33
|
next unless crud_actions.include?(ca)
|
@@ -90,8 +91,8 @@ module Olivander
|
|
90
91
|
end
|
91
92
|
|
92
93
|
class_methods do
|
93
|
-
def resource(model, only: DEFAULT_CRUD_ACTIONS, except: [], &block)
|
94
|
-
self.current_resource = RoutedResource.new(model, DEFAULT_CRUD_ACTIONS & (only - except))
|
94
|
+
def resource(model, only: DEFAULT_CRUD_ACTIONS, except: [], namespaces: [], &block)
|
95
|
+
self.current_resource = RoutedResource.new(model, namespaces, DEFAULT_CRUD_ACTIONS & (only - except))
|
95
96
|
yield if block_given?
|
96
97
|
resources[model] = current_resource
|
97
98
|
self.current_resource = nil
|
@@ -109,9 +110,7 @@ module Olivander
|
|
109
110
|
end
|
110
111
|
|
111
112
|
def build_routes(mapper)
|
112
|
-
|
113
|
-
build_resource_routes(mapper)
|
114
|
-
Rails.logger.info "...routes built"
|
113
|
+
build_resources_routes(mapper)
|
115
114
|
end
|
116
115
|
|
117
116
|
def set_controller_and_helper(a)
|
@@ -121,10 +120,19 @@ module Olivander
|
|
121
120
|
self.last_path_helper = a.path_helper
|
122
121
|
end
|
123
122
|
|
124
|
-
def
|
123
|
+
def build_resources_routes(mapper)
|
125
124
|
resources.keys.each do |k|
|
126
|
-
before_routes = Rails.application.routes.named_routes.helper_names
|
127
125
|
r = resources[k]
|
126
|
+
build_resource_route(mapper, r, r.namespaces)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
def build_resource_route(mapper, r, namespaces)
|
131
|
+
if namespaces.size.positive?
|
132
|
+
mapper.namespace namespaces.first do
|
133
|
+
build_resource_route(mapper, r, r.namespaces.last(r.namespaces.size - 1))
|
134
|
+
end
|
135
|
+
else
|
128
136
|
mapper.resources r.model, only: [] do
|
129
137
|
mapper.collection do
|
130
138
|
r.collection_actions.each do |ba|
|
@@ -160,10 +168,6 @@ module Olivander
|
|
160
168
|
end
|
161
169
|
end
|
162
170
|
end
|
163
|
-
after_routes = Rails.application.routes.named_routes.helper_names
|
164
|
-
net_routes = after_routes - before_routes
|
165
|
-
# Rails.logger.info "added these route helpers:\n#{net_routes}"
|
166
|
-
# binding.pry if k == :projects
|
167
171
|
end
|
168
172
|
end
|
169
173
|
end
|
@@ -45,7 +45,8 @@ module Olivander
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def resource_form_action_label(resource, action)
|
48
|
-
|
48
|
+
key = resource.class.name.underscore
|
49
|
+
return I18n.t("activerecord.actions.#{key}.#{action}") if I18n.exists?("activerecord.actions.#{key}.#{action}")
|
49
50
|
return I18n.t("activerecord.actions.#{action}") if I18n.exists?("activerecord.actions.#{action}")
|
50
51
|
|
51
52
|
action.to_s.titleize
|
@@ -1,7 +1,15 @@
|
|
1
|
-
- actions.
|
2
|
-
=
|
1
|
+
- actions.each_with_index do |a, idx|
|
2
|
+
- cf_sym = "link_inner#{idx}".to_sym
|
3
|
+
= content_for cf_sym do
|
3
4
|
- icon_key = "activerecord.actions.icons.#{a.sym}"
|
4
5
|
- if I18n.exists?(icon_key)
|
5
6
|
%i.fa{ class: I18n.t(icon_key)}
|
6
7
|
= resource_form_action_label(@resource, a.sym)
|
8
|
+
|
9
|
+
- if a.turbo_frame.blank?
|
10
|
+
= link_to({ controller: a.controller, action: a.action }, method: a.verb, class: 'btn btn-tool') do
|
11
|
+
= yield cf_sym
|
12
|
+
- else
|
13
|
+
= 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
|
14
|
+
= yield cf_sym
|
7
15
|
|
@@ -2,4 +2,5 @@
|
|
2
2
|
= dropdown(variation: :dropleft, btn_class: btn_class) do
|
3
3
|
- authorized_resource_actions(route_builder, resource, for_action: action_name).select{ |x| x.show_in_datatable }.each do |a|
|
4
4
|
- path = a.path_helper.is_a?(Proc) ? a.path_helper.call(resource) : send(a.path_helper, resource.id)
|
5
|
-
=
|
5
|
+
- data = a.turbo_frame.present? ? { turbo: true, turbo_frame: a.turbo_frame } : {}
|
6
|
+
= dropdown_link_to resource_form_action_label(resource, a.sym), path, data: data
|
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.36
|
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-08-
|
11
|
+
date: 2023-08-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chartkick
|