<% content_for :before_content do %> <%= govuk_back_link href: collection_resources_path %> <% end %>
<% resource_exists = file_exists_on_s3?(@collection_resource.download_filename) %> <%= form_with model: @collection_resource, url: @collection_resource.mandatory ? update_mandatory_collection_resource_path : collection_resource_update_path(@collection_resource), method: :patch do |f| %> <%= f.hidden_field :year %> <%= f.hidden_field :log_type %> <%= f.hidden_field :resource_type %> <%= f.govuk_error_summary %> <%= "#{@collection_resource.log_type.humanize} #{text_year_range_format(@collection_resource.year)}" %>

<%= resource_exists ? "Change" : "Upload" %> the <%= @collection_resource.short_display_name.downcase %>

This file will be available for all users to download.

<%= f.govuk_file_field :file, label: { text: "Upload file", size: "m" } %> <% if resource_exists %>

Current file: <%= govuk_link_to @collection_resource.download_filename, href: @collection_resource.download_path %>

<% end %> <% unless @collection_resource.mandatory %> <%= f.govuk_text_field :short_display_name, label: { text: "Resource type", size: "m" }, hint: { text: safe_join(["This will be used in the download link on the homepage. Do not include the log type or collection year.", content_tag(:br), "For example, if you enter “bulk upload change log”, the download link will say “Download the #{@collection_resource.log_type} bulk upload change log (#{text_year_range_format(@collection_resource.year)})”."]) } %> <% end %>
<%= f.govuk_submit resource_exists ? "Save changes" : "Upload" %> <%= govuk_button_link_to "Cancel", collection_resources_path, secondary: true %>
<% end %>