From 0dd4bafdfd890ea8e4dbfb3e1db8277466dee0f5 Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Thu, 25 Apr 2024 12:11:48 +0200 Subject: [PATCH] refactor(pj): more readable as_multiple logic --- .../multiple_component/multiple_component.html.haml | 2 +- app/models/champs/piece_justificative_champ.rb | 4 ---- app/models/champs/titre_identite_champ.rb | 4 ---- 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/app/components/attachment/multiple_component/multiple_component.html.haml b/app/components/attachment/multiple_component/multiple_component.html.haml index b5a64b044..74abdf23c 100644 --- a/app/components/attachment/multiple_component/multiple_component.html.haml +++ b/app/components/attachment/multiple_component/multiple_component.html.haml @@ -8,7 +8,7 @@ = render Attachment::EditComponent.new(champ:, attached_file:, attachment:, index:, view_as:, user_can_destroy:, form_object_name:) %div{ id: empty_component_id, class: class_names("hidden": !can_attach_next?), data: { turbo_force: :server } } - = render Attachment::EditComponent.new(champ:, as_multiple: champ.present? ? champ.allow_multiple_attachments? : true, attached_file:, attachment: nil, index: attachments_count, user_can_destroy:, form_object_name:) + = render Attachment::EditComponent.new(champ:, as_multiple: champ.nil?, attached_file:, attachment: nil, index: attachments_count, user_can_destroy:, form_object_name:) // single poll and refresh message for all attachments = render Attachment::PendingPollComponent.new(attachments: attachments, poll_url:, context: poll_context) diff --git a/app/models/champs/piece_justificative_champ.rb b/app/models/champs/piece_justificative_champ.rb index bca75c292..8d9435d17 100644 --- a/app/models/champs/piece_justificative_champ.rb +++ b/app/models/champs/piece_justificative_champ.rb @@ -30,8 +30,4 @@ class Champs::PieceJustificativeChamp < Champ def blank? piece_justificative_file.blank? end - - def allow_multiple_attachments? - false - end end diff --git a/app/models/champs/titre_identite_champ.rb b/app/models/champs/titre_identite_champ.rb index 88983fa6e..05b67e802 100644 --- a/app/models/champs/titre_identite_champ.rb +++ b/app/models/champs/titre_identite_champ.rb @@ -25,8 +25,4 @@ class Champs::TitreIdentiteChamp < Champ def blank? piece_justificative_file.blank? end - - def allow_multiple_attachments? - false - end end