avo 2.24.0 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 60faee4dc37aadd6cd825e07a6b0f75cb99d7d11b49ecf2cebd8f88862dc1899
4
- data.tar.gz: 12aa335762c14fe85e18b61931dec31e97afa71a86c5f048a33d7f18fdec1201
3
+ metadata.gz: f44b08c9a7b54364ae4baf4d7f0947fd61de44b2cf92e1fc434ed93e7410ca4f
4
+ data.tar.gz: ad282ef2dfede35333d11dc090a059bc874bf8996c3dc991b5c939bf2dfa3dc9
5
5
  SHA512:
6
- metadata.gz: ac936588c00117a18bfb5515450c044787851fa95fde94e63f1d74ad7dfb3d1b7b1f72401764dd72ed0b7207e48e27aa3520663b1044377f9208f5b1707add7d
7
- data.tar.gz: bbb926db8935c89225a99a8e4f56cfce3d2f3e6c1a5fa5cfa234e8b99f0df7f6ad20c871bfe7a535e4be916eed6db2e0b279752302772665e9a847fe12c6958e
6
+ metadata.gz: 2cfea44f9fabc5835fc132591a486e18469b3a8757c28d9573254defa9b6890278b7e8c5b8b8fa1eb4dc695241b2c8f28620a56a460adc2b236c09e57ff32b0c
7
+ data.tar.gz: 47126c8a1194483bd615fcf694c3cbe1a74b3fee5e8fc8d11b1bfa1b83d8c6f0b437c5e424a1ddc3b67857b06d8aa7e5f28f6f36b254b7f28209212da2aa867f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- avo (2.24.0)
4
+ avo (2.25.0)
5
5
  actionview (>= 6.0)
6
6
  active_link_to
7
7
  activerecord (>= 6.0)
@@ -264,7 +264,7 @@ GEM
264
264
  nokogiri (1.13.10-x86_64-linux)
265
265
  racc (~> 1.4)
266
266
  orm_adapter (0.5.0)
267
- pagy (6.0.0)
267
+ pagy (6.0.1)
268
268
  parallel (1.22.1)
269
269
  parser (3.2.0.0)
270
270
  ast (~> 2.4.1)
@@ -407,7 +407,7 @@ GEM
407
407
  tzinfo (2.0.5)
408
408
  concurrent-ruby (~> 1.0)
409
409
  unicode-display_width (2.4.0)
410
- view_component (2.81.0)
410
+ view_component (2.82.0)
411
411
  activesupport (>= 5.2.0, < 8.0)
412
412
  concurrent-ruby (~> 1.0)
413
413
  method_source (~> 1.0)
@@ -44,7 +44,13 @@
44
44
  ""
45
45
  end
46
46
  %>
47
- <th class="text-left uppercase px-3 py-3 whitespace-nowrap rounded-l" data-control="resource-field-th">
47
+ <%= content_tag :th,
48
+ class: "text-left uppercase px-3 py-3 whitespace-nowrap rounded-l",
49
+ data: {
50
+ control: "resource-field-th",
51
+ table_header_field_id: field.id,
52
+ table_header_field_type: field.type,
53
+ } do %>
48
54
  <% if field.sortable %>
49
55
  <%= link_to params.permit!.merge(sort_by: sort_by, sort_direction: sort_direction), class: "flex items-center #{classes} #{'cursor-pointer' if field.sortable}", 'data-turbo-frame': params[:turbo_frame] do %>
50
56
  <%= field.name %>
@@ -55,7 +61,7 @@
55
61
  <%= field.name %>
56
62
  </div>
57
63
  <% end %>
58
- </th>
64
+ <% end %>
59
65
  <% end %>
60
66
  <% if Avo.configuration.resource_controls_on_the_right? %>
61
67
  <th class="w-24" data-control="resource-controls-th">
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 { [:closed, :rejected, :failed, :loading, :running, :waiting].sample }
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
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "2.24.0" unless const_defined?(:VERSION)
2
+ VERSION = "2.25.0" unless const_defined?(:VERSION)
3
3
  end
@@ -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.camelize.pluralize}Controller"
25
+ "Avo::#{class_name.remove(":").pluralize}Controller"
26
26
  end
27
27
 
28
28
  def resource_name
29
- "#{singular_name}_resource"
29
+ "#{model_resource_name}_resource"
30
30
  end
31
31
 
32
32
  def controller_name
33
- "#{plural_name}_controller"
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"]&.capitalize
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
- "\n self.model_class = ::#{class_from_args}" if class_from_args.present?
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.reject { |name, _| db_columns_to_ignore.include? name }
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] = associations_mapping[association.class]
159
-
160
- if association.is_a? ActiveRecord::Reflection::ThroughReflection
161
- fields[name][:options][:through] = ":#{association.options[:through]}"
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.24.0
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-17 00:00:00.000000000 Z
12
+ date: 2023-01-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord