avo 1.18.1 → 1.18.2.pre.0
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 +3 -1
- data/Gemfile.lock +195 -167
- data/app/components/avo/index/resource_controls_component.rb +1 -1
- data/app/components/avo/views/resource_edit_component.html.erb +1 -1
- data/app/controllers/avo/application_controller.rb +5 -19
- data/app/helpers/avo/application_helper.rb +18 -0
- data/db/factories.rb +9 -0
- data/lib/avo/base_resource.rb +9 -2
- data/lib/avo/version.rb +1 -1
- data/public/avo-packs/css/application-f9191617.css.map +1 -1
- data/public/avo-packs/css/application-f9191617.css.map.br +0 -0
- data/public/avo-packs/css/application-f9191617.css.map.gz +0 -0
- data/public/avo-packs/js/application-cc89f096028eb1d4d971.js.map +1 -1
- data/public/avo-packs/js/application-cc89f096028eb1d4d971.js.map.br +0 -0
- data/public/avo-packs/js/application-cc89f096028eb1d4d971.js.map.gz +0 -0
- metadata +5 -5
@@ -154,5 +154,23 @@ module Avo
|
|
154
154
|
|
155
155
|
classes
|
156
156
|
end
|
157
|
+
|
158
|
+
def get_model_class(model)
|
159
|
+
if model.instance_of?(Class)
|
160
|
+
model
|
161
|
+
else
|
162
|
+
model.class.base_class
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
def singular_name(model_or_class)
|
167
|
+
model_class = get_model_class model_or_class
|
168
|
+
|
169
|
+
if ActiveModel::Naming.uncountable? model_class
|
170
|
+
model_class.base_class.model_name.route_key.singularize.gsub('_index', '')
|
171
|
+
else
|
172
|
+
model_class.base_class.model_name.route_key.singularize
|
173
|
+
end
|
174
|
+
end
|
157
175
|
end
|
158
176
|
end
|
data/db/factories.rb
CHANGED
@@ -44,4 +44,13 @@ FactoryBot.define do
|
|
44
44
|
factory :comment do
|
45
45
|
body { Faker::Lorem.paragraphs(number: rand(4...10)).join("\n") }
|
46
46
|
end
|
47
|
+
|
48
|
+
factory :person do
|
49
|
+
name { "#{Faker::Name.first_name} #{Faker::Name.last_name}" }
|
50
|
+
end
|
51
|
+
|
52
|
+
factory :spouse do
|
53
|
+
name { "#{Faker::Name.first_name} #{Faker::Name.last_name}" }
|
54
|
+
type { "Spouse" }
|
55
|
+
end
|
47
56
|
end
|
data/lib/avo/base_resource.rb
CHANGED
@@ -74,7 +74,7 @@ module Avo
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def initialize
|
77
|
-
self.class.model_class = model_class
|
77
|
+
self.class.model_class = model_class.base_class
|
78
78
|
end
|
79
79
|
|
80
80
|
def hydrate(model: nil, view: nil, user: nil, params: nil)
|
@@ -198,10 +198,13 @@ module Avo
|
|
198
198
|
end
|
199
199
|
|
200
200
|
def model_class
|
201
|
+
# get the model class off of the static property
|
201
202
|
return self.class.model_class if self.class.model_class.present?
|
202
203
|
|
203
|
-
|
204
|
+
# get the model class off of the model
|
205
|
+
return @model.base_class if @model.present?
|
204
206
|
|
207
|
+
# generate a model class
|
205
208
|
class_name_without_resource.safe_constantize
|
206
209
|
end
|
207
210
|
|
@@ -410,5 +413,9 @@ module Avo
|
|
410
413
|
rescue
|
411
414
|
nil
|
412
415
|
end
|
416
|
+
|
417
|
+
def form_scope
|
418
|
+
model.class.base_class.to_s.downcase
|
419
|
+
end
|
413
420
|
end
|
414
421
|
end
|
data/lib/avo/version.rb
CHANGED