refactor(attachment): remove replace feature
This commit is contained in:
parent
b8296c6d4d
commit
7ae6efe776
5 changed files with 3 additions and 23 deletions
|
@ -60,7 +60,7 @@ class Attachment::EditComponent < ApplicationComponent
|
|||
end
|
||||
|
||||
def auto_attach_url
|
||||
helpers.auto_attach_url(form.object, replace_attachment_id: persisted? ? attachment_id : nil)
|
||||
helpers.auto_attach_url(form.object)
|
||||
end
|
||||
|
||||
def input_id(given_id)
|
||||
|
@ -95,14 +95,6 @@ class Attachment::EditComponent < ApplicationComponent
|
|||
}
|
||||
end
|
||||
|
||||
def replace_button_options
|
||||
{
|
||||
type: 'button',
|
||||
class: 'button small',
|
||||
data: { toggle_target: ".#{attachment_input_class}" }
|
||||
}
|
||||
end
|
||||
|
||||
def file_size_validator
|
||||
@attached_file.record
|
||||
._validators[file_field_name.to_sym]
|
||||
|
|
|
@ -6,8 +6,6 @@
|
|||
- if user_can_destroy?
|
||||
.attachment-action{ "data-turbo": "true" }
|
||||
= link_to('Supprimer', attachment_path, **remove_button_options)
|
||||
.attachment-action
|
||||
= button_tag('Remplacer', **replace_button_options)
|
||||
|
||||
.attachment-error.hidden
|
||||
.attachment-error-message
|
||||
|
|
|
@ -14,8 +14,6 @@ class Champs::PieceJustificativeController < ApplicationController
|
|||
def attach_piece_justificative
|
||||
@champ = policy_scope(Champ).find(params[:champ_id])
|
||||
|
||||
purge_replaced_attachment
|
||||
|
||||
@champ.piece_justificative_file.attach(params[:blob_signed_id])
|
||||
save_succeed = @champ.save
|
||||
@champ.dossier.update(last_champ_updated_at: Time.zone.now.utc) if save_succeed
|
||||
|
@ -27,11 +25,4 @@ class Champs::PieceJustificativeController < ApplicationController
|
|||
rescue ActiveRecord::StaleObjectError
|
||||
attach_piece_justificative
|
||||
end
|
||||
|
||||
def purge_replaced_attachment
|
||||
return if params[:replace_attachment_id].blank?
|
||||
|
||||
attachment = @champ.piece_justificative_file.attachments.find { _1.id == params[:replace_attachment_id].to_i }
|
||||
attachment&.purge_later
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7,9 +7,9 @@ module ChampHelper
|
|||
simple_format(auto_linked_text, {}, sanitize: false)
|
||||
end
|
||||
|
||||
def auto_attach_url(object, url_options = {})
|
||||
def auto_attach_url(object)
|
||||
if object.is_a?(Champ)
|
||||
champs_piece_justificative_url(object.id, url_options)
|
||||
champs_piece_justificative_url(object.id)
|
||||
elsif object.is_a?(TypeDeChamp)
|
||||
piece_justificative_template_admin_procedure_type_de_champ_url(stable_id: object.stable_id, procedure_id: object.procedure.id)
|
||||
end
|
||||
|
|
|
@ -30,7 +30,6 @@ describe 'shared/attachment/_update.html.haml', type: :view do
|
|||
end
|
||||
|
||||
it 'does not render action buttons' do
|
||||
expect(subject).not_to have_link('Remplacer')
|
||||
expect(subject).not_to have_link('Supprimer')
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue