Documents: collections (and Uncollected) collapse, closed by default, with document counts

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rickyandClaude Opus 5.5 committed 2026-11-11 20:31:02 -05:00
1 parent 85326d494c
commit 6e871e9ebb
3 files changed
+31 -11

No files matched your search

+18 -10
View File
@@ -12,11 +12,14 @@
<% end %>
<div class="space-y-5">
<% @collections.each do |col| %>
<section class="card">
<div class="card-header">
<div>
<h2 class="card-title"><%= "★ " if col.starred? %><%= col.name %></h2>
<% if col.description.present? %><p class="text-xs text-slate-500"><%= col.description %></p><% end %>
<details class="card group document-collection">
<summary class="card-header cursor-pointer list-none border-b-0 group-open:border-b [&::-webkit-details-marker]:hidden">
<div class="flex min-w-0 items-start gap-2">
<span aria-hidden="true" class="mt-0.5 text-slate-400 transition group-open:rotate-90">›</span>
<div class="min-w-0">
<h2 class="card-title"><%= "★ " if col.starred? %><%= col.name %> <span class="text-sm font-normal text-slate-500">(<%= col.documents.size %>)</span></h2>
<% if col.description.present? %><p class="text-xs text-slate-500"><%= col.description %></p><% end %>
</div>
</div>
<div class="flex items-center gap-2">
<%= visibility_badge(col.visibility) %>
@@ -25,16 +28,21 @@
<%= link_to "Edit", edit_aircraft_document_collection_path(@aircraft, col), class: "btn-secondary btn-sm" %>
<% end %>
</div>
</div>
</summary>
<% if col.documents.any? %>
<ul class="divide-y divide-slate-100"><% col.documents.sort_by(&:name).each do |doc| %><%= render "documents/doc_row", doc: doc, aircraft: @aircraft %><% end %></ul>
<% else %><%= empty_state "Empty collection." %><% end %>
</section>
</details>
<% end %>
<% if @uncollected.any? %>
<section class="card">
<div class="card-header"><h2 class="card-title">Uncollected</h2></div>
<details class="card group document-collection">
<summary class="card-header cursor-pointer list-none border-b-0 group-open:border-b [&::-webkit-details-marker]:hidden">
<div class="flex items-start gap-2">
<span aria-hidden="true" class="mt-0.5 text-slate-400 transition group-open:rotate-90">›</span>
<h2 class="card-title">Uncollected <span class="text-sm font-normal text-slate-500">(<%= @uncollected.size %>)</span></h2>
</div>
</summary>
<ul class="divide-y divide-slate-100"><% @uncollected.each do |doc| %><%= render "documents/doc_row", doc: doc, aircraft: @aircraft %><% end %></ul>
</section>
</details>
<% end %>
</div>
+1 -1
View File
@@ -4,7 +4,7 @@ The **Documents** tab keeps scans and files: registration, airworthiness certifi
- **+ Upload Document**: a name, type, collection, description, and one or more files (images, PDFs or text). Each file is a page in the viewer.
- **Bulk upload**: many files at once. Each becomes its own document named after the file; files with the same name are combined, in order, as pages of one document.
- **+ Collection** groups documents (for example *Engine logbook* or *Annual 2026*).
- **+ Collection** groups documents (for example *Engine logbook* or *Annual 2026*). Collections start collapsed, showing how many documents they hold; click one to open it.
## Expiry
@@ -15,6 +15,18 @@ class DocumentBulkUploadTest < ActionDispatch::IntegrationTest
ActiveStorage::Blob.create_and_upload!(io: StringIO.new("bytes"), filename: name, content_type: type)
end
test "collections are collapsed on the documents page, with their document count" do
sign_in @owner
@a.document_collections.create!(name: "Engine logbook").documents.create!(aircraft: @a, name: "Scan", doc_type: "LOG")
@a.documents.create!(name: "Loose receipt", doc_type: "INVOICE")
get aircraft_documents_path(@a)
assert_select "details.document-collection", 2
assert_select "details.document-collection[open]", 0 # collapsed until clicked
assert_select "details.document-collection summary h2", text: /Engine logbook\s*\(1\)/
assert_select "details.document-collection summary h2", text: /Uncollected\s*\(1\)/
assert_select "details.document-collection a", text: "Scan" # still in the page, just closed
end
test "owner sees the bulk page; pilots and outsiders can't use it" do
sign_in @owner
get aircraft_documents_path(@a)