<% initialise_script 'GOVUK.AdminRenameAttachments', form_id: '#attachment_form' %>
<%= form_tag [:update_many, :admin, typecast_for_attachable_routing(@edition), Attachment], method: :put, id: 'attachment_form', remote: true, class: 'form-inline' do %>

  <table class="table">
  <thead>
    <tr>
      <th>Title</th>
      <th>Filename</th>
      <th></th>
    </tr>
  </thead>
  <% @edition.attachments.each do |attachment| %>
    <tr>
      <td id='<%= "js-attachment-#{attachment.id}" %>' class="control-group">
        <%= fields_for 'attachments[]', attachment, builder: ActionView::Helpers::FormBuilder do |f| %>
          <%= f.text_field :title %>
        <% end %>
      </td>
      <td class="attachment-filename"><%= link_to_attachment(attachment, preview: !@edition.published?, truncate: @edition.imported?) %></td>
      <td class="asset-manager-uploading-status"><%= attachment_uploading_status(attachment) %></td>
    </tr>
  <% end %>
  </table>
<div class="inline-submit notices">
  <%= submit_tag "Save attachment titles", class: "btn btn-primary" %>
</div>
<% end %>

<% initialise_script 'GOVUK.AdminRenameAttachments', form_id: '#attachment_form' %>
<%= form_tag [:update_many, :admin, typecast_for_attachable_routing(@edition), Attachment], method: :put, id: 'attachment_form', remote: true, class: 'form-inline' do %>

  <table class="table">
  <thead>
    <tr>
      <th>Title</th>
      <th>Filename</th>
      <th></th>
    </tr>
  </thead>
  <% @edition.attachments.includes(:attachment_data).each do |attachment| %>
    <tr>
      <td id='<%= "js-attachment-#{attachment.id}" %>' class="control-group">
        <%= fields_for 'attachments[]', attachment, builder: ActionView::Helpers::FormBuilder do |f| %>
          <%= f.text_field :title %>
        <% end %>
      </td>
      <td class="attachment-filename"><%= link_to_attachment(attachment, preview: !@edition.published?, truncate: @edition.imported?) %></td>
      <td class="asset-manager-uploading-status"><%= attachment_uploading_status(attachment) %></td>
    </tr>
  <% end %>
  </table>
<div class="inline-submit notices">
  <%= submit_tag "Save attachment titles", class: "btn btn-primary" %>
</div>
<% end %>

Improve loading edit attachments page for publication
Improve loading edit attachments page for publication

Following https://github.com/alphagov/whitehall/pull/4686
The Edit Attachments page for a publication requests each `attachment` requires it's `attachment_data`. Including this here should help optimise the query.

[Trello](https://trello.com/c/8vxsdXsq/857-make-the-add-html-attachment-step-more-resilient)
