avo 2.24.1 → 2.25.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.lock +1 -1
- data/db/factories.rb +1 -1
- data/lib/avo/fields/status_field.rb +2 -2
- data/lib/avo/version.rb +1 -1
- data/lib/generators/avo/resource_generator.rb +29 -17
- data/lib/generators/avo/templates/initializer/avo.tt +5 -3
- 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: f44b08c9a7b54364ae4baf4d7f0947fd61de44b2cf92e1fc434ed93e7410ca4f
|
4
|
+
data.tar.gz: ad282ef2dfede35333d11dc090a059bc874bf8996c3dc991b5c939bf2dfa3dc9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2cfea44f9fabc5835fc132591a486e18469b3a8757c28d9573254defa9b6890278b7e8c5b8b8fa1eb4dc695241b2c8f28620a56a460adc2b236c09e57ff32b0c
|
7
|
+
data.tar.gz: 47126c8a1194483bd615fcf694c3cbe1a74b3fee5e8fc8d11b1bfa1b83d8c6f0b437c5e424a1ddc3b67857b06d8aa7e5f28f6f36b254b7f28209212da2aa867f
|
data/Gemfile.lock
CHANGED
data/db/factories.rb
CHANGED
@@ -31,7 +31,7 @@ FactoryBot.define do
|
|
31
31
|
|
32
32
|
factory :project do
|
33
33
|
name { Faker::App.name }
|
34
|
-
status { [
|
34
|
+
status { ['closed', :rejected, :failed, 'loading', :running, :waiting].sample }
|
35
35
|
stage { ["Discovery", "Idea", "Done", "On hold", "Cancelled"].sample }
|
36
36
|
budget { Faker::Number.decimal(l_digits: 4) }
|
37
37
|
country { Faker::Address.country_code }
|
@@ -4,8 +4,8 @@ module Avo
|
|
4
4
|
def initialize(id, **args, &block)
|
5
5
|
super(id, **args, &block)
|
6
6
|
|
7
|
-
@loading_when = args[:loading_when].present? ? [args[:loading_when]].flatten : [:waiting, :running]
|
8
|
-
@failed_when = args[:failed_when].present? ? [args[:failed_when]].flatten : [:failed]
|
7
|
+
@loading_when = args[:loading_when].present? ? [args[:loading_when]].flatten.map(&:to_sym) : [:waiting, :running]
|
8
|
+
@failed_when = args[:failed_when].present? ? [args[:failed_when]].flatten.map(&:to_sym) : [:failed]
|
9
9
|
end
|
10
10
|
|
11
11
|
def status
|
data/lib/avo/version.rb
CHANGED
@@ -18,19 +18,19 @@ module Generators
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def resource_class
|
21
|
-
"#{class_name}Resource"
|
21
|
+
"#{class_name.remove(":")}Resource"
|
22
22
|
end
|
23
23
|
|
24
24
|
def controller_class
|
25
|
-
"Avo::#{class_name.
|
25
|
+
"Avo::#{class_name.remove(":").pluralize}Controller"
|
26
26
|
end
|
27
27
|
|
28
28
|
def resource_name
|
29
|
-
"#{
|
29
|
+
"#{model_resource_name}_resource"
|
30
30
|
end
|
31
31
|
|
32
32
|
def controller_name
|
33
|
-
"#{
|
33
|
+
"#{model_resource_name.pluralize}_controller"
|
34
34
|
end
|
35
35
|
|
36
36
|
def current_models
|
@@ -40,11 +40,13 @@ module Generators
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def class_from_args
|
43
|
-
@class_from_args ||= options["model-class"]&.
|
43
|
+
@class_from_args ||= options["model-class"]&.camelize || (class_name if class_name.include?("::"))
|
44
44
|
end
|
45
45
|
|
46
46
|
def model_class_from_args
|
47
|
-
|
47
|
+
if class_from_args.present? || class_name.include?("::")
|
48
|
+
"\n self.model_class = ::#{class_from_args || class_name}"
|
49
|
+
end
|
48
50
|
end
|
49
51
|
|
50
52
|
private
|
@@ -58,7 +60,7 @@ module Generators
|
|
58
60
|
end
|
59
61
|
|
60
62
|
def model_db_columns
|
61
|
-
@model_db_columns ||= model.columns_hash.
|
63
|
+
@model_db_columns ||= model.columns_hash.except(*db_columns_to_ignore)
|
62
64
|
end
|
63
65
|
|
64
66
|
def db_columns_to_ignore
|
@@ -155,14 +157,30 @@ module Generators
|
|
155
157
|
|
156
158
|
def fields_from_model_associations
|
157
159
|
associations.each do |name, association|
|
158
|
-
fields[name] =
|
159
|
-
|
160
|
-
|
161
|
-
|
160
|
+
fields[name] = if association.is_a? ActiveRecord::Reflection::ThroughReflection
|
161
|
+
field_from_through_association(association)
|
162
|
+
else
|
163
|
+
associations_mapping[association.class]
|
162
164
|
end
|
163
165
|
end
|
164
166
|
end
|
165
167
|
|
168
|
+
def field_from_through_association(association)
|
169
|
+
if association.through_reflection.is_a? ActiveRecord::Reflection::HasManyReflection
|
170
|
+
{
|
171
|
+
field: "has_many",
|
172
|
+
options: {
|
173
|
+
through: ":#{association.options[:through]}"
|
174
|
+
}
|
175
|
+
}
|
176
|
+
else
|
177
|
+
# If the through_reflection is not a HasManyReflection, add it to the fields hash using the class of the through_reflection
|
178
|
+
# ex (team.rb): has_one :admin, through: :admin_membership, source: :user
|
179
|
+
# we use the class of the through_reflection (HasOneReflection -> has_one :admin) to generate the field
|
180
|
+
associations_mapping[association.through_reflection.class]
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
166
184
|
def fields_from_model_attachements
|
167
185
|
attachments.each do |name, attachment|
|
168
186
|
fields[remove_last_word_from name] = attachments_mapping[attachment.class]
|
@@ -210,12 +228,6 @@ module Generators
|
|
210
228
|
ActiveRecord::Reflection::HasManyReflection => {
|
211
229
|
field: "has_many"
|
212
230
|
},
|
213
|
-
ActiveRecord::Reflection::ThroughReflection => {
|
214
|
-
field: "has_many",
|
215
|
-
options: {
|
216
|
-
through: ":..."
|
217
|
-
}
|
218
|
-
},
|
219
231
|
ActiveRecord::Reflection::HasAndBelongsToManyReflection => {
|
220
232
|
field: "has_and_belongs_to_many"
|
221
233
|
}
|
@@ -17,7 +17,8 @@ Avo.configure do |config|
|
|
17
17
|
|
18
18
|
## == Authentication ==
|
19
19
|
# config.current_user_method = {}
|
20
|
-
# config.authenticate_with
|
20
|
+
# config.authenticate_with do
|
21
|
+
# end
|
21
22
|
|
22
23
|
## == Authorization ==
|
23
24
|
# config.authorization_methods = {
|
@@ -76,8 +77,9 @@ Avo.configure do |config|
|
|
76
77
|
# },
|
77
78
|
# chart_colors: ["#0B8AE2", "#34C683", "#2AB1EE", "#34C6A8"],
|
78
79
|
# logo: "/avo-assets/logo.png",
|
79
|
-
# logomark: "/avo-assets/logomark.png"
|
80
|
-
# placeholder: "/avo-assets/placeholder.svg"
|
80
|
+
# logomark: "/avo-assets/logomark.png",
|
81
|
+
# placeholder: "/avo-assets/placeholder.svg",
|
82
|
+
# favicon: "/avo-assets/favicon.ico"
|
81
83
|
# }
|
82
84
|
|
83
85
|
## == Breadcrumbs ==
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: avo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.25.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adrian Marin
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-01-
|
12
|
+
date: 2023-01-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|