avo 0.5.0.beta6 → 0.5.0.beta7
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of avo might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/app/controllers/avo/application_controller.rb +6 -1
- data/lib/avo/app.rb +20 -6
- data/lib/avo/base_resource.rb +3 -0
- data/lib/avo/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 48ae6c7207084645f7a7a14a462ebc7161f94801e100054d53f48722f758f9c2
|
4
|
+
data.tar.gz: dcc5caabc807328ddd1c52c640d446d88d84c58f786b693d59455f1e7d251744
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '038536c5cc11eeae399c9cbb59d366868bb3affe39592075c8852d65df49f1a362917a9e96861c804e807a6ed0e2cb39932e5bb82cb04d54b9830301a44b7056'
|
7
|
+
data.tar.gz: b9d16aa4a175c5a43a0ec24059e4715febc755cea5b28be601b0b9fb22f9414881ec170b6ad9e1dbe2e51a77d6b8d5cae7e620d8d1d7dc95c4c01c988f9f09ca
|
data/Gemfile.lock
CHANGED
@@ -155,7 +155,12 @@ module Avo
|
|
155
155
|
# Gets the Avo resource for this request based on the request from the `resource_name` "param"
|
156
156
|
# Ex: Avo::Resources::Project, Avo::Resources::Team, Avo::Resources::User
|
157
157
|
def resource
|
158
|
-
|
158
|
+
|
159
|
+
resource = App.get_resource @resource_name.to_s.camelize.singularize
|
160
|
+
|
161
|
+
return resource if resource.present?
|
162
|
+
|
163
|
+
App.get_resource_by_controller_name @resource_name
|
159
164
|
end
|
160
165
|
|
161
166
|
def related_resource
|
data/lib/avo/app.rb
CHANGED
@@ -122,7 +122,7 @@ module Avo
|
|
122
122
|
|
123
123
|
# Returns the Avo resource by camelized name
|
124
124
|
#
|
125
|
-
# get_resource_by_name('User') =>
|
125
|
+
# get_resource_by_name('User') => UserResource
|
126
126
|
def get_resource(resource)
|
127
127
|
self.app[:resources].find do |available_resource|
|
128
128
|
"#{resource}Resource".safe_constantize == available_resource.class
|
@@ -131,21 +131,31 @@ module Avo
|
|
131
131
|
|
132
132
|
# Returns the Avo resource by singular snake_cased name
|
133
133
|
#
|
134
|
-
# get_resource_by_name('user') =>
|
134
|
+
# get_resource_by_name('user') => UserResource
|
135
135
|
def get_resource_by_name(name)
|
136
136
|
self.get_resource name.singularize.camelize
|
137
137
|
end
|
138
138
|
|
139
139
|
# Returns the Avo resource by singular snake_cased name
|
140
140
|
#
|
141
|
-
# get_resource_by_name('User') =>
|
142
|
-
# get_resource_by_name(User) =>
|
141
|
+
# get_resource_by_name('User') => UserResource
|
142
|
+
# get_resource_by_name(User) => UserResource
|
143
143
|
def get_resource_by_model_name(name)
|
144
144
|
get_resources.find do |resource|
|
145
145
|
resource.model_class.model_name.name == name.to_s
|
146
146
|
end
|
147
147
|
end
|
148
148
|
|
149
|
+
# Returns the Avo resource by singular snake_cased name
|
150
|
+
#
|
151
|
+
# get_resource_by_controller_name('delayed_backend_active_record_jobs') => DelayedJobResource
|
152
|
+
# get_resource_by_controller_name('users') => UserResource
|
153
|
+
def get_resource_by_controller_name(name)
|
154
|
+
get_resources.find do |resource|
|
155
|
+
resource.model_class.to_s.pluralize.underscore.gsub('/', '_') == name.to_s
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
149
159
|
# Returns the Rails model class by singular snake_cased name
|
150
160
|
#
|
151
161
|
# get_model_class_by_name('user') => User
|
@@ -174,11 +184,15 @@ module Avo
|
|
174
184
|
Proc.new do
|
175
185
|
BaseResource.descendants
|
176
186
|
.select do |resource|
|
177
|
-
resource != :
|
187
|
+
resource != :BaseResource
|
178
188
|
end
|
179
189
|
.map do |resource|
|
180
190
|
if resource.is_a? Class
|
181
|
-
|
191
|
+
if resource.model_class.present?
|
192
|
+
route_key = resource.model_class.model_name.route_key
|
193
|
+
else
|
194
|
+
route_key = resource.to_s.underscore.gsub('_resource', '').downcase.pluralize.to_sym
|
195
|
+
end
|
182
196
|
|
183
197
|
resources route_key
|
184
198
|
end
|
data/lib/avo/base_resource.rb
CHANGED
@@ -11,6 +11,7 @@ module Avo
|
|
11
11
|
class_attribute :title, default: :id
|
12
12
|
class_attribute :search, default: [:id]
|
13
13
|
class_attribute :includes, default: []
|
14
|
+
class_attribute :model_class
|
14
15
|
class_attribute :translation_key
|
15
16
|
class_attribute :default_view_type, default: :table
|
16
17
|
class_attribute :devise_password_optional, default: false
|
@@ -158,6 +159,8 @@ module Avo
|
|
158
159
|
end
|
159
160
|
|
160
161
|
def model_class
|
162
|
+
return self.class.model_class if self.class.model_class.present?
|
163
|
+
|
161
164
|
return @model.class if @model.present?
|
162
165
|
|
163
166
|
self.class.name.demodulize.chomp('Resource').safe_constantize
|
data/lib/avo/version.rb
CHANGED