five-two-nw-olivander 0.1.2.35 → 0.1.2.37
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/components/olivander/components/table_portlet_component.rb +1 -0
- data/app/controllers/concerns/olivander/resources/route_builder.rb +17 -13
- data/app/datatables/olivander/datatable.rb +7 -1
- data/app/helpers/olivander/application_helper.rb +2 -1
- 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: bd2984fed303415434608a19eadfc7da16727e43434b67119ca9732797ad24c7
|
4
|
+
data.tar.gz: b3c3ad917a5069422bef3b3ee6de9fd7654c5b6b6687af5edce67c49daee2866
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f07b08a5271fd1d723a615718a85199e490c0c20e81ed8d6fcd34005730256b5f0e5a2983424c01443c306b5a9bbec70c951e2dc43930ff31ee564eee24ff6e3
|
7
|
+
data.tar.gz: bafbc5827b23d23748b8ef259cff09b7febf0e8b5d6c7920bace1ca8315c150bddd821468355252b29fa3b87faa6c1f720617ea2a08b388d9fc6461e0651151e
|
@@ -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
|
@@ -15,7 +15,7 @@ module Olivander
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
def self.auto_datatable(klazz, collection: nil, link_path: nil, only: [], except: [], hide: [], show: [], order_by: [])
|
18
|
+
def self.auto_datatable(klazz, collection: nil, link_path: nil, only: [], except: [], hide: [], show: [], order_by: [], scopes: [])
|
19
19
|
Rails.logger.debug "initializing datatable for #{klazz}"
|
20
20
|
|
21
21
|
klazz_attributes = klazz.new.attributes.collect{ |x| x[0] }
|
@@ -27,6 +27,12 @@ module Olivander
|
|
27
27
|
|
28
28
|
default_hidden = %w[id created updated created_at updated_at deleted_at current_user current_action]
|
29
29
|
|
30
|
+
filters do
|
31
|
+
scopes.each do |s|
|
32
|
+
scope s
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
30
36
|
collection do
|
31
37
|
dc = collection.nil? ? klazz.all : collection
|
32
38
|
|
@@ -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
|
@@ -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.37
|
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-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chartkick
|