lib/avo/base_action.rb in avo-3.2.3 vs lib/avo/base_action.rb in avo-3.3.0
- old
+ new
@@ -8,11 +8,11 @@
class_attribute :confirm_button_label
class_attribute :cancel_button_label
class_attribute :no_confirmation, default: false
class_attribute :standalone, default: false
class_attribute :visible
- class_attribute :may_download_file, default: false
+ class_attribute :may_download_file
class_attribute :turbo
class_attribute :authorize, default: true
attr_accessor :view
attr_accessor :response
@@ -34,29 +34,16 @@
class << self
delegate :context, to: ::Avo::Current
def form_data_attributes
- # We can't respond with a file download from Turbo se we disable it on the form
- if may_download_file
- {turbo: turbo || false, remote: false}
- else
- {turbo: turbo, turbo_frame: :_top}.compact
- end
+ {
+ turbo: turbo,
+ turbo_frame: :_top
+ }.compact
end
- # We can't respond with a file download from Turbo se we disable close the modal manually after a while (it's a hack, we know)
- def submit_button_data_attributes
- attributes = { action_target: "submit" }
-
- if may_download_file
- attributes[:action] = "click->modal#delayedClose"
- end
-
- attributes
- end
-
def to_param
to_s
end
def link_arguments(resource:, **args)
@@ -97,10 +84,14 @@
self.items_holder = Avo::Resources::Items::Holder.new
fields
@response ||= {}
@response[:messages] = []
+
+ if self.may_download_file.present?
+ puts "[Avo->] WARNING! Since version 3.2.2 'may_download_file' is unecessary and deprecated on actions. Can be safely removed from #{self.class.name}"
+ end
end
# Blank method
def fields
end
@@ -191,10 +182,16 @@
self
end
def keep_modal_open
- response[:keep_modal_open] = true
+ response[:type] = :keep_modal_open
+
+ self
+ end
+
+ def close_modal
+ response[:type] = :close_modal
self
end
# Add a placeholder silent message from when a user wants to do a redirect action or something similar