<%= form_with model: [aircraft, document], class: "card card-body space-y-4 max-w-3xl", multipart: true, data: { controller: "name-from-file" } do |f| %> <%= f.errors_summary %>
<%= f.field :name, required: true, data: { name_from_file_target: "name" } %> <%= f.field :doc_type, as: :select, label: t(".type"), collection: Document::TYPES.invert %> <%= f.field :document_collection_id, as: :select, label: t(".collection"), collection: [[t(".none"), nil]] + aircraft.document_collections.ordered.map { [_1.name, _1.id] } %> <%= f.field :visibility, as: :select, label: t(".share_link_visibility"), collection: [[t(".inherit_from_collection"), nil]] + DocumentCollection::VISIBILITIES.invert.to_a %>
<%= f.field :legacy_record, as: :checkbox, label: t(".legacy_record_a_scan_of"), hint: t(".records_from_before_the_electronic") %> <%= f.field :expires_on, as: :date, label: t(".expires_on"), wrapper: { class: "max-w-xs" }, hint: t(".optional_registration_good_for_7") %> <%= f.field :description, as: :textarea, rows: 2 %> <%= f.field :pages, as: :file, multiple: true, label: document.persisted? ? t(".add_files") : t(".files"), hint: t(".images_pdfs_or_text_up", max_upload_mb: Setting.max_upload_mb), data: { name_from_file_target: "file", action: "name-from-file#fill" } %> <% if document.persisted? && document.pages.any? %>

<%= t(".remove_existing_files") %>

<% document.pages.each do |p| %> <% end %>
<% end %> <% unless document.persisted? %>

<%= t(".lots_of_files_makes_a_html", link: (link_to t(".bulk_upload"), new_bulk_aircraft_documents_path(aircraft, collection_id: document.document_collection_id), class: "link")) %>

<% end %>
<%= f.submit t(".save_document") %><%= link_to t(".cancel"), aircraft_documents_path(aircraft), class: "btn-secondary" %>
<% end %> <% if document.persisted? %>
<%= delete_button t(".delete_document"), aircraft_document_path(aircraft, document) %>
<% end %>