From 3f45b557c24390b081a7463d7764b59a68675d78 Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Fri, 13 Nov 2026 21:21:57 -0500 Subject: [PATCH] Secondary actions behind More menus; tidier aircraft header and tabs - more_menu helper (menu / menu-item styles): each section keeps its main action as a button; imports, exports, printing and tools move under More (flights, logbook, logbook entry, documents, inspections, fleet) - Aircraft header: More with status report and, for owners, access & sharing, edit, .sam.zip and records package; Access & Sharing and Oil Analysis tabs removed (oil analysis is under Oil & Fuel with a switch) - Logbook: Print selected appears once an entry is ticked; filters apply on change; dates use fmt_date (also AirTrail, notes, audits, About) - Header shows the role on the aircraft and hides the usual Available badge; no second Grounded badge on the Overview; AD DRS import listed once - Flights: stat cards 2x2 on phones; By year opens visibly, only with more than one year; duplicate + Log Flight removed - Remove unused hello_controller.js; guide and README updated Co-Authored-By: Claude Opus 5.5 --- README.md | 2 +- app/assets/tailwind/application.css | 3 ++ app/helpers/aircraft_helper.rb | 8 ++-- app/helpers/application_helper.rb | 11 +++++ app/javascript/application.js | 10 ++++ .../controllers/hello_controller.js | 7 --- app/views/admin/about/show.html.erb | 4 +- app/views/admin/audits/index.html.erb | 2 +- app/views/air_trail_connections/show.html.erb | 2 +- app/views/aircraft/index.html.erb | 2 +- app/views/aircraft/show.html.erb | 1 - app/views/aircraft_roles/index.html.erb | 1 + .../airworthiness_directives/index.html.erb | 1 - app/views/consumable_records/index.html.erb | 1 + app/views/documents/index.html.erb | 6 ++- app/views/flight_logs/_stats.html.erb | 10 ++-- app/views/flight_logs/index.html.erb | 9 +++- app/views/inspections/index.html.erb | 2 +- app/views/logbook_entries/index.html.erb | 15 +++--- app/views/logbook_entries/show.html.erb | 13 ++++-- app/views/notes/index.html.erb | 2 +- app/views/oil_analyses/index.html.erb | 1 + app/views/shared/_aircraft_header.html.erb | 17 +++++-- app/views/shared/_oil_subnav.html.erb | 7 +++ docs/guide/administration.md | 2 +- docs/guide/ads.md | 2 +- docs/guide/aircraft.md | 4 +- docs/guide/documents.md | 4 +- docs/guide/flights.md | 2 +- docs/guide/getting-started.md | 5 +- docs/guide/inspections.md | 2 +- docs/guide/logbook.md | 4 +- docs/guide/oil-and-fuel.md | 2 +- docs/guide/records.md | 4 +- docs/guide/sharing.md | 4 +- test/integration/document_bulk_upload_test.rb | 2 +- test/integration/more_menu_test.rb | 46 +++++++++++++++++++ test/integration/phone_layout_test.rb | 2 +- 38 files changed, 159 insertions(+), 63 deletions(-) delete mode 100644 app/javascript/controllers/hello_controller.js create mode 100644 app/views/shared/_oil_subnav.html.erb create mode 100644 test/integration/more_menu_test.rb diff --git a/README.md b/README.md index 734d7d4..a5e7aa0 100644 --- a/README.md +++ b/README.md @@ -120,7 +120,7 @@ The app also makes a verified copy of the main database every night in `storage/ For an off-site copy without extra tools, **Admin → Off-site Backup** connects a Google Drive account: each night the verified database copy and any new uploaded files are copied there, and a restore test checks them. Setup and restoring are in the [administration guide](docs/guide/administration.md#off-site-backup-to-google-drive). Keep `SECRET_KEY_BASE` somewhere safe off the server: stored secrets (API keys, the Drive connection) and electronic signature seals depend on it. -To back up or move a single aircraft with all its files, use **Access & Sharing → Download .sam.zip** (or `bin/rails "sam:export[N12345]"`). Import it from **Fleet → Import** (or `bin/rails "sam:import[file.sam.zip,owner@example.com]"`). The archive format is the original Simple Aircraft Manager's, so archives move between the two apps. +To back up or move a single aircraft with all its files, use **More → Download .sam.zip** on the aircraft (or `bin/rails "sam:export[N12345]"`). Import it from **Fleet → More → Import from a .sam.zip archive** (or `bin/rails "sam:import[file.sam.zip,owner@example.com]"`). The archive format is the original Simple Aircraft Manager's, so archives move between the two apps. ## Features diff --git a/app/assets/tailwind/application.css b/app/assets/tailwind/application.css index be43df4..232e4c1 100644 --- a/app/assets/tailwind/application.css +++ b/app/assets/tailwind/application.css @@ -15,6 +15,9 @@ @utility btn-danger { @apply btn bg-surface text-red-700 ring-1 ring-red-300 ring-inset hover:bg-red-50; } @utility btn-sm { @apply px-2 py-1 text-xs; } @utility link { @apply text-sky-700 hover:underline; } +/* The "More" menu (ApplicationHelper#more_menu): secondary actions, one per row. */ +@utility menu { @apply absolute right-0 z-30 mt-2 w-60 rounded-md bg-surface py-1 shadow-lg ring-1 ring-slate-200; } +@utility menu-item { @apply block w-full px-4 py-2 text-left text-sm text-slate-700 hover:bg-slate-100 cursor-pointer; } @utility card { @apply rounded-lg bg-surface shadow-sm ring-1 ring-slate-200; } @utility card-header { @apply flex flex-wrap items-center justify-between gap-3 border-b border-slate-200 px-4 py-3; } diff --git a/app/helpers/aircraft_helper.rb b/app/helpers/aircraft_helper.rb index fd66ca8..20258f0 100644 --- a/app/helpers/aircraft_helper.rb +++ b/app/helpers/aircraft_helper.rb @@ -6,8 +6,7 @@ module AircraftHelper [ "Components", aircraft_components_path(aircraft), %w[components] ], [ "Squawks", aircraft_squawks_path(aircraft), %w[squawks] ], [ "Flights", aircraft_flight_logs_path(aircraft), %w[flight_logs flight_imports air_trail_exports airport_codes] ], - [ "Oil & Fuel", aircraft_consumable_records_path(aircraft), %w[consumable_records] ], - [ "Oil Analysis", aircraft_oil_analyses_path(aircraft), %w[oil_analyses] ], + [ "Oil & Fuel", aircraft_consumable_records_path(aircraft), %w[consumable_records oil_analyses] ], [ "Logbook", aircraft_logbook_entries_path(aircraft), %w[logbook_entries] ], [ "Inspections", aircraft_inspections_path(aircraft), %w[inspections inspection_types inspection_records] ], [ "ADs", aircraft_airworthiness_directives_path(aircraft), %w[airworthiness_directives ad_compliances ad_imports] ], @@ -15,9 +14,8 @@ module AircraftHelper [ "Major Records", aircraft_major_records_path(aircraft), %w[major_records] ], [ "W&B", aircraft_weight_balance_records_path(aircraft), %w[weight_balance_records loading_setups] ], [ "Notes", aircraft_notes_path(aircraft), %w[notes] ], - [ "Activity", aircraft_events_path(aircraft), %w[events record_versions] ], - ([ "Access & Sharing", aircraft_aircraft_roles_path(aircraft), %w[aircraft_roles share_tokens] ] if owner?) - ].compact + [ "Activity", aircraft_events_path(aircraft), %w[events record_versions] ] + ] end def component_options(aircraft, include_blank: true) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index fcf3c05..7dfe7f9 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -14,6 +14,17 @@ module ApplicationHelper value ? value.in_time_zone.strftime("%b %-d, %Y %H:%M") : "—" end + # Secondary actions (imports, exports, printing, tools) behind one "More" + # button, so each section shows only its main action. The block gives the + # items: links or button_to forms with class "menu-item". + def more_menu(label = "More", small: false, &block) + tag.details(class: "relative", data: { controller: "dropdown", action: "click@window->dropdown#closeOutside keydown.esc@window->dropdown#close" }) do + tag.summary(class: [ "btn-secondary list-none [&::-webkit-details-marker]:hidden", ("btn-sm" if small) ], title: "More actions") do + safe_join([ label, tag.span("▾", class: "text-xs", "aria-hidden": true) ], " ") + end + tag.div(capture(&block), class: "menu") + end + end + AIRWORTHINESS_COLORS = { "RED" => "red", "LIMITED" => "blue", "ORANGE" => "orange", "GREEN" => "green", "INFO" => "gray" }.freeze def airworthiness_badge(status, large: false) diff --git a/app/javascript/application.js b/app/javascript/application.js index 344b302..93cb62d 100644 --- a/app/javascript/application.js +++ b/app/javascript/application.js @@ -51,8 +51,18 @@ document.addEventListener("click", (event) => { if (target.matches("[data-check-all]")) { target.closest("table")?.querySelectorAll("tbody input[type=checkbox]").forEach((box) => { box.checked = target.checked }) } + if (target.type === "checkbox") showSelectionActions() }) +// Actions on ticked rows (e.g. "Print selected") appear once a row is ticked: +// data-needs-selection names the form the row checkboxes belong to. +function showSelectionActions() { + document.querySelectorAll("[data-needs-selection]").forEach((el) => { + el.hidden = !document.querySelector(`input[form="${el.dataset.needsSelection}"]:checked`) + }) +} +document.addEventListener("turbo:load", showSelectionActions) + document.addEventListener("change", (event) => { if (event.target.matches?.("[data-submit-on-change]")) event.target.form?.requestSubmit() }) diff --git a/app/javascript/controllers/hello_controller.js b/app/javascript/controllers/hello_controller.js deleted file mode 100644 index 5975c07..0000000 --- a/app/javascript/controllers/hello_controller.js +++ /dev/null @@ -1,7 +0,0 @@ -import { Controller } from "@hotwired/stimulus" - -export default class extends Controller { - connect() { - this.element.textContent = "Hello World!" - } -} diff --git a/app/views/admin/about/show.html.erb b/app/views/admin/about/show.html.erb index 5d40993..fae612b 100644 --- a/app/views/admin/about/show.html.erb +++ b/app/views/admin/about/show.html.erb @@ -96,8 +96,8 @@ [ "Backups kept", "#{Setting.integer('backups_kept')} (in storage/backups)" ], [ "Off-site backup", OffsiteConnection.connected? ? ((o = OffsiteRun.latest_backup) ? tag.span("#{o.ok ? 'OK' : 'FAILED'} #{fmt_date(o.created_at.to_date)}", class: (o.ok && o.recent? ? nil : "badge-orange")) + " · Google Drive (#{OffsiteConnection.current.account_email})" : "Google Drive connected, none yet") : link_to("not set up", admin_offsite_backup_path, class: "badge-orange") ], [ "Procedures", (r = ProceduresRevision.current) ? "Revision #{r.number}, adopted #{fmt_date(r.adopted_at.to_date)}" : tag.span("not adopted", class: "badge-orange") ], - [ "Last audit", AuditRun.latest ? "#{AuditRun.latest.performed_at.to_date} · #{AuditRun.latest.passed ? 'passed' : 'items not passed'}" : "none yet" ], - [ "Next audit due", AuditRun.due_soon? ? tag.span(AuditRun.next_due.to_s, class: "badge-orange") : AuditRun.next_due.to_s ] + [ "Last audit", AuditRun.latest ? "#{fmt_date(AuditRun.latest.performed_at.to_date)} · #{AuditRun.latest.passed ? 'passed' : 'items not passed'}" : "none yet" ], + [ "Next audit due", AuditRun.due_soon? ? tag.span(fmt_date(AuditRun.next_due), class: "badge-orange") : fmt_date(AuditRun.next_due) ] ] %> <% if check && !check.ok %> diff --git a/app/views/admin/audits/index.html.erb b/app/views/admin/audits/index.html.erb index 660fc6f..fee993b 100644 --- a/app/views/admin/audits/index.html.erb +++ b/app/views/admin/audits/index.html.erb @@ -11,7 +11,7 @@