Skip to content

Commit

Permalink
Merge pull request #7862 from alphagov/delete-attachable-editing-tabs…
Browse files Browse the repository at this point in the history
…-helper

Remove unused attachable helper methods
  • Loading branch information
beccapearce committed Jun 28, 2023
2 parents 7a5e7d5 + 3ae7923 commit 55b046d
Showing 1 changed file with 0 additions and 55 deletions.
55 changes: 0 additions & 55 deletions app/helpers/admin/attachable_helper.rb
Original file line number Diff line number Diff line change
@@ -1,59 +1,4 @@
module Admin::AttachableHelper
def attachable_editing_tabs(attachable, &block)
case attachable
when Consultation
consultation_editing_tabs(attachable, &block)
when ConsultationResponse
consultation_editing_tabs(attachable.consultation, &block)
when CallForEvidence
call_for_evidence_editing_tabs(attachable, &block)
when CallForEvidenceResponse
call_for_evidence_editing_tabs(attachable.call_for_evidence, &block)
when Edition
edition_editing_tabs(attachable, &block)
else
tab_navigation_for(attachable, &block)
end
end

def attachment_action_fields(fields, data_object_name = :attachment_data)
return if fields.object.new_record?

keep_destroy_or_replace =
if fields.object[:_destroy].present? && fields.object[:_destroy] == "1"
"destroy"
elsif fields.object.send(data_object_name).file_cache.present?
"replace"
else
"keep"
end
[
fields.labelled_radio_button("Keep", :attachment_action, "keep", checked: keep_destroy_or_replace == "keep"),
fields.labelled_radio_button("Remove", :attachment_action, "remove", checked: keep_destroy_or_replace == "destroy"),
fields.labelled_radio_button("Replace", :attachment_action, "replace", checked: keep_destroy_or_replace == "replace"),
].join.html_safe
end

def consultation_response_form_data_fields(response_form_fields)
object = response_form_fields.object.consultation_response_form_data
if object.nil? && !response_form_fields.object.persisted?
object = response_form_fields.object.build_consultation_response_form_data
end

response_form_fields.fields_for(:consultation_response_form_data, object) do |data_fields|
contents = []
contents << data_fields.label(:file, "Replacement") if response_form_fields.object.persisted?
contents << data_fields.file_field(:file)
if data_fields.object.file_cache.present?
text = "#{File.basename(data_fields.object.file_cache)} already uploaded"
text << " as replacement" if response_form_fields.object.persisted?
contents << tag.span(text, class: "already_uploaded")
end
contents << data_fields.hidden_field(:file_cache)
contents.join.html_safe
end
end

def is_publication?(model_name)
model_name == "publication"
end
Expand Down

0 comments on commit 55b046d

Please sign in to comment.