avo 2.37.0 → 2.37.1

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: d162fb0b1c274b27a2c4e185bbc058e1e6ad2984454ebf01249701259e802eba
4
- data.tar.gz: bcf8ba5a7c30007bfa696537797d04a10517a9cc7b8ce8e3aaec018101250290
3
+ metadata.gz: 23ddc6ba1d200de7c9597eb8aeb0d52b82f18f9321d859dd4f2089dfc11e7991
4
+ data.tar.gz: 8825e4520ec2c6792c3b34de9be0658cc13e4fa13bdd15e1c2930719ae98391a
5
5
  SHA512:
6
- metadata.gz: f760ec5a9acf707e9c5113ee747985cf87998a88dd3bd085fcccd37703621fce0fb57bbab43bc2d0c03196dea78a3fb8b3ebb1a228c11e1c6072b2c691f99d95
7
- data.tar.gz: 6f9544cd72a2b94e33254a0c359801d8a3eb6e23fe17ca42ad746614f14fee2d1c3ea838538a39e79092e0647c5e7bb3668d28cd10f1bf11eb719a9861a2e37f
6
+ metadata.gz: 9e0d26ced1c8bbfdb1d1c29a90e8c11ff86e038d58f985f06b2241888416b1c2d4ab13a8179229bcf39af94861b591804616312342e06ed069cd1bbdb6fb4f21
7
+ data.tar.gz: b2be4690bf39bee8d27fa064393b91431b38476022610e084e5f625890abd563669009d043ca9b56f57c21671ecb7c63eb7040629b3bc23c5b501b1429ff1c71
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- avo (2.37.0)
4
+ avo (2.37.1)
5
5
  actionview (>= 6.0)
6
6
  active_link_to
7
7
  activerecord (>= 6.0)
@@ -422,7 +422,7 @@ GEM
422
422
  tzinfo (2.0.6)
423
423
  concurrent-ruby (~> 1.0)
424
424
  unicode-display_width (2.4.0)
425
- view_component (3.4.0)
425
+ view_component (3.5.0)
426
426
  activesupport (>= 5.2.0, < 8.0)
427
427
  concurrent-ruby (~> 1.0)
428
428
  method_source (~> 1.0)
@@ -9,7 +9,7 @@
9
9
  <%= link_to helpers.svg('eye', class: button_classes),
10
10
  show_path,
11
11
  class: 'flex items-center',
12
- title: t('avo.view_item', item: singular_resource_name).capitalize,
12
+ title: t('avo.view_item', item: singular_resource_name).humanize,
13
13
  data: {
14
14
  target: 'control:view',
15
15
  control: :show,
@@ -22,7 +22,7 @@
22
22
  <%= link_to helpers.svg('edit', class: button_classes),
23
23
  edit_path,
24
24
  class: 'flex items-center',
25
- title: t('avo.edit_item', item: singular_resource_name).capitalize,
25
+ title: t('avo.edit_item', item: singular_resource_name).humanize,
26
26
  data: {
27
27
  target: 'control:edit',
28
28
  control: :edit,
@@ -41,7 +41,7 @@
41
41
  'data-turbo-frame': params[:turbo_frame]
42
42
  } do |form| %>
43
43
  <%= form.button helpers.svg('detach', class: button_classes),
44
- title: t('avo.detach_item', item: singular_resource_name).capitalize,
44
+ title: t('avo.detach_item', item: singular_resource_name).humanize,
45
45
  type: :submit,
46
46
  data: {
47
47
  target: 'control:detach',
@@ -65,7 +65,7 @@
65
65
  'data-turbo-frame': params[:turbo_frame]
66
66
  } do |form| %>
67
67
  <%= form.button helpers.svg('trash', class: button_classes),
68
- title: t('avo.delete_item', item: singular_resource_name).capitalize,
68
+ title: t('avo.delete_item', item: singular_resource_name).humanize,
69
69
  type: :submit,
70
70
  data: {
71
71
  target: 'control:destroy',
@@ -10,10 +10,7 @@ class Avo::Index::ResourceControlsComponent < Avo::ResourceComponent
10
10
  end
11
11
 
12
12
  def can_detach?
13
- @reflection.present? &&
14
- @resource.model.present? &&
15
- is_has_many_association &&
16
- authorize_association_for(:detach)
13
+ is_has_many_association? ? super : false
17
14
  end
18
15
 
19
16
  def can_edit?
@@ -79,7 +76,7 @@ class Avo::Index::ResourceControlsComponent < Avo::ResourceComponent
79
76
  ::Avo::App.get_resource_by_model_name @parent_model.class
80
77
  end
81
78
 
82
- def is_has_many_association
79
+ def is_has_many_association?
83
80
  @reflection.is_a?(::ActiveRecord::Reflection::HasManyReflection) || @reflection.is_a?(::ActiveRecord::Reflection::ThroughReflection)
84
81
  end
85
82
 
@@ -36,6 +36,11 @@
36
36
  <%= sidebar %>
37
37
  </div>
38
38
  <% end %>
39
+ <% if bare_sidebar? %>
40
+ <div class="w-full sm:w-1/3 flex-shrink-0 h-full">
41
+ <%= bare_sidebar %>
42
+ </div>
43
+ <% end %>
39
44
  </div>
40
45
  <% end %>
41
46
  <% if bare_content? %>
@@ -10,6 +10,7 @@ class Avo::PanelComponent < ViewComponent::Base
10
10
  renders_one :tools
11
11
  renders_one :body
12
12
  renders_one :sidebar
13
+ renders_one :bare_sidebar
13
14
  renders_one :bare_content
14
15
  renders_one :footer_tools
15
16
  renders_one :footer
@@ -20,7 +20,14 @@ class Avo::ResourceComponent < Avo::BaseComponent
20
20
  end
21
21
 
22
22
  def can_detach?
23
- authorize_association_for(:detach)
23
+ return false if @reflection.blank? || @resource.model.blank? || !authorize_association_for(:detach)
24
+
25
+ # If the inverse_of is a belongs_to, we need to check if it's optional in order to know if we can detach it.
26
+ if inverse_of.is_a?(ActiveRecord::Reflection::BelongsToReflection)
27
+ inverse_of.options[:optional]
28
+ else
29
+ true
30
+ end
24
31
  end
25
32
 
26
33
  def detach_path
@@ -136,4 +143,19 @@ class Avo::ResourceComponent < Avo::BaseComponent
136
143
 
137
144
  item&.hydrate(view: view)
138
145
  end
146
+
147
+ def inverse_of
148
+ current_reflection = @reflection.active_record.reflect_on_all_associations.find do |reflection|
149
+ reflection.name == @reflection.name.to_sym
150
+ end
151
+
152
+ inverse_of = current_reflection.inverse_of
153
+
154
+ if inverse_of.blank?
155
+ # Please configure the 'inverse_of' option for the ':users' association on the 'Project' model.
156
+ raise "Please configure the 'inverse_of' option for the '#{current_reflection.macro} :#{current_reflection.name}' association on the '#{current_reflection.active_record.name}' model."
157
+ end
158
+
159
+ inverse_of
160
+ end
139
161
  end
@@ -13,7 +13,7 @@
13
13
  style: :text,
14
14
  'data-turbo-frame': 'attach_modal',
15
15
  'data-target': 'attach' do %>
16
- <%= t('avo.attach_item', item: singular_resource_name).capitalize %>
16
+ <%= t('avo.attach_item', item: singular_resource_name).humanize %>
17
17
  <% end %>
18
18
  <% end %>
19
19
  <% if can_act_on? %>
@@ -25,7 +25,7 @@
25
25
  'data-target': 'create',
26
26
  style: :primary,
27
27
  color: :primary do %>
28
- <%= t('avo.create_new_item', item: singular_resource_name.downcase ) %>
28
+ <%= t('avo.create_new_item', item: singular_resource_name.humanize(capitalize: false) ) %>
29
29
  <% end %>
30
30
  <% end %>
31
31
  <% end %>
@@ -109,7 +109,7 @@
109
109
  data: {
110
110
  confirm: "Are you sure you want to detach this #{title}."
111
111
  } do %>
112
- <%= t('avo.detach_item', item: title).capitalize %>
112
+ <%= t('avo.detach_item', item: title).humanize %>
113
113
  <% end %>
114
114
  <% end %>
115
115
  <%= render Avo::ActionsComponent.new actions: @actions, resource: @resource, view: @view %>
@@ -55,7 +55,7 @@ module Avo
55
55
  model: @model,
56
56
  resource: @resource,
57
57
  user: _current_user,
58
- view: @view,
58
+ view: :new, # force the action view to in order to render new-related fields (hidden field)
59
59
  arguments: @resource.get_action_arguments(action_class)
60
60
  )
61
61
  end
@@ -81,7 +81,7 @@ module Avo
81
81
  association_name = BaseResource.valid_association_name(@model, params[:related_name])
82
82
 
83
83
  if reflection_class == "HasManyReflection"
84
- @model.send(association_name).delete @attachment_model
84
+ @model.send(association_name).destroy @attachment_model
85
85
  else
86
86
  @model.send("#{association_name}=", nil)
87
87
  end
@@ -263,7 +263,7 @@ module Avo
263
263
  return @name if @name.present?
264
264
 
265
265
  if translation_key && ::Avo::App.translation_enabled
266
- t(translation_key, count: 1, default: default).capitalize
266
+ t(translation_key, count: 1, default: default).humanize
267
267
  else
268
268
  default
269
269
  end
@@ -277,7 +277,7 @@ module Avo
277
277
  default = name.pluralize
278
278
 
279
279
  if translation_key && ::Avo::App.translation_enabled
280
- t(translation_key, count: 2, default: default).capitalize
280
+ t(translation_key, count: 2, default: default).humanize
281
281
  else
282
282
  default
283
283
  end
@@ -124,7 +124,7 @@ module Avo
124
124
  return @name if custom_name?
125
125
 
126
126
  if translation_key && ::Avo::App.translation_enabled
127
- t(translation_key, count: 1, default: default_name).capitalize
127
+ t(translation_key, count: 1, default: default_name).humanize
128
128
  else
129
129
  default_name
130
130
  end
@@ -134,7 +134,7 @@ module Avo
134
134
  default = name.pluralize
135
135
 
136
136
  if translation_key && ::Avo::App.translation_enabled
137
- t(translation_key, count: 2, default: default).capitalize
137
+ t(translation_key, count: 2, default: default).humanize
138
138
  else
139
139
  default
140
140
  end
@@ -5,7 +5,7 @@ module Avo
5
5
  def initialize(**args)
6
6
  super(**args)
7
7
 
8
- @label = I18n.t("avo.detach_item", item: title).capitalize
8
+ @label = I18n.t("avo.detach_item", item: title).humanize
9
9
  end
10
10
  end
11
11
  end
data/lib/avo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "2.37.0" unless const_defined?(:VERSION)
2
+ VERSION = "2.37.1" unless const_defined?(:VERSION)
3
3
  end
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.37.0
4
+ version: 2.37.1
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-07-18 00:00:00.000000000 Z
12
+ date: 2023-07-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord