avo 3.0.0.pre16 → 3.0.0.pre18
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/app/components/avo/fields/has_one_field/show_component.html.erb +2 -2
- data/app/components/avo/index/resource_controls_component.rb +2 -5
- data/app/components/avo/modal_component.html.erb +1 -1
- 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 +26 -2
- data/app/components/avo/sidebar_component.rb +1 -1
- data/app/controllers/avo/actions_controller.rb +3 -2
- data/app/controllers/avo/associations_controller.rb +1 -1
- data/lib/avo/base_action.rb +6 -3
- data/lib/avo/base_resource.rb +3 -3
- data/lib/avo/fields/base_field.rb +2 -2
- data/lib/avo/resources/controls/create_button.rb +1 -1
- data/lib/avo/resources/controls/delete_button.rb +1 -1
- data/lib/avo/resources/controls/detach_button.rb +1 -1
- data/lib/avo/resources/controls/edit_button.rb +1 -1
- data/lib/avo/resources/controls/show_button.rb +1 -1
- data/lib/avo/version.rb +1 -1
- data/public/avo-assets/avo.base.js +89 -89
- data/public/avo-assets/avo.base.js.map +2 -2
- 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: a9c50d4849e253d4fbdd7aa6213feb651e764efe5cf5e4b34341f2dde7b7de18
|
4
|
+
data.tar.gz: 6c4a2d98de7136f1f2d4282c05870c1d2a92f2b2c56facc37c9cdf80a25a3cc7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02bcdcf818e190b9e6aa03c638f8bec67525ff4418e5c55e4f8eb4613cea9107a5151b4254a78e1c219881c1a3d1faa0cb4bacf8f38677ccfd194f434080e67f
|
7
|
+
data.tar.gz: b6ce2f86cbc6749edad03a442dc8c5b7c70de454845ea84754f66ac2b549af0be8b8def02abd538d1372a600264c7da1cf36e7183ec9f29c294be448ed9f0c3d
|
data/Gemfile.lock
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
color: :primary,
|
12
12
|
style: :text,
|
13
13
|
'data-turbo-frame': 'attach_modal' do %>
|
14
|
-
<%= t('avo.attach_item', item: @field.name.
|
14
|
+
<%= t('avo.attach_item', item: @field.name.humanize(capitalize: false)) %>
|
15
15
|
<% end %>
|
16
16
|
<% end %>
|
17
17
|
<% if !@field.is_readonly? && !@field.is_disabled? && can_see_the_create_button? %>
|
@@ -21,7 +21,7 @@
|
|
21
21
|
'data-turbo-frame': '_top',
|
22
22
|
style: :primary,
|
23
23
|
color: :primary do %>
|
24
|
-
<%= t('avo.create_new_item', item: @field.name.
|
24
|
+
<%= t('avo.create_new_item', item: @field.name.humanize(capitalize: false) ) %>
|
25
25
|
<% end %>
|
26
26
|
<% end %>
|
27
27
|
<% end %>
|
@@ -13,10 +13,7 @@ class Avo::Index::ResourceControlsComponent < Avo::ResourceComponent
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def can_detach?
|
16
|
-
|
17
|
-
@resource.record.present? &&
|
18
|
-
is_has_many_association &&
|
19
|
-
authorize_association_for(:detach)
|
16
|
+
is_has_many_association? ? super : false
|
20
17
|
end
|
21
18
|
|
22
19
|
def can_edit?
|
@@ -76,7 +73,7 @@ class Avo::Index::ResourceControlsComponent < Avo::ResourceComponent
|
|
76
73
|
Avo.resource_manager.get_resource_by_model_class @parent_record.class
|
77
74
|
end
|
78
75
|
|
79
|
-
def is_has_many_association
|
76
|
+
def is_has_many_association?
|
80
77
|
@reflection.is_a?(::ActiveRecord::Reflection::HasManyReflection) || @reflection.is_a?(::ActiveRecord::Reflection::ThroughReflection)
|
81
78
|
end
|
82
79
|
|
@@ -3,7 +3,7 @@
|
|
3
3
|
data-modal-target="modal"
|
4
4
|
>
|
5
5
|
<div aria-expanded="true" class="modal-overlay absolute w-full h-full bg-opacity-25 bg-gray-800 flex justify-center items-center" data-action="click->modal#close"></div>
|
6
|
-
<div aria-expanded="true" role="dialog" aria-modal="true" class="modal-body rounded-lg
|
6
|
+
<div aria-expanded="true" role="dialog" aria-modal="true" class="modal-body rounded-lg inset-auto w-11/12 lg:w-1/2 sm:max-w-168 min-h-1/4 bg-white flex z-50 relative shadow-modal overflow-auto max-h-full">
|
7
7
|
<div class="flex-1 flex flex-col justify-between">
|
8
8
|
<div>
|
9
9
|
<div class="p-6 text-2xl tracking-normal font-semibold text-black">
|
@@ -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.record.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
|
@@ -237,7 +244,7 @@ class Avo::ResourceComponent < Avo::BaseComponent
|
|
237
244
|
data: {
|
238
245
|
confirm: "Are you sure you want to detach this #{title}."
|
239
246
|
} do
|
240
|
-
control.label || t("avo.detach_item", item: title).
|
247
|
+
control.label || t("avo.detach_item", item: title).humanize
|
241
248
|
end
|
242
249
|
end
|
243
250
|
|
@@ -311,4 +318,21 @@ class Avo::ResourceComponent < Avo::BaseComponent
|
|
311
318
|
def is_a_related_resource?
|
312
319
|
@reflection.present? && @resource.record.present?
|
313
320
|
end
|
321
|
+
|
322
|
+
def inverse_of
|
323
|
+
current_reflection = @reflection.active_record.reflect_on_all_associations.find do |reflection|
|
324
|
+
reflection.name == @reflection.name.to_sym
|
325
|
+
end
|
326
|
+
|
327
|
+
inverse_of = current_reflection.inverse_of
|
328
|
+
|
329
|
+
if inverse_of.blank? && Rails.env.development?
|
330
|
+
puts "WARNING! Avo uses the 'inverse_of' option to determine the inverse association and figure out if the association permit or not detaching."
|
331
|
+
# Ex: Please configure the 'inverse_of' option for the ':users' association on the 'Project' model.
|
332
|
+
puts "Please configure the 'inverse_of' option for the '#{current_reflection.macro} :#{current_reflection.name}' association on the '#{current_reflection.active_record.name}' model."
|
333
|
+
puts "Otherwise the detach button will be visible by default.\n\n"
|
334
|
+
end
|
335
|
+
|
336
|
+
inverse_of
|
337
|
+
end
|
314
338
|
end
|
@@ -53,7 +53,7 @@ module Avo
|
|
53
53
|
record: @record,
|
54
54
|
resource: @resource,
|
55
55
|
user: _current_user,
|
56
|
-
view:
|
56
|
+
view: :new, # force the action view to in order to render new-related fields (hidden field)
|
57
57
|
arguments: decrypted_arguments || {}
|
58
58
|
)
|
59
59
|
end
|
@@ -80,7 +80,8 @@ module Avo
|
|
80
80
|
flash_messages messages
|
81
81
|
|
82
82
|
if response[:type] == :redirect
|
83
|
-
redirect_to Avo::ExecutionContext.new(target: response[:path]).handle
|
83
|
+
redirect_to Avo::ExecutionContext.new(target: response[:path]).handle,
|
84
|
+
**{allow_other_host: response[:allow_other_host], status: response[:status]}.compact
|
84
85
|
elsif response[:type] == :reload
|
85
86
|
redirect_back fallback_location: resources_path(resource: @resource)
|
86
87
|
end
|
@@ -79,7 +79,7 @@ module Avo
|
|
79
79
|
association_name = BaseResource.valid_association_name(@record, params[:related_name])
|
80
80
|
|
81
81
|
if reflection_class == "HasManyReflection"
|
82
|
-
@record.send(association_name).
|
82
|
+
@record.send(association_name).destroy @attachment_record
|
83
83
|
else
|
84
84
|
@record.send("#{association_name}=", nil)
|
85
85
|
end
|
data/lib/avo/base_action.rb
CHANGED
@@ -14,6 +14,7 @@ module Avo
|
|
14
14
|
class_attribute :standalone, default: false
|
15
15
|
class_attribute :visible
|
16
16
|
class_attribute :may_download_file, default: false
|
17
|
+
class_attribute :turbo
|
17
18
|
|
18
19
|
attr_accessor :response
|
19
20
|
attr_accessor :record
|
@@ -38,9 +39,9 @@ module Avo
|
|
38
39
|
def form_data_attributes
|
39
40
|
# We can't respond with a file download from Turbo se we disable it on the form
|
40
41
|
if may_download_file
|
41
|
-
{turbo: false, remote: false, action_target: :form}
|
42
|
+
{turbo: turbo || false, remote: false, action_target: :form}
|
42
43
|
else
|
43
|
-
{turbo_frame: :_top, action_target: :form}
|
44
|
+
{turbo: turbo, turbo_frame: :_top, action_target: :form}.compact
|
44
45
|
end
|
45
46
|
end
|
46
47
|
|
@@ -198,8 +199,10 @@ module Avo
|
|
198
199
|
self
|
199
200
|
end
|
200
201
|
|
201
|
-
def redirect_to(path = nil, &block)
|
202
|
+
def redirect_to(path = nil, allow_other_host: nil, status: nil, &block)
|
202
203
|
response[:type] = :redirect
|
204
|
+
response[:allow_other_host] = allow_other_host
|
205
|
+
response[:status] = status
|
203
206
|
response[:path] = if block.present?
|
204
207
|
block
|
205
208
|
else
|
data/lib/avo/base_resource.rb
CHANGED
@@ -176,7 +176,7 @@ module Avo
|
|
176
176
|
default = class_name.underscore.humanize
|
177
177
|
|
178
178
|
if translation_key
|
179
|
-
t(translation_key, count: 1, default: default).
|
179
|
+
t(translation_key, count: 1, default: default).humanize
|
180
180
|
else
|
181
181
|
default
|
182
182
|
end
|
@@ -187,7 +187,7 @@ module Avo
|
|
187
187
|
default = name.pluralize
|
188
188
|
|
189
189
|
if translation_key
|
190
|
-
t(translation_key, count: 2, default: default).
|
190
|
+
t(translation_key, count: 2, default: default).humanize
|
191
191
|
else
|
192
192
|
default
|
193
193
|
end
|
@@ -320,7 +320,7 @@ module Avo
|
|
320
320
|
when :edit
|
321
321
|
record_title
|
322
322
|
when :new
|
323
|
-
t("avo.create_new_item", item: name.
|
323
|
+
t("avo.create_new_item", item: name.humanize(capitalize: false)).upcase_first
|
324
324
|
end
|
325
325
|
end
|
326
326
|
|
@@ -93,11 +93,11 @@ module Avo
|
|
93
93
|
end
|
94
94
|
|
95
95
|
def translated_name(default:)
|
96
|
-
t(translation_key, count: 1, default: default).
|
96
|
+
t(translation_key, count: 1, default: default).humanize
|
97
97
|
end
|
98
98
|
|
99
99
|
def translated_plural_name(default:)
|
100
|
-
t(translation_key, count: 2, default: default).
|
100
|
+
t(translation_key, count: 2, default: default).humanize
|
101
101
|
end
|
102
102
|
|
103
103
|
# Getting the name of the resource (user/users, post/posts)
|
@@ -7,7 +7,7 @@ module Avo
|
|
7
7
|
|
8
8
|
@label = args[:label] || I18n.t("avo.delete").capitalize
|
9
9
|
if args[:item].present?
|
10
|
-
@title = I18n.t("avo.delete_item", item: args[:item]).
|
10
|
+
@title = I18n.t("avo.delete_item", item: args[:item]).humanize if title.nil?
|
11
11
|
@confirmation_message = I18n.t("avo.are_you_sure") if confirmation_message.nil?
|
12
12
|
end
|
13
13
|
end
|
@@ -6,7 +6,7 @@ module Avo
|
|
6
6
|
super(**args)
|
7
7
|
|
8
8
|
if args[:item].present?
|
9
|
-
@title = I18n.t("avo.detach_item", item: args[:item]).
|
9
|
+
@title = I18n.t("avo.detach_item", item: args[:item]).humanize if title.nil?
|
10
10
|
@confirmation_message = I18n.t("avo.are_you_sure_detach_item", item: args[:item]) if confirmation_message.nil?
|
11
11
|
end
|
12
12
|
end
|
@@ -7,7 +7,7 @@ module Avo
|
|
7
7
|
|
8
8
|
@label = args[:label] || I18n.t("avo.edit").capitalize
|
9
9
|
if args[:item].present?
|
10
|
-
@title = I18n.t("avo.edit_item", item: args[:item]).
|
10
|
+
@title = I18n.t("avo.edit_item", item: args[:item]).humanize if title.nil?
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
data/lib/avo/version.rb
CHANGED