Submit social housing lettings and sales data (CORE)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

46 lines
1.2 KiB

module LogActionsHelper
include GovukLinkHelper
def edit_actions_for_log(log)
back = back_button_for(log)
delete = delete_button_for_log(log)
return if back.nil? && delete.nil?
content_tag(:div, class: "govuk-button-group") do
safe_join([back, delete])
end
end
private
def back_button_for(log)
if log.completed?
if log.creation_method_bulk_upload?
if log.lettings?
govuk_button_link_to "Back to uploaded logs", resume_bulk_upload_lettings_result_path(log.bulk_upload)
else
govuk_button_link_to "Back to uploaded logs", resume_bulk_upload_sales_result_path(log.bulk_upload)
end
elsif log.lettings?
govuk_button_link_to "Back to lettings logs", lettings_logs_path
elsif log.sales?
govuk_button_link_to "Back to sales logs", sales_logs_path
end
end
end
def policy_class_for(log)
log.lettings? ? LettingsLogPolicy : SalesLogPolicy
end
def delete_button_for_log(log)
if policy_class_for(log).new(current_user, log).destroy?
govuk_button_link_to(
"Delete log",
log.lettings? ? lettings_log_delete_confirmation_path(log) : sales_log_delete_confirmation_path(log),
warning: true,
)
end
end
end