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 +4 -4
- data/Gemfile.lock +2 -2
- data/app/components/avo/index/resource_controls_component.html.erb +4 -4
- data/app/components/avo/index/resource_controls_component.rb +2 -5
- data/app/components/avo/panel_component.html.erb +5 -0
- data/app/components/avo/panel_component.rb +1 -0
- data/app/components/avo/resource_component.rb +23 -1
- data/app/components/avo/views/resource_index_component.html.erb +2 -2
- data/app/components/avo/views/resource_show_component.html.erb +1 -1
- data/app/controllers/avo/actions_controller.rb +1 -1
- data/app/controllers/avo/associations_controller.rb +1 -1
- data/lib/avo/base_resource.rb +2 -2
- data/lib/avo/fields/base_field.rb +2 -2
- data/lib/avo/resources/controls/detach_button.rb +1 -1
- data/lib/avo/version.rb +1 -1
- 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: 23ddc6ba1d200de7c9597eb8aeb0d52b82f18f9321d859dd4f2089dfc11e7991
|
4
|
+
data.tar.gz: 8825e4520ec2c6792c3b34de9be0658cc13e4fa13bdd15e1c2930719ae98391a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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.
|
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).
|
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).
|
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).
|
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).
|
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
|
-
|
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
|
|
@@ -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).
|
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.
|
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).
|
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 %>
|
@@ -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).
|
84
|
+
@model.send(association_name).destroy @attachment_model
|
85
85
|
else
|
86
86
|
@model.send("#{association_name}=", nil)
|
87
87
|
end
|
data/lib/avo/base_resource.rb
CHANGED
@@ -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).
|
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).
|
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).
|
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).
|
137
|
+
t(translation_key, count: 2, default: default).humanize
|
138
138
|
else
|
139
139
|
default
|
140
140
|
end
|
data/lib/avo/version.rb
CHANGED
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.
|
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-
|
12
|
+
date: 2023-07-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|