Initial commit: Rails port of Simple Aircraft Manager

Rails 8.1 + SQLite rewrite of marbindrakon/simple-aircraft-manager,
designed to self-host as a single container (Solid Queue/Cache/Cable,
Active Storage on disk, Hotwire + importmap, Tailwind).

- Airworthiness engine ported from health/services.py (ADs, grounding
  squawks, inspection recurrency, component replacement)
- Hours updates and flight logs cascading to in-service components,
  optional airworthiness enforcement
- Components, squawks, ADs, inspections, logbook, documents, major
  records, oil/fuel consumption stats and charts, activity log
- Admin/owner/pilot RBAC and public share links (status/maintenance)
- Docker Compose and Kamal deployment, env-driven production config
- Service and integration tests

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rickyandClaude Opus 5.5 committed 2026-11-04 17:59:08 -05:00
commit 38df19c331
264 files changed
+8365

No files matched your search

+15
View File
@@ -0,0 +1,15 @@
<%= form_with model: compliance, url: compliance.new_record? ? aircraft_ad_compliances_path(aircraft) : aircraft_ad_compliance_path(aircraft, compliance), class: "card card-body space-y-4 max-w-2xl" do |f| %>
<%= f.errors_summary %>
<%= f.field :airworthiness_directive_id, as: :select, label: "AD", collection: aircraft.applicable_ads.ordered.map { ["#{_1.name} – #{_1.short_description.truncate(50)}", _1.id] } %>
<div class="grid gap-4 sm:grid-cols-2">
<%= f.field :date_complied, as: :date %>
<%= f.field :aircraft_hours_at_compliance, as: :number, step: 0.1, label: "Aircraft hours (tach)" %>
<%= f.field :next_due_at_time, as: :number, step: 0.1, label: "Next due at (tach hours)", hint: "0 = no hour-based recurrence." %>
<%= f.field :component_id, as: :select, label: "Component", collection: component_options(aircraft) %>
<%= f.field :logbook_entry_id, as: :select, label: "Logbook entry", collection: logbook_options(aircraft) %>
</div>
<%= f.field :permanent, as: :checkbox, label: "Permanently complied (terminating action)" %>
<%= f.field :compliance_notes, as: :textarea, label: "Method of compliance", rows: 3, required: true %>
<div class="flex gap-2"><%= f.submit "Save" %><%= link_to "Cancel", aircraft_airworthiness_directives_path(aircraft), class: "btn-secondary" %></div>
<% end %>
<% if compliance.persisted? %><div class="mt-4"><%= delete_button "Delete record", aircraft_ad_compliance_path(aircraft, compliance) %></div><% end %>
+2
View File
@@ -0,0 +1,2 @@
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<%= render "form", aircraft: @aircraft, compliance: @compliance %>
+2
View File
@@ -0,0 +1,2 @@
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<%= render "form", aircraft: @aircraft, compliance: @compliance %>
@@ -0,0 +1,7 @@
<%= form_with model: [:admin, component_type], class: "card card-body space-y-4 max-w-md" do |f| %>
<%= f.errors_summary %>
<%= f.field :name, required: true %>
<%= f.field :consumable, as: :checkbox, label: "Consumable (oil filter, spark plugs…)" %>
<div class="flex gap-2"><%= f.submit "Save" %><%= link_to "Cancel", admin_component_types_path, class: "btn-secondary" %></div>
<% end %>
<% if component_type.persisted? %><div class="mt-4"><%= delete_button "Delete type", admin_component_type_path(component_type) %></div><% end %>
@@ -0,0 +1,2 @@
<h1 class="mb-4 text-2xl font-bold">Edit Component Type</h1>
<%= render "form", component_type: @component_type %>
@@ -0,0 +1,7 @@
<% content_for :title, "Component Types" %>
<div class="mb-4 flex items-center justify-between"><h1 class="text-2xl font-bold">Component Types</h1><%= link_to "+ New Type", new_admin_component_type_path, class: "btn-primary" %></div>
<section class="card"><table class="table">
<thead><tr><th>Name</th><th>Consumable</th><th></th></tr></thead>
<tbody><% @component_types.each do |t| %><tr><td><%= t.name %></td><td><%= "Yes" if t.consumable? %></td>
<td class="text-right"><%= link_to "Edit", edit_admin_component_type_path(t), class: "btn-secondary btn-sm" %></td></tr><% end %></tbody>
</table></section>
@@ -0,0 +1,2 @@
<h1 class="mb-4 text-2xl font-bold">New Component Type</h1>
<%= render "form", component_type: @component_type %>
+10
View File
@@ -0,0 +1,10 @@
<%= form_with model: [:admin, user], class: "card card-body space-y-4 max-w-md" do |f| %>
<%= f.errors_summary %>
<%= f.field :name %>
<%= f.field :email_address, as: :email, label: "Email", required: true %>
<%= f.field :password, as: :password, hint: (user.persisted? ? "Leave blank to keep current password." : "At least 8 characters."), autocomplete: "new-password" %>
<%= f.field :password_confirmation, as: :password %>
<%= f.field :admin, as: :checkbox, label: "Administrator", hint: "Admins can see and edit every aircraft and manage users." %>
<div class="flex gap-2"><%= f.submit "Save" %><%= link_to "Cancel", admin_users_path, class: "btn-secondary" %></div>
<% end %>
<% if user.persisted? && user != current_user %><div class="mt-4"><%= delete_button "Delete user", admin_user_path(user) %></div><% end %>
+2
View File
@@ -0,0 +1,2 @@
<h1 class="mb-4 text-2xl font-bold">Edit User</h1>
<%= render "form", user: @user %>
+12
View File
@@ -0,0 +1,12 @@
<% content_for :title, "Users" %>
<div class="mb-4 flex items-center justify-between"><h1 class="text-2xl font-bold">Users</h1><%= link_to "+ New User", new_admin_user_path, class: "btn-primary" %></div>
<section class="card"><table class="table">
<thead><tr><th>Name</th><th>Email</th><th>Aircraft</th><th></th></tr></thead>
<tbody><% @users.each do |u| %><tr>
<td><%= u.name %> <% if u.admin? %><span class="badge-blue">Admin</span><% end %></td>
<td><%= u.email_address %></td>
<td class="text-xs"><%= u.aircraft_roles.map { "#{_1.aircraft.tail_number} (#{_1.role})" }.join(", ").presence || "—" %></td>
<td class="text-right"><%= link_to "Edit", edit_admin_user_path(u), class: "btn-secondary btn-sm" %></td>
</tr><% end %></tbody>
</table></section>
<p class="hint mt-3">After creating an account, an aircraft owner can grant access from the aircraft's “Access & Sharing” tab.</p>
+2
View File
@@ -0,0 +1,2 @@
<h1 class="mb-4 text-2xl font-bold">New User</h1>
<%= render "form", user: @user %>
+30
View File
@@ -0,0 +1,30 @@
<%= form_with model: aircraft, class: "card card-body space-y-4 max-w-3xl" do |f| %>
<%= f.errors_summary %>
<div class="grid gap-4 sm:grid-cols-3">
<%= f.field :tail_number, required: true, autofocus: true %>
<%= f.field :make %>
<%= f.field :model %>
<%= f.field :serial_number %>
<%= f.field :purchased, as: :date %>
<%= f.field :status, as: :select, collection: Aircraft::STATUSES.invert %>
</div>
<%= f.field :description, as: :textarea, rows: 3 %>
<div class="grid gap-4 sm:grid-cols-4">
<% if aircraft.new_record? %>
<%= f.field :tach_time, as: :number, step: 0.1, label: "Current tach" %>
<%= f.field :hobbs_time, as: :number, step: 0.1, label: "Current hobbs" %>
<% end %>
<%= f.field :tach_time_offset, as: :number, step: 0.1, hint: "Subtracted from tach for compliance math (e.g. after a tach replacement)." %>
<%= f.field :hobbs_time_offset, as: :number, step: 0.1 %>
</div>
<% unless aircraft.new_record? %>
<p class="hint">To change hours use “Update Hours” on the overview, so component times stay in sync.</p>
<% end %>
<%= f.field :picture, as: :file, accept: "image/*" %>
<%= f.field :airworthiness_enforcement, as: :checkbox, label: "Enforce airworthiness",
hint: "Block flight logs and hours updates while the aircraft is red." %>
<div class="flex gap-2">
<%= f.submit aircraft.new_record? ? "Add Aircraft" : "Save" %>
<%= link_to "Cancel", aircraft.new_record? ? root_path : aircraft_path(aircraft), class: "btn-secondary" %>
</div>
<% end %>
+9
View File
@@ -0,0 +1,9 @@
<% content_for :title, "Edit #{@aircraft.tail_number}" %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<%= render "form", aircraft: @aircraft %>
<div class="mt-6 max-w-3xl card card-body border-red-200">
<h2 class="font-semibold text-red-700">Danger zone</h2>
<p class="text-sm text-slate-600 mb-3">Deleting an aircraft removes all of its records, documents and history.</p>
<%= delete_button "Delete #{@aircraft.tail_number}", aircraft_path(@aircraft),
confirm: "Delete #{@aircraft.tail_number} and ALL its records? This cannot be undone.", class: "btn-danger" %>
</div>
+48
View File
@@ -0,0 +1,48 @@
<% content_for :title, "Fleet" %>
<div class="mb-5 flex items-center justify-between">
<h1 class="text-2xl font-bold tracking-tight">Fleet</h1>
<%= link_to "+ Add Aircraft", new_aircraft_path, class: "btn-primary" %>
</div>
<% if @aircraft_list.empty? %>
<div class="card card-body text-center">
<p class="text-slate-600">No aircraft yet.</p>
<p class="mt-3"><%= link_to "Add your first aircraft", new_aircraft_path, class: "btn-primary" %></p>
</div>
<% else %>
<div class="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
<% @aircraft_list.each do |aircraft| %>
<% aw = aircraft.airworthiness %>
<%= link_to aircraft_path(aircraft), class: "card block overflow-hidden transition hover:shadow-md" do %>
<div class="flex h-36 items-center justify-center bg-slate-200">
<% if aircraft.picture.attached? %>
<%= image_tag aircraft.picture, class: "h-full w-full object-cover" %>
<% else %>
<span class="text-5xl text-slate-400">✈</span>
<% end %>
</div>
<div class="card-body">
<div class="flex items-start justify-between gap-2">
<div>
<div class="text-lg font-bold"><%= aircraft.tail_number %></div>
<div class="text-sm text-slate-500"><%= [aircraft.make, aircraft.model].compact_blank.join(" ").presence || "—" %></div>
</div>
<%= airworthiness_badge(aw) %>
</div>
<div class="mt-3 flex items-center justify-between text-sm text-slate-600">
<span>Tach <strong><%= hours(aircraft.tach_time) %></strong></span>
<%= aircraft_status_badge(aircraft) %>
</div>
<% if aw.issues.any? %>
<ul class="mt-3 space-y-1 text-xs">
<% aw.issues.first(3).each do |issue| %>
<li class="<%= issue.severity == 'RED' ? 'text-red-700' : 'text-amber-700' %>">• <%= issue.title %></li>
<% end %>
<% if aw.issues.size > 3 %><li class="text-slate-500">+ <%= aw.issues.size - 3 %> more</li><% end %>
</ul>
<% end %>
</div>
<% end %>
<% end %>
</div>
<% end %>
+3
View File
@@ -0,0 +1,3 @@
<% content_for :title, "Add Aircraft" %>
<h1 class="mb-4 text-2xl font-bold">Add Aircraft</h1>
<%= render "form", aircraft: @aircraft %>
+109
View File
@@ -0,0 +1,109 @@
<% content_for :title, @aircraft.tail_number %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<div class="grid gap-5 lg:grid-cols-3">
<div class="space-y-5 lg:col-span-2">
<section class="card">
<div class="card-header">
<h2 class="card-title">Airworthiness</h2>
<%= airworthiness_badge(@airworthiness, large: true) %>
</div>
<div class="card-body">
<% if @airworthiness.issues.empty? %>
<p class="text-sm text-emerald-700">No open issues. All tracked ADs, inspections, components and squawks are current.</p>
<% else %>
<ul class="divide-y divide-slate-100">
<% @airworthiness.issues.each do |issue| %>
<li class="flex items-start gap-3 py-2">
<span class="<%= issue.severity == 'RED' ? 'badge-red' : 'badge-orange' %> mt-0.5"><%= issue.category %></span>
<div>
<div class="text-sm font-medium"><%= issue.title %></div>
<div class="text-xs text-slate-500"><%= issue.description %></div>
</div>
</li>
<% end %>
</ul>
<% end %>
<% if @aircraft.airworthiness_enforcement? %>
<p class="hint mt-3">Airworthiness enforcement is on: flights and hours updates are blocked while the status is red.</p>
<% end %>
</div>
</section>
<section class="card">
<div class="card-header">
<h2 class="card-title">Active Squawks</h2>
<%= link_to "All squawks →", aircraft_squawks_path(@aircraft), class: "link text-sm" %>
</div>
<% if @active_squawks.any? %>
<%= render "squawks/table", squawks: @active_squawks, aircraft: @aircraft %>
<% else %>
<%= empty_state "No open squawks." %>
<% end %>
</section>
<section class="card">
<div class="card-header"><h2 class="card-title">Consumption</h2>
<%= link_to "Oil & fuel →", aircraft_consumable_records_path(@aircraft), class: "link text-sm" %></div>
<div class="card-body grid grid-cols-2 gap-4 text-center">
<div><div class="text-2xl font-semibold"><%= @oil.average || "—" %></div><div class="text-xs text-slate-500">Avg oil, hrs/qt</div></div>
<div><div class="text-2xl font-semibold"><%= @fuel.average || "—" %></div><div class="text-xs text-slate-500">Avg fuel burn, gal/hr</div></div>
</div>
</section>
</div>
<div class="space-y-5">
<section class="card">
<div class="card-header"><h2 class="card-title">Update Hours</h2></div>
<%= form_with url: hours_aircraft_path(@aircraft), method: :patch, class: "card-body space-y-3" do |f| %>
<div class="grid grid-cols-2 gap-3">
<div><%= f.label :tach_time, "Tach", class: "label" %>
<%= f.number_field :tach_time, value: @aircraft.tach_time, step: 0.1, class: "input", required: true %></div>
<div><%= f.label :hobbs_time, "Hobbs", class: "label" %>
<%= f.number_field :hobbs_time, value: @aircraft.hobbs_time, step: 0.1, class: "input" %></div>
</div>
<p class="hint">Enter the current meter readings. The difference is applied to every in-service component. For a single flight, use <%= link_to "Log Flight", new_aircraft_flight_log_path(@aircraft), class: "link" %>.</p>
<%= f.submit "Update Hours", class: "btn-primary" %>
<% end %>
</section>
<section class="card">
<div class="card-header">
<h2 class="card-title">Details</h2>
<% if owner? %><%= link_to "Edit", edit_aircraft_path(@aircraft), class: "btn-secondary btn-sm" %><% end %>
</div>
<dl class="card-body grid grid-cols-2 gap-x-3 gap-y-2 text-sm">
<dt class="text-slate-500">Serial</dt><dd><%= @aircraft.serial_number.presence || "—" %></dd>
<dt class="text-slate-500">Purchased</dt><dd><%= fmt_date(@aircraft.purchased) %></dd>
<dt class="text-slate-500">Tach offset</dt><dd><%= hours(@aircraft.tach_time_offset) %></dd>
<dt class="text-slate-500">Hobbs offset</dt><dd><%= hours(@aircraft.hobbs_time_offset) %></dd>
</dl>
<% if @aircraft.description.present? %>
<p class="border-t border-slate-100 px-4 py-3 text-sm text-slate-600"><%= simple_format @aircraft.description %></p>
<% end %>
</section>
<section class="card">
<div class="card-header"><h2 class="card-title">Notes</h2>
<%= link_to "+ Add", new_aircraft_note_path(@aircraft), class: "btn-secondary btn-sm" %></div>
<% if @notes.any? %>
<ul class="divide-y divide-slate-100">
<% @notes.each do |note| %>
<li class="px-4 py-2 text-sm">
<div><%= note.text.truncate(200) %></div>
<div class="text-xs text-slate-500"><%= note.user&.display_name %> · <%= time_ago_in_words(note.created_at) %> ago <%= "· public" if note.public? %></div>
</li>
<% end %>
</ul>
<% else %>
<%= empty_state "No notes." %>
<% end %>
</section>
<section class="card">
<div class="card-header"><h2 class="card-title">Recent Activity</h2>
<%= link_to "All →", aircraft_events_path(@aircraft), class: "link text-sm" %></div>
<%= render "events/list", events: @recent_events %>
</section>
</div>
</div>
+61
View File
@@ -0,0 +1,61 @@
<% content_for :title, "#{@aircraft.tail_number} Access" %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<div class="grid gap-5 lg:grid-cols-2">
<section class="card">
<div class="card-header"><h2 class="card-title">People</h2></div>
<table class="table">
<tbody>
<% @roles.each do |r| %>
<tr>
<td><%= r.user.display_name %><div class="text-xs text-slate-500"><%= r.user.email_address %></div></td>
<td>
<%= form_with url: aircraft_aircraft_role_path(@aircraft, r), method: :patch do |f| %>
<%= f.select :role, AircraftRole::ROLES.invert, { selected: r.role }, class: "input w-28", onchange: "this.form.requestSubmit()" %>
<% end %>
</td>
<td class="text-right"><% unless r.user == current_user %><%= delete_button "Remove", aircraft_aircraft_role_path(@aircraft, r), confirm: "Remove #{r.user.display_name}'s access?" %><% end %></td>
</tr>
<% end %>
</tbody>
</table>
<%= form_with url: aircraft_aircraft_roles_path(@aircraft), class: "flex flex-wrap items-end gap-2 border-t border-slate-100 p-4" do |f| %>
<div class="flex-1"><%= f.label :email_address, "Add by email", class: "label" %><%= f.email_field :email_address, class: "input", required: true %></div>
<%= f.select :role, AircraftRole::ROLES.invert, { selected: "pilot" }, class: "input w-28" %>
<%= f.submit "Add", class: "btn-primary" %>
<% end %>
<p class="px-4 pb-4 hint"><strong>Owners</strong> can edit everything. <strong>Pilots</strong> can view all records, log flights, update hours, and add squawks, notes and oil/fuel.</p>
</section>
<section class="card">
<div class="card-header"><h2 class="card-title">Share Links</h2></div>
<% if @share_tokens.any? %>
<ul class="divide-y divide-slate-100">
<% @share_tokens.each do |t| %>
<li class="px-4 py-3">
<div class="flex items-center justify-between gap-2">
<div>
<span class="font-medium"><%= t.label.presence || "Untitled link" %></span>
<%= tag.span ShareToken::PRIVILEGES[t.privilege], class: t.maintenance? ? "badge-blue" : "badge-green" %>
<% if t.expired? %><span class="badge-red">Expired</span><% end %>
</div>
<%= delete_button "Revoke", aircraft_share_token_path(@aircraft, t), confirm: "Revoke this link? Anyone using it will lose access." %>
</div>
<input type="text" readonly value="<%= shared_url(t.token) %>" class="input mt-2 font-mono text-xs" onclick="this.select()">
<div class="mt-1 text-xs text-slate-500">Created <%= t.created_at.to_date %><%= " by #{t.created_by.display_name}" if t.created_by %> · <%= t.expires_at ? "expires #{l t.expires_at, format: :short}" : "never expires" %></div>
</li>
<% end %>
</ul>
<% else %>
<%= empty_state "No share links." %>
<% end %>
<%= form_with model: ShareToken.new, url: aircraft_share_tokens_path(@aircraft), class: "space-y-3 border-t border-slate-100 p-4" do |f| %>
<div class="grid gap-3 sm:grid-cols-3">
<%= f.field :label, placeholder: "Mechanic, buyer…" %>
<%= f.field :privilege, as: :select, label: "Shows", collection: ShareToken::PRIVILEGES.invert %>
<%= f.field :expires_at, as: :datetime, label: "Expires (optional)" %>
</div>
<p class="hint"><strong>Current Status</strong>: overview, airworthiness, components, open squawks, AD/inspection status, oil & fuel, public notes and documents shared with all links. <strong>Maintenance Detail</strong> adds the full logbook, history, resolved squawks and major records.</p>
<%= f.submit "Create Share Link" %>
<% end %>
</section>
</div>
@@ -0,0 +1,27 @@
<%= form_with model: ad, url: ad.new_record? ? aircraft_airworthiness_directives_path(aircraft) : aircraft_airworthiness_directive_path(aircraft, ad), class: "card card-body space-y-4 max-w-3xl" do |f| %>
<%= f.errors_summary %>
<div class="grid gap-4 sm:grid-cols-3">
<%= f.field :name, label: "Number", required: true, placeholder: "2011-10-09" %>
<%= f.field :bulletin_type, as: :select, label: "Type", collection: AirworthinessDirective::BULLETIN_TYPES.invert %>
<%= f.field :compliance_type, as: :select, label: "Compliance", collection: AirworthinessDirective::COMPLIANCE_TYPES.invert,
hint: "Conditional ADs only apply when a trigger occurs and don't affect airworthiness." %>
</div>
<%= f.field :short_description, required: true %>
<%= f.field :required_action, as: :textarea, rows: 3 %>
<%= f.field :trigger_condition, as: :textarea, rows: 2, hint: "For conditional ADs (e.g. “on prop strike”)." %>
<div class="flex gap-6">
<%= f.field :mandatory, as: :checkbox, label: "Mandatory" %>
<%= f.field :recurring, as: :checkbox, label: "Recurring" %>
</div>
<div class="grid gap-4 sm:grid-cols-3">
<%= f.field :recurring_hours, as: :number, step: 0.1, label: "Every (hours)" %>
<%= f.field :recurring_months, as: :number, label: "Every (months)" %>
<%= f.field :document_id, as: :select, label: "Reference document", collection: document_options(aircraft) %>
</div>
<%= render "shared/applicability_fields", aircraft: aircraft, record: ad, applies_to_airframe: @applies_to_airframe %>
<% if ad.persisted? && (ad.aircraft.count + ad.components.where.not(aircraft_id: aircraft.id).count) > 1 %>
<p class="rounded bg-amber-50 p-2 text-xs text-amber-800">This AD is shared with other aircraft; edits affect them too.</p>
<% end %>
<div class="flex gap-2"><%= f.submit "Save" %><%= link_to "Cancel", aircraft_airworthiness_directives_path(aircraft), class: "btn-secondary" %></div>
<% end %>
<% if ad.persisted? %><div class="mt-4"><%= delete_button "Remove from #{aircraft.tail_number}", aircraft_airworthiness_directive_path(aircraft, ad) %></div><% end %>
@@ -0,0 +1,2 @@
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<%= render "form", aircraft: @aircraft, ad: @ad %>
@@ -0,0 +1,70 @@
<% content_for :title, "#{@aircraft.tail_number} ADs" %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<section class="card">
<div class="card-header">
<h2 class="card-title">Airworthiness Directives & Bulletins</h2>
<% if owner? %>
<div class="flex flex-wrap items-center gap-2">
<% if @attachable.any? %>
<%= form_with url: attach_aircraft_airworthiness_directives_path(@aircraft), class: "flex gap-2" do |f| %>
<%= f.select :airworthiness_directive_id, @attachable.map { ["#{_1.name} – #{_1.short_description.truncate(40)}", _1.id] }, {}, class: "input w-64" %>
<%= f.submit "Link existing", class: "btn-secondary" %>
<% end %>
<% end %>
<%= link_to "+ New AD", new_aircraft_airworthiness_directive_path(@aircraft), class: "btn-primary" %>
</div>
<% end %>
</div>
<% if @rows.any? %>
<div class="overflow-x-auto">
<table class="table">
<thead><tr><th>AD / Bulletin</th><th>Description</th><th>Recurrence</th><th>Last complied</th><th>Next due</th><th>Status</th><th></th></tr></thead>
<tbody>
<% @rows.each do |row| ad = row.ad %>
<tr>
<td class="whitespace-nowrap font-medium"><span class="badge-gray mr-1"><%= ad.bulletin_label %></span><%= ad.name %>
<% unless ad.mandatory? %><div class="text-xs text-slate-400">not mandatory</div><% end %></td>
<td class="max-w-sm text-xs"><%= ad.short_description %>
<% if ad.conditional? && ad.trigger_condition.present? %><div class="text-slate-500">Trigger: <%= ad.trigger_condition %></div><% end %></td>
<td class="text-xs"><%= ad.recurring? ? [ad.recurring_hours.to_f > 0 && "#{hours(ad.recurring_hours)} h", ad.recurring_months > 0 && "#{ad.recurring_months} mo"].select(&:itself).join(" / ") : "One-time" %></td>
<td class="text-xs"><%= row.latest ? "#{row.latest.date_complied}#{' (permanent)' if row.latest.permanent?}" : "—" %></td>
<td class="text-xs"><%= [row.next_due_date&.strftime("%b %Y"), row.next_due_hours && "#{hours(row.next_due_hours)} h"].compact.join(" / ").presence || "—" %></td>
<td><%= compliance_badge(row.status) %></td>
<td class="whitespace-nowrap text-right">
<% if owner? %>
<%= link_to "Comply", new_aircraft_ad_compliance_path(@aircraft, ad_id: ad.id), class: "btn-secondary btn-sm" %>
<%= link_to "Edit", edit_aircraft_airworthiness_directive_path(@aircraft, ad), class: "btn-secondary btn-sm" %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
<% else %>
<%= empty_state "No ADs tracked for this aircraft." %>
<% end %>
</section>
<section class="card mt-5">
<div class="card-header"><h2 class="card-title">Compliance History</h2></div>
<% if @history.any? %>
<table class="table">
<thead><tr><th>Date</th><th>AD</th><th class="text-right">Hours</th><th>Next due (hrs)</th><th>Notes</th><th></th></tr></thead>
<tbody>
<% @history.each do |c| %>
<tr>
<td class="whitespace-nowrap"><%= c.date_complied %></td>
<td><%= c.airworthiness_directive.name %><%= " (#{c.component})" if c.component %></td>
<td class="text-right"><%= hours(c.aircraft_hours_at_compliance) %></td>
<td><%= c.permanent? ? "Permanent" : (c.next_due_at_time.to_f > 0 ? hours(c.next_due_at_time) : "—") %></td>
<td class="max-w-md text-xs"><%= c.compliance_notes %></td>
<td class="text-right"><% if owner? %><%= link_to "Edit", edit_aircraft_ad_compliance_path(@aircraft, c), class: "btn-secondary btn-sm" %><% end %></td>
</tr>
<% end %>
</tbody>
</table>
<% else %>
<%= empty_state "No compliance records." %>
<% end %>
</section>
@@ -0,0 +1,2 @@
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<%= render "form", aircraft: @aircraft, ad: @ad %>
+50
View File
@@ -0,0 +1,50 @@
<%= form_with model: [aircraft, component], class: "card card-body space-y-5 max-w-4xl" do |f| %>
<%= f.errors_summary %>
<div class="grid gap-4 sm:grid-cols-3">
<div>
<%= f.field :component_type_id, as: :select, label: "Type",
collection: ComponentType.ordered.map { [_1.name, _1.id] }, include_blank: "— Select —" %>
<%= text_field_tag :new_component_type, params[:new_component_type], class: "input mt-2", placeholder: "…or type a new one" %>
</div>
<%= f.field :manufacturer, required: true %>
<%= f.field :model, required: true %>
<%= f.field :serial_number %>
<%= f.field :install_location, hint: "e.g. Left mag, #3 cylinder" %>
<%= f.field :status, as: :select, collection: Component::STATUSES.invert %>
<%= f.field :parent_component_id, as: :select, label: "Parent component",
collection: [["— None —", nil]] + aircraft.components.where.not(id: component.id).includes(:component_type).map { [_1.to_s, _1.id] } %>
</div>
<fieldset class="grid gap-4 sm:grid-cols-4">
<legend class="mb-2 text-sm font-semibold text-slate-900">Time</legend>
<%= f.field :date_in_service, as: :date, required: true %>
<%= f.field :hours_in_service, as: :number, step: 0.1 %>
<%= f.field :overhaul_date, as: :date, label: "Last overhaul / service" %>
<%= f.field :hours_since_overhaul, as: :number, step: 0.1, label: "Hours since OH / service" %>
</fieldset>
<fieldset class="grid gap-4 sm:grid-cols-3">
<legend class="mb-2 text-sm font-semibold text-slate-900">Limits</legend>
<%= f.field :replacement_hours, as: :number, label: "Replace every (hrs)" %>
<%= f.field :replacement_days, as: :number, label: "Replace every (days)" %>
<%= f.field :replacement_critical, as: :checkbox, label: "Replacement critical", hint: "Overdue replacement grounds the aircraft (oil, filters, ELT battery…)." %>
<%= f.field :tbo_hours, as: :number, label: "TBO (hrs)" %>
<%= f.field :tbo_days, as: :number, label: "TBO (days)" %>
<div class="space-y-2">
<%= f.field :tbo_critical, as: :checkbox, label: "TBO critical" %>
<%= f.field :on_condition, as: :checkbox, label: "On condition (Part 91)" %>
</div>
<%= f.field :inspection_hours, as: :number, label: "Inspect every (hrs)" %>
<%= f.field :inspection_days, as: :number, label: "Inspect every (days)" %>
<%= f.field :inspection_critical, as: :checkbox, label: "Inspection critical" %>
</fieldset>
<%= f.field :notes, as: :textarea, rows: 3 %>
<div class="flex gap-2">
<%= f.submit component.new_record? ? "Add Component" : "Save" %>
<%= link_to "Cancel", aircraft_components_path(aircraft), class: "btn-secondary" %>
</div>
<% end %>
<% if component.persisted? %>
<div class="mt-4"><%= delete_button "Delete component", aircraft_component_path(aircraft, component), confirm: "Delete #{component} and its sub-components?" %></div>
<% end %>
+3
View File
@@ -0,0 +1,3 @@
<% content_for :title, "Edit Component" %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<%= render "form", aircraft: @aircraft, component: @component %>
+52
View File
@@ -0,0 +1,52 @@
<% content_for :title, "#{@aircraft.tail_number} Components" %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<section class="card">
<div class="card-header">
<h2 class="card-title">Components</h2>
<div class="flex items-center gap-3">
<%= link_to (@show_disposed ? "Hide disposed" : "Show disposed"),
aircraft_components_path(@aircraft, disposed: (@show_disposed ? nil : 1)), class: "link text-sm" %>
<% if owner? %><%= link_to "+ Add Component", new_aircraft_component_path(@aircraft), class: "btn-primary" %><% end %>
</div>
</div>
<% if @rows.empty? %>
<%= empty_state "No components yet. Add the engine, propeller, oil filter, ELT battery, etc." %>
<% else %>
<div class="overflow-x-auto">
<table class="table">
<thead><tr>
<th>Component</th><th>Make / Model</th><th>Status</th>
<th class="text-right">In service</th><th class="text-right">Since OH/svc</th>
<th>Limit</th><th>Life</th><th></th>
</tr></thead>
<tbody>
<% @rows.each do |c, depth| %>
<tr>
<td style="padding-left: <%= 0.75 + depth * 1.25 %>rem">
<%= "↳ " if depth > 0 %><%= link_to c.component_type.name, aircraft_component_path(@aircraft, c), class: "link font-medium" %>
<% if c.install_location.present? %><div class="text-xs text-slate-500"><%= c.install_location %></div><% end %>
</td>
<td><%= c.manufacturer %> <%= c.model %><% if c.serial_number.present? %><div class="text-xs text-slate-500">S/N <%= c.serial_number %></div><% end %></td>
<td><%= tag.span c.status_label, class: { "IN-USE" => "badge-green", "SPARE" => "badge-gray", "DISPOSED" => "badge-gray" }[c.status] %></td>
<td class="text-right tabular-nums"><%= hours(c.hours_in_service) %></td>
<td class="text-right tabular-nums"><%= hours(c.hours_since_overhaul) %></td>
<td class="text-xs text-slate-600">
<% if c.replacement_critical? && (c.replacement_hours || c.replacement_days) %>
Replace: <%= [c.replacement_hours && "#{c.replacement_hours} h", c.replacement_days && "#{c.replacement_days} d"].compact.join(" / ") %><br>
<% end %>
<% if c.tbo_critical? && c.tbo_hours %>TBO: <%= c.tbo_hours %> h<%= " (on condition)" if c.on_condition? %><% end %>
</td>
<td><%= life_badge(c.life_status) %></td>
<td class="whitespace-nowrap text-right">
<% if owner? %>
<%= link_to "Edit", edit_aircraft_component_path(@aircraft, c), class: "btn-secondary btn-sm" %>
<%= link_to "Service", aircraft_component_path(@aircraft, c, anchor: "service"), class: "btn-secondary btn-sm" %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
<% end %>
</section>
+3
View File
@@ -0,0 +1,3 @@
<% content_for :title, "Add Component" %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<%= render "form", aircraft: @aircraft, component: @component %>
+61
View File
@@ -0,0 +1,61 @@
<% content_for :title, @component.to_s %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<div class="grid gap-5 lg:grid-cols-3">
<section class="card lg:col-span-2">
<div class="card-header">
<h2 class="card-title"><%= @component %> <%= life_badge(@component.life_status) %></h2>
<% if owner? %>
<div class="flex gap-2">
<%= link_to "+ Sub-component", new_aircraft_component_path(@aircraft, parent_id: @component.id), class: "btn-secondary btn-sm" %>
<%= link_to "Edit", edit_aircraft_component_path(@aircraft, @component), class: "btn-secondary btn-sm" %>
</div>
<% end %>
</div>
<dl class="card-body grid grid-cols-2 gap-x-4 gap-y-2 text-sm sm:grid-cols-4">
<dt class="text-slate-500">Manufacturer</dt><dd><%= @component.manufacturer %></dd>
<dt class="text-slate-500">Model</dt><dd><%= @component.model %></dd>
<dt class="text-slate-500">Serial</dt><dd><%= @component.serial_number.presence || "—" %></dd>
<dt class="text-slate-500">Status</dt><dd><%= @component.status_label %></dd>
<dt class="text-slate-500">Parent</dt><dd><%= @component.parent_component ? link_to(@component.parent_component, aircraft_component_path(@aircraft, @component.parent_component), class: "link") : "—" %></dd>
<dt class="text-slate-500">Location</dt><dd><%= @component.install_location.presence || "—" %></dd>
<dt class="text-slate-500">In service since</dt><dd><%= fmt_date(@component.date_in_service) %></dd>
<dt class="text-slate-500">Last OH / service</dt><dd><%= fmt_date(@component.overhaul_date) %></dd>
<dt class="text-slate-500">Hours in service</dt><dd><%= hours(@component.hours_in_service) %></dd>
<dt class="text-slate-500">Since OH / service</dt><dd><%= hours(@component.hours_since_overhaul) %></dd>
<dt class="text-slate-500">TBO</dt><dd><%= @component.tbo_hours ? "#{@component.tbo_hours} h (#{hours(@component.hours_to_tbo)} remaining)" : "—" %></dd>
<dt class="text-slate-500">Replacement</dt><dd>
<%= [@component.replacement_hours && "#{@component.replacement_hours} h", @component.replacement_days && "#{@component.replacement_days} d"].compact.join(" / ").presence || "—" %>
<% if (d = @component.next_replacement_date) %><div class="text-xs text-slate-500">Next by <%= fmt_date(d) %></div><% end %>
</dd>
<dt class="text-slate-500">Flags</dt>
<dd class="col-span-3 flex flex-wrap gap-1">
<% { tbo_critical: "TBO critical", replacement_critical: "Replacement critical", inspection_critical: "Inspection critical", on_condition: "On condition" }.each do |flag, label| %>
<% if @component.public_send("#{flag}?") %><span class="badge-blue"><%= label %></span><% end %>
<% end %>
</dd>
</dl>
<% if @component.notes.present? %><div class="border-t border-slate-100 px-4 py-3 text-sm"><%= simple_format @component.notes %></div><% end %>
</section>
<% if owner? %>
<section class="card" id="service">
<div class="card-header"><h2 class="card-title">Service / Replace</h2></div>
<%= form_with url: reset_service_aircraft_component_path(@aircraft, @component), method: :post, class: "card-body space-y-3",
data: { turbo_confirm: "Reset hours for #{@component}?" } do |f| %>
<p class="text-sm text-slate-600">Resets <strong>hours since overhaul</strong> to 0 and sets the service date to today.</p>
<label class="flex items-start gap-2 text-sm">
<%= f.check_box :reset_in_service, class: "mt-0.5 h-4 w-4" %>
<span>Part was physically <strong>replaced</strong> — also reset hours in service and in-service date.</span>
</label>
<%= f.submit "Record Service", class: "btn-primary" %>
<% end %>
</section>
<% end %>
</div>
<% if @squawks.any? %>
<section class="card mt-5">
<div class="card-header"><h2 class="card-title">Squawks on this component</h2></div>
<%= render "squawks/table", squawks: @squawks, aircraft: @aircraft %>
</section>
<% end %>
@@ -0,0 +1,15 @@
<%= form_with model: [aircraft, record], class: "card card-body space-y-4 max-w-2xl" do |f| %>
<%= f.errors_summary %>
<div class="grid gap-4 sm:grid-cols-2">
<%= f.field :record_type, as: :select, label: "Type", collection: ConsumableRecord::TYPES.invert %>
<%= f.field :date, as: :date %>
<%= f.field :quantity_added, as: :number, step: 0.01, label: "Quantity added (qt / gal)" %>
<%= f.field :level_after, as: :number, step: 0.01, label: "Level after" %>
<%= f.field :consumable_type, label: "Product", placeholder: "Aeroshell W100 / 100LL" %>
<%= f.field :flight_hours, as: :number, step: 0.1, label: "Tach at time of record" %>
</div>
<%= f.field :notes, as: :textarea, rows: 2 %>
<%= f.field :excluded_from_averages, as: :checkbox, label: "Exclude from averages", hint: "Use for oil changes or partial fills that would skew the trend." %>
<div class="flex gap-2"><%= f.submit "Save" %><%= link_to "Cancel", aircraft_consumable_records_path(aircraft), class: "btn-secondary" %></div>
<% end %>
<% if record.persisted? %><div class="mt-4"><%= delete_button "Delete record", aircraft_consumable_record_path(aircraft, record) %></div><% end %>
@@ -0,0 +1,2 @@
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<%= render "form", aircraft: @aircraft, record: @record %>
@@ -0,0 +1,51 @@
<% content_for :title, "#{@aircraft.tail_number} Oil & Fuel" %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<div class="grid gap-5 lg:grid-cols-2">
<% [@oil, @fuel].each do |stats| %>
<section class="card">
<div class="card-header">
<h2 class="card-title"><%= stats.oil? ? "Oil Consumption" : "Fuel Burn" %></h2>
<%= link_to "+ Add #{stats.oil? ? 'Oil' : 'Fuel'}", new_aircraft_consumable_record_path(@aircraft, type: stats.record_type), class: "btn-secondary btn-sm" %>
</div>
<div class="card-body">
<div class="mb-3 flex gap-6 text-sm">
<div><span class="text-2xl font-semibold"><%= stats.average || "—" %></span> <span class="text-slate-500"><%= stats.metric_label %> avg (last 20)</span></div>
<div><span class="text-lg"><%= stats.latest || "—" %></span> <span class="text-slate-500">latest</span></div>
</div>
<% if stats.points.size >= 2 %>
<%= line_chart stats.chart_data, xtitle: "Tach hours", ytitle: stats.metric_label, height: "220px",
library: { scales: { x: { type: "linear" } } }, colors: [stats.oil? ? "#b45309" : "#0369a1"] %>
<% else %>
<%= empty_state "Add at least three records to see a trend." %>
<% end %>
</div>
</section>
<% end %>
</div>
<section class="card mt-5">
<div class="card-header"><h2 class="card-title">Records</h2></div>
<% if @records.any? %>
<div class="overflow-x-auto">
<table class="table">
<thead><tr><th>Date</th><th>Type</th><th class="text-right">Added</th><th class="text-right">Level after</th><th>Product</th><th class="text-right">Tach</th><th>Notes</th><th></th></tr></thead>
<tbody>
<% @records.each do |r| %>
<tr>
<td class="whitespace-nowrap"><%= r.date %></td>
<td><%= tag.span ConsumableRecord::TYPES[r.record_type], class: r.record_type == "oil" ? "badge-orange" : "badge-blue" %></td>
<td class="text-right tabular-nums"><%= r.quantity_added %> <%= r.unit %></td>
<td class="text-right tabular-nums"><%= r.level_after ? "#{r.level_after} #{r.unit}" : "" %></td>
<td><%= r.consumable_type %></td>
<td class="text-right tabular-nums"><%= hours(r.flight_hours) %></td>
<td class="text-xs text-slate-500"><%= r.notes %><%= " (excluded from average)" if r.excluded_from_averages? %></td>
<td class="text-right"><% if owner? %><%= link_to "Edit", edit_aircraft_consumable_record_path(@aircraft, r), class: "btn-secondary btn-sm" %><% end %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
<% else %>
<%= empty_state "No oil or fuel records yet." %>
<% end %>
</section>
@@ -0,0 +1,2 @@
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<%= render "form", aircraft: @aircraft, record: @record %>
@@ -0,0 +1,9 @@
<%= form_with model: [aircraft, collection], class: "card card-body space-y-4 max-w-2xl" do |f| %>
<%= f.errors_summary %>
<%= f.field :name, required: true %>
<%= f.field :description, as: :textarea, rows: 2 %>
<%= f.field :visibility, as: :select, label: "Share-link visibility", collection: DocumentCollection::VISIBILITIES.invert %>
<%= f.field :starred, as: :checkbox, label: "Starred (shown first)" %>
<div class="flex gap-2"><%= f.submit "Save Collection" %><%= link_to "Cancel", aircraft_documents_path(aircraft), class: "btn-secondary" %></div>
<% end %>
<% if collection.persisted? %><div class="mt-4"><%= delete_button "Delete collection and its documents", aircraft_document_collection_path(aircraft, collection) %></div><% end %>
@@ -0,0 +1,2 @@
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<%= render "form", aircraft: @aircraft, collection: @collection %>
@@ -0,0 +1,2 @@
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<%= render "form", aircraft: @aircraft, collection: @collection %>
+11
View File
@@ -0,0 +1,11 @@
<li class="flex items-center justify-between gap-3 px-4 py-2">
<div>
<%= link_to doc.name, aircraft_document_path(aircraft, doc), class: "link font-medium" %>
<span class="ml-2 text-xs text-slate-500"><%= doc.type_label %> · <%= pluralize(doc.pages.size, "file") %></span>
<% if doc.description.present? %><div class="text-xs text-slate-500"><%= doc.description.truncate(120) %></div><% end %>
</div>
<div class="flex items-center gap-2">
<%= visibility_badge(doc.effective_visibility) %>
<% if owner? %><%= link_to "Edit", edit_aircraft_document_path(aircraft, doc), class: "btn-secondary btn-sm" %><% end %>
</div>
</li>
+24
View File
@@ -0,0 +1,24 @@
<%= form_with model: [aircraft, document], class: "card card-body space-y-4 max-w-3xl", multipart: true do |f| %>
<%= f.errors_summary %>
<div class="grid gap-4 sm:grid-cols-2">
<%= f.field :name, required: true %>
<%= f.field :doc_type, as: :select, label: "Type", collection: Document::TYPES.invert %>
<%= f.field :document_collection_id, as: :select, label: "Collection",
collection: [["— None —", nil]] + aircraft.document_collections.ordered.map { [_1.name, _1.id] } %>
<%= f.field :visibility, as: :select, label: "Share-link visibility",
collection: [["Inherit from collection", nil]] + DocumentCollection::VISIBILITIES.invert.to_a %>
</div>
<%= f.field :description, as: :textarea, rows: 2 %>
<%= f.field :pages, as: :file, multiple: true, label: document.persisted? ? "Add files" : "Files",
hint: "Images, PDFs or text. Each file is a page in the viewer, in upload order." %>
<% if document.persisted? && document.pages.any? %>
<div>
<p class="label">Remove existing files</p>
<% document.pages.each do |p| %>
<label class="flex items-center gap-2 text-sm"><%= check_box_tag "remove_page_ids[]", p.id, false %> <%= p.filename %></label>
<% end %>
</div>
<% end %>
<div class="flex gap-2"><%= f.submit "Save Document" %><%= link_to "Cancel", aircraft_documents_path(aircraft), class: "btn-secondary" %></div>
<% end %>
<% if document.persisted? %><div class="mt-4"><%= delete_button "Delete document", aircraft_document_path(aircraft, document) %></div><% end %>
+21
View File
@@ -0,0 +1,21 @@
<%# Multi-page viewer: one attachment per "page", with prev/next. %>
<% pages = document.pages.to_a %>
<% if pages.empty? %>
<%= empty_state "No files uploaded." %>
<% else %>
<% current = pages[page - 1] %>
<div class="mb-3 flex items-center justify-between text-sm">
<%= link_to "← Prev", url_for(page: page - 1), class: ["btn-secondary btn-sm", ("pointer-events-none opacity-40" if page <= 1)] %>
<span>Page <%= page %> of <%= pages.size %> · <%= link_to current.filename, rails_blob_path(current, disposition: :attachment), class: "link" %></span>
<%= link_to "Next →", url_for(page: page + 1), class: ["btn-secondary btn-sm", ("pointer-events-none opacity-40" if page >= pages.size)] %>
</div>
<div class="flex justify-center rounded bg-slate-50 p-2">
<% if current.image? %>
<%= image_tag rails_blob_path(current, disposition: :inline), class: "max-h-[80vh] max-w-full" %>
<% elsif current.content_type == "application/pdf" %>
<iframe src="<%= rails_blob_path(current, disposition: :inline) %>" class="h-[80vh] w-full"></iframe>
<% else %>
<p class="p-6 text-sm"><%= link_to "Download #{current.filename}", rails_blob_path(current, disposition: :attachment), class: "link" %></p>
<% end %>
</div>
<% end %>
+2
View File
@@ -0,0 +1,2 @@
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<%= render "form", aircraft: @aircraft, document: @document %>
+39
View File
@@ -0,0 +1,39 @@
<% content_for :title, "#{@aircraft.tail_number} Documents" %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<div class="mb-4 flex justify-end gap-2">
<% if owner? %>
<%= link_to "+ Collection", new_aircraft_document_collection_path(@aircraft), class: "btn-secondary" %>
<%= link_to "+ Upload Document", new_aircraft_document_path(@aircraft), class: "btn-primary" %>
<% end %>
</div>
<% if @collections.empty? && @uncollected.empty? %>
<div class="card"><%= empty_state "No documents yet. Upload logbook scans, 337s, weight & balance, receipts…" %></div>
<% 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 %>
</div>
<div class="flex items-center gap-2">
<%= visibility_badge(col.visibility) %>
<% if owner? %>
<%= link_to "+ Document", new_aircraft_document_path(@aircraft, collection_id: col.id), class: "btn-secondary btn-sm" %>
<%= link_to "Edit", edit_aircraft_document_collection_path(@aircraft, col), class: "btn-secondary btn-sm" %>
<% end %>
</div>
</div>
<% 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>
<% end %>
<% if @uncollected.any? %>
<section class="card">
<div class="card-header"><h2 class="card-title">Uncollected</h2></div>
<ul class="divide-y divide-slate-100"><% @uncollected.each do |doc| %><%= render "documents/doc_row", doc: doc, aircraft: @aircraft %><% end %></ul>
</section>
<% end %>
</div>
+2
View File
@@ -0,0 +1,2 @@
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<%= render "form", aircraft: @aircraft, document: @document %>
+18
View File
@@ -0,0 +1,18 @@
<% content_for :title, @document.name %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<section class="card">
<div class="card-header">
<div>
<h2 class="card-title"><%= @document.name %></h2>
<p class="text-xs text-slate-500"><%= @document.type_label %><%= " · #{@document.document_collection.name}" if @document.document_collection %></p>
</div>
<div class="flex items-center gap-2">
<%= visibility_badge(@document.effective_visibility) %>
<% if owner? %><%= link_to "Edit", edit_aircraft_document_path(@aircraft, @document), class: "btn-secondary btn-sm" %><% end %>
</div>
</div>
<div class="card-body">
<% if @document.description.present? %><p class="mb-3 text-sm text-slate-600"><%= @document.description %></p><% end %>
<%= render "documents/viewer", document: @document, page: @page %>
</div>
</section>
+5
View File
@@ -0,0 +1,5 @@
<div class="card mx-auto max-w-lg card-body text-center">
<h1 class="text-lg font-semibold">Not found</h1>
<p class="mt-2 text-sm text-slate-600">That page doesn't exist, or you don't have access to it.</p>
<% if current_user %><p class="mt-4"><%= link_to "Back to fleet", root_path, class: "btn-secondary" %></p><% end %>
</div>
+16
View File
@@ -0,0 +1,16 @@
<% if events.any? %>
<ul class="divide-y divide-slate-100">
<% events.each do |e| %>
<li class="px-4 py-2 text-sm">
<div class="flex items-center justify-between gap-2">
<span><%= e.event_name %></span>
<span class="badge-gray"><%= AircraftEvent::CATEGORIES[e.category] %></span>
</div>
<div class="text-xs text-slate-500"><%= e.user&.display_name || "System" %> · <%= time_ago_in_words(e.created_at) %> ago</div>
<% if e.notes.present? && local_assigns[:full] %><div class="mt-1 text-xs text-slate-600"><%= e.notes %></div><% end %>
</li>
<% end %>
</ul>
<% else %>
<%= empty_state "No activity yet." %>
<% end %>
+11
View File
@@ -0,0 +1,11 @@
<% content_for :title, "#{@aircraft.tail_number} Activity" %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<section class="card">
<div class="card-header">
<h2 class="card-title">Activity Log</h2>
<%= form_with url: aircraft_events_path(@aircraft), method: :get, class: "flex gap-2" do |f| %>
<%= f.select :category, AircraftEvent::CATEGORIES.invert, { include_blank: "All categories", selected: @category }, class: "input", onchange: "this.form.requestSubmit()" %>
<% end %>
</div>
<%= render "events/list", events: @events, full: true %>
</section>
+28
View File
@@ -0,0 +1,28 @@
<% content_for :title, "#{@aircraft.tail_number} Flights" %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<section class="card">
<div class="card-header"><h2 class="card-title">Flight Log</h2><%= link_to "+ Log Flight", new_aircraft_flight_log_path(@aircraft), class: "btn-primary" %></div>
<% if @flight_logs.any? %>
<div class="overflow-x-auto">
<table class="table">
<thead><tr><th>Date</th><th>Route</th><th class="text-right">Tach</th><th class="text-right">Hobbs</th><th class="text-right">Oil</th><th class="text-right">Fuel</th><th>Pilot</th><th></th></tr></thead>
<tbody>
<% @flight_logs.each do |fl| %>
<tr>
<td class="whitespace-nowrap"><%= link_to fl.date, aircraft_flight_log_path(@aircraft, fl), class: "link" %></td>
<td><%= fl.route_summary.presence || "—" %></td>
<td class="text-right tabular-nums"><%= hours(fl.tach_time) %></td>
<td class="text-right tabular-nums"><%= hours(fl.hobbs_time) %></td>
<td class="text-right tabular-nums"><%= fl.oil_added ? "#{fl.oil_added} qt" : "" %></td>
<td class="text-right tabular-nums"><%= fl.fuel_added ? "#{fl.fuel_added} gal" : "" %></td>
<td class="text-xs"><%= fl.user&.display_name %></td>
<td class="text-right"><%= "📍" if fl.track_log.attached? %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
<% else %>
<%= empty_state "No flights logged yet." %>
<% end %>
</section>
+36
View File
@@ -0,0 +1,36 @@
<% content_for :title, "Log Flight" %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<%= form_with model: [@aircraft, @flight_log], class: "card card-body space-y-5 max-w-3xl" do |f| %>
<%= f.errors_summary %>
<div class="grid gap-4 sm:grid-cols-3">
<%= f.field :date, as: :date, required: true %>
<%= f.field :departure_location, label: "From", placeholder: "KPVD" %>
<%= f.field :destination_location, label: "To", placeholder: "KBID" %>
</div>
<fieldset class="grid gap-4 sm:grid-cols-3">
<legend class="mb-2 text-sm font-semibold">Tach (required)</legend>
<%= f.field :tach_out, as: :number, step: 0.1, label: "Tach out" %>
<%= f.field :tach_in, as: :number, step: 0.1, label: "Tach in" %>
<%= f.field :tach_time, as: :number, step: 0.1, label: "…or duration", hint: "Calculated from out/in if blank." %>
</fieldset>
<fieldset class="grid gap-4 sm:grid-cols-3">
<legend class="mb-2 text-sm font-semibold">Hobbs (optional)</legend>
<%= f.field :hobbs_out, as: :number, step: 0.1, label: "Hobbs out" %>
<%= f.field :hobbs_in, as: :number, step: 0.1, label: "Hobbs in" %>
<%= f.field :hobbs_time, as: :number, step: 0.1, label: "…or duration" %>
</fieldset>
<fieldset class="grid gap-4 sm:grid-cols-3">
<legend class="mb-2 text-sm font-semibold">Oil & fuel added</legend>
<%= f.field :oil_added, as: :number, step: 0.25, label: "Oil added (qt)" %>
<%= f.field :oil_level_after, as: :number, step: 0.25, label: "Oil level after (qt)" %>
<%= f.field :oil_added_type, label: "Oil type", placeholder: "Aeroshell W100" %>
<%= f.field :fuel_added, as: :number, step: 0.1, label: "Fuel added (gal)" %>
<%= f.field :fuel_level_after, as: :number, step: 0.1, label: "Fuel level after (gal)" %>
<%= f.field :fuel_added_type, label: "Fuel type", placeholder: "100LL" %>
</fieldset>
<%= f.field :route, as: :textarea, rows: 2 %>
<%= f.field :notes, as: :textarea, rows: 2 %>
<%= f.field :track_log, as: :file, label: "Track log (GPX/KML/CSV)" %>
<p class="hint">Saving adds the tach time to the aircraft and all in-service components, and records any oil/fuel added.</p>
<div class="flex gap-2"><%= f.submit "Log Flight" %><%= link_to "Cancel", aircraft_flight_logs_path(@aircraft), class: "btn-secondary" %></div>
<% end %>
+15
View File
@@ -0,0 +1,15 @@
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<section class="card max-w-3xl">
<div class="card-header"><h2 class="card-title">Flight on <%= fmt_date(@flight_log.date) %></h2>
<% if owner? %><%= delete_button "Delete", aircraft_flight_log_path(@aircraft, @flight_log), confirm: "Delete this flight log? Aircraft and component hours will NOT be rolled back." %><% end %></div>
<dl class="card-body grid grid-cols-2 gap-x-4 gap-y-2 text-sm sm:grid-cols-4">
<dt class="text-slate-500">Tach</dt><dd><%= hours(@flight_log.tach_time) %> <span class="text-xs text-slate-500"><%= "(#{@flight_log.tach_out} → #{@flight_log.tach_in})" if @flight_log.tach_out && @flight_log.tach_in %></span></dd>
<dt class="text-slate-500">Hobbs</dt><dd><%= hours(@flight_log.hobbs_time) %> <span class="text-xs text-slate-500"><%= "(#{@flight_log.hobbs_out} → #{@flight_log.hobbs_in})" if @flight_log.hobbs_out && @flight_log.hobbs_in %></span></dd>
<dt class="text-slate-500">Route</dt><dd class="col-span-3"><%= @flight_log.route_summary.presence || "—" %> <%= @flight_log.route %></dd>
<dt class="text-slate-500">Oil added</dt><dd><%= @flight_log.oil_added ? "#{@flight_log.oil_added} qt #{@flight_log.oil_added_type}" : "—" %></dd>
<dt class="text-slate-500">Fuel added</dt><dd><%= @flight_log.fuel_added ? "#{@flight_log.fuel_added} gal #{@flight_log.fuel_added_type}" : "—" %></dd>
<dt class="text-slate-500">Pilot</dt><dd><%= @flight_log.user&.display_name || "—" %></dd>
<dt class="text-slate-500">Track log</dt><dd><%= @flight_log.track_log.attached? ? link_to(@flight_log.track_log.filename, rails_blob_path(@flight_log.track_log, disposition: :attachment), class: "link") : "—" %></dd>
</dl>
<% if @flight_log.notes.present? %><div class="border-t border-slate-100 px-4 py-3 text-sm"><%= simple_format @flight_log.notes %></div><% end %>
</section>
@@ -0,0 +1,13 @@
<%= form_with model: record, url: record.new_record? ? aircraft_inspection_records_path(aircraft) : aircraft_inspection_record_path(aircraft, record), class: "card card-body space-y-4 max-w-2xl" do |f| %>
<%= f.errors_summary %>
<%= f.field :inspection_type_id, as: :select, label: "Inspection", collection: aircraft.applicable_inspection_types.ordered.map { [_1.name, _1.id] } %>
<div class="grid gap-4 sm:grid-cols-2">
<%= f.field :date, as: :date %>
<%= f.field :aircraft_hours, as: :number, step: 0.1, label: "Aircraft hours (tach)" %>
<%= f.field :component_id, as: :select, label: "Component (if component-level)", collection: component_options(aircraft) %>
<%= f.field :logbook_entry_id, as: :select, label: "Logbook entry", collection: logbook_options(aircraft) %>
</div>
<%= f.field :notes, as: :textarea, rows: 2 %>
<div class="flex gap-2"><%= f.submit "Save" %><%= link_to "Cancel", aircraft_inspections_path(aircraft), class: "btn-secondary" %></div>
<% end %>
<% if record.persisted? %><div class="mt-4"><%= delete_button "Delete record", aircraft_inspection_record_path(aircraft, record) %></div><% end %>
@@ -0,0 +1,2 @@
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<%= render "form", aircraft: @aircraft, record: @record %>
@@ -0,0 +1,2 @@
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<%= render "form", aircraft: @aircraft, record: @record %>
+19
View File
@@ -0,0 +1,19 @@
<%= form_with model: inspection_type, url: inspection_type.new_record? ? aircraft_inspection_types_path(aircraft) : aircraft_inspection_type_path(aircraft, inspection_type), class: "card card-body space-y-4 max-w-2xl" do |f| %>
<%= f.errors_summary %>
<%= f.field :name, required: true, placeholder: "Annual Inspection" %>
<div class="flex gap-6">
<%= f.field :required, as: :checkbox, label: "Required for airworthiness" %>
<%= f.field :recurring, as: :checkbox, label: "Recurring" %>
</div>
<div class="grid gap-4 sm:grid-cols-3">
<%= f.field :recurring_hours, as: :number, step: 0.1, label: "Every (hours)" %>
<%= f.field :recurring_months, as: :number, label: "Every (calendar months)", hint: "Due end of month." %>
<%= f.field :recurring_days, as: :number, label: "Every (days)" %>
</div>
<%= render "shared/applicability_fields", aircraft: aircraft, record: inspection_type, applies_to_airframe: @applies_to_airframe %>
<% if inspection_type.persisted? && inspection_type.aircraft.count > 1 %>
<p class="rounded bg-amber-50 p-2 text-xs text-amber-800">This inspection type is shared with other aircraft; interval changes affect them too.</p>
<% end %>
<div class="flex gap-2"><%= f.submit "Save" %><%= link_to "Cancel", aircraft_inspections_path(aircraft), class: "btn-secondary" %></div>
<% end %>
<% if inspection_type.persisted? %><div class="mt-4"><%= delete_button "Remove from #{aircraft.tail_number}", aircraft_inspection_type_path(aircraft, inspection_type) %></div><% end %>
+2
View File
@@ -0,0 +1,2 @@
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<%= render "form", aircraft: @aircraft, inspection_type: @inspection_type %>
+2
View File
@@ -0,0 +1,2 @@
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<%= render "form", aircraft: @aircraft, inspection_type: @inspection_type %>
+54
View File
@@ -0,0 +1,54 @@
<% content_for :title, "#{@aircraft.tail_number} Inspections" %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<section class="card">
<div class="card-header"><h2 class="card-title">Inspection Status</h2>
<% if owner? %><%= link_to "+ Inspection Type", new_aircraft_inspection_type_path(@aircraft), class: "btn-primary" %><% end %></div>
<% if @rows.any? %>
<div class="overflow-x-auto">
<table class="table">
<thead><tr><th>Inspection</th><th>Interval</th><th>Last done</th><th>Next due</th><th>Status</th><th></th></tr></thead>
<tbody>
<% @rows.each do |row| %>
<tr>
<td class="font-medium"><%= row.type.name %><%= tag.span(" optional", class: "text-xs text-slate-400") unless row.type.required? %></td>
<td class="text-xs"><%= row.type.interval_description %></td>
<td class="text-xs"><%= row.latest ? "#{row.latest.date} @ #{hours(row.latest.hours_at_inspection)} h" : "—" %></td>
<td class="text-xs"><%= [row.next_due_date&.to_s, row.next_due_hours && "#{hours(row.next_due_hours)} h"].compact.join(" / ").presence || "—" %></td>
<td><%= compliance_badge(row.status) %></td>
<td class="whitespace-nowrap text-right">
<% if owner? %>
<%= link_to "Record", new_aircraft_inspection_record_path(@aircraft, inspection_type_id: row.type.id), class: "btn-secondary btn-sm" %>
<%= link_to "Edit", edit_aircraft_inspection_type_path(@aircraft, row.type), class: "btn-secondary btn-sm" %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
<% else %>
<%= empty_state "No inspections tracked. Add Annual, 100-hour, transponder (91.413), pitot-static (91.411), ELT (91.207)…" %>
<% end %>
</section>
<section class="card mt-5">
<div class="card-header"><h2 class="card-title">History</h2></div>
<% if @history.any? %>
<table class="table">
<thead><tr><th>Date</th><th>Inspection</th><th class="text-right">Hours</th><th>Notes</th><th></th></tr></thead>
<tbody>
<% @history.each do |r| %>
<tr>
<td><%= r.date %></td>
<td><%= r.inspection_type.name %><%= " (#{r.component})" if r.component %></td>
<td class="text-right"><%= hours(r.hours_at_inspection) %></td>
<td class="text-xs"><%= r.notes %><% if r.logbook_entry %> <%= link_to "logbook", aircraft_logbook_entry_path(@aircraft, r.logbook_entry), class: "link" %><% end %></td>
<td class="text-right"><% if owner? %><%= link_to "Edit", edit_aircraft_inspection_record_path(@aircraft, r), class: "btn-secondary btn-sm" %><% end %></td>
</tr>
<% end %>
</tbody>
</table>
<% else %>
<%= empty_state "No inspections recorded." %>
<% end %>
</section>
+43
View File
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<html class="h-full bg-slate-100">
<head>
<title><%= [content_for(:title), "Simple Aircraft Manager"].compact.join(" · ") %></title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<%= yield :head %>
<link rel="icon" href="/icon.png" type="image/png">
<link rel="icon" href="/icon.svg" type="image/svg+xml">
<link rel="apple-touch-icon" href="/icon.png">
<%= stylesheet_link_tag :app, "data-turbo-track": "reload" %>
<%= javascript_importmap_tags %>
</head>
<body class="min-h-full text-slate-800">
<header class="bg-slate-900 text-white">
<div class="mx-auto flex max-w-7xl items-center justify-between gap-4 px-4 py-3">
<%= link_to root_path, class: "flex items-center gap-2 font-semibold tracking-tight" do %>
<span class="text-xl">✈</span> Simple Aircraft Manager
<% end %>
<% if current_user %>
<nav class="flex items-center gap-4 text-sm">
<%= link_to "Fleet", root_path, class: "hover:text-sky-300" %>
<% if current_user.admin? %>
<%= link_to "Users", admin_users_path, class: "hover:text-sky-300" %>
<%= link_to "Component Types", admin_component_types_path, class: "hover:text-sky-300 hidden sm:inline" %>
<% end %>
<%= link_to current_user.display_name, edit_profile_path, class: "text-slate-300 hover:text-sky-300 hidden sm:inline" %>
<%= button_to "Sign out", session_path, method: :delete, class: "rounded bg-slate-700 px-2 py-1 hover:bg-slate-600" %>
</nav>
<% end %>
</div>
</header>
<main class="mx-auto max-w-7xl px-4 py-6">
<%= render "shared/flash" %>
<%= yield %>
</main>
</body>
</html>
+13
View File
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style>
/* Email styles need to be inline */
</style>
</head>
<body>
<%= yield %>
</body>
</html>
+1
View File
@@ -0,0 +1 @@
<%= yield %>
+22
View File
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html class="h-full bg-slate-100">
<head>
<title><%= [content_for(:title), "Simple Aircraft Manager"].compact.join(" · ") %></title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="robots" content="noindex, nofollow">
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<link rel="icon" href="/icon.png" type="image/png">
<%= stylesheet_link_tag :app, "data-turbo-track": "reload" %>
<%= javascript_importmap_tags %>
</head>
<body class="min-h-full text-slate-800">
<header class="bg-slate-900 text-white">
<div class="mx-auto max-w-7xl px-4 py-3 font-semibold"><span class="text-xl">✈</span> Simple Aircraft Manager</div>
</header>
<main class="mx-auto max-w-7xl px-4 py-6">
<%= render "shared/flash" %>
<%= yield %>
</main>
</body>
</html>
+18
View File
@@ -0,0 +1,18 @@
<%= form_with model: [aircraft, entry], class: "card card-body space-y-4 max-w-3xl" do |f| %>
<%= f.errors_summary %>
<div class="grid gap-4 sm:grid-cols-4">
<%= f.field :date, as: :date %>
<%= f.field :log_type, as: :select, label: "Logbook", collection: LogbookEntry::LOG_TYPES.invert %>
<%= f.field :entry_type, as: :select, label: "Entry type", collection: LogbookEntry::ENTRY_TYPES.invert %>
<%= f.field :aircraft_hours_at_entry, as: :number, step: 0.1, label: "Aircraft hours" %>
</div>
<%= f.field :text, as: :textarea, label: "Entry text", rows: 8 %>
<div class="grid gap-4 sm:grid-cols-2">
<%= f.field :signoff_person, label: "Signed off by", placeholder: "Name, A&P/IA #" %>
<%= f.field :signoff_location, label: "Location / shop" %>
<%= f.field :document_id, as: :select, label: "Scanned page document", collection: document_options(aircraft) %>
<%= f.field :page_number, as: :number, label: "Page # in document" %>
</div>
<div class="flex gap-2"><%= f.submit "Save Entry" %><%= link_to "Cancel", aircraft_logbook_entries_path(aircraft), class: "btn-secondary" %></div>
<% end %>
<% if entry.persisted? %><div class="mt-4"><%= delete_button "Delete entry", aircraft_logbook_entry_path(aircraft, entry) %></div><% end %>
+2
View File
@@ -0,0 +1,2 @@
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<%= render "form", aircraft: @aircraft, entry: @entry %>
+36
View File
@@ -0,0 +1,36 @@
<% content_for :title, "#{@aircraft.tail_number} Logbook" %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<section class="card">
<div class="card-header">
<h2 class="card-title">Maintenance Logbook</h2>
<div class="flex flex-wrap items-center gap-2">
<%= form_with url: aircraft_logbook_entries_path(@aircraft), method: :get, class: "flex gap-2" do |f| %>
<%= f.search_field :q, value: @query, placeholder: "Search entries…", class: "input w-48" %>
<%= f.select :log_type, LogbookEntry::LOG_TYPES.invert, { include_blank: "All logs", selected: @log_type }, class: "input w-32" %>
<%= f.submit "Filter", class: "btn-secondary" %>
<% end %>
<% if owner? %><%= link_to "+ New Entry", new_aircraft_logbook_entry_path(@aircraft), class: "btn-primary" %><% end %>
</div>
</div>
<% if @entries.any? %>
<div class="overflow-x-auto">
<table class="table">
<thead><tr><th>Date</th><th>Log</th><th>Type</th><th class="text-right">Hours</th><th>Entry</th><th>Signed off</th></tr></thead>
<tbody>
<% @entries.each do |e| %>
<tr>
<td class="whitespace-nowrap"><%= link_to e.date, aircraft_logbook_entry_path(@aircraft, e), class: "link" %></td>
<td><span class="badge-gray"><%= LogbookEntry::LOG_TYPES[e.log_type] %></span></td>
<td class="text-xs"><%= LogbookEntry::ENTRY_TYPES[e.entry_type] %></td>
<td class="text-right tabular-nums"><%= hours(e.aircraft_hours_at_entry) %></td>
<td class="max-w-xl"><%= e.text.truncate(220) %> <%= "📄" if e.document %></td>
<td class="text-xs text-slate-500"><%= e.signoff_person %><% if e.signoff_location.present? %><br><%= e.signoff_location %><% end %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
<% else %>
<%= empty_state(@query.present? ? "No entries match “#{@query}”." : "No logbook entries yet.") %>
<% end %>
</section>
+2
View File
@@ -0,0 +1,2 @@
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<%= render "form", aircraft: @aircraft, entry: @entry %>
+18
View File
@@ -0,0 +1,18 @@
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<section class="card max-w-4xl">
<div class="card-header">
<h2 class="card-title"><%= LogbookEntry::LOG_TYPES[@entry.log_type] %> log — <%= fmt_date(@entry.date) %></h2>
<% if owner? %><%= link_to "Edit", edit_aircraft_logbook_entry_path(@aircraft, @entry), class: "btn-secondary btn-sm" %><% end %>
</div>
<div class="card-body space-y-3">
<div class="flex flex-wrap gap-4 text-sm text-slate-600">
<span>Type: <%= LogbookEntry::ENTRY_TYPES[@entry.entry_type] %></span>
<span>Aircraft hours: <%= hours(@entry.aircraft_hours_at_entry) %></span>
</div>
<div class="whitespace-pre-wrap rounded bg-slate-50 p-3 font-mono text-sm"><%= @entry.text %></div>
<div class="text-sm text-slate-600">Signed off: <%= @entry.signoff_person.presence || "—" %> <%= "(#{@entry.signoff_location})" if @entry.signoff_location.present? %></div>
<% if @entry.document %>
<p class="text-sm">Scan: <%= link_to @entry.document.name, aircraft_document_path(@aircraft, @entry.document, page: @entry.page_number), class: "link" %><%= " (page #{@entry.page_number})" if @entry.page_number %></p>
<% end %>
</div>
</section>
+24
View File
@@ -0,0 +1,24 @@
<%= form_with model: [aircraft, record], class: "card card-body space-y-4 max-w-3xl" do |f| %>
<%= f.errors_summary %>
<div class="grid gap-4 sm:grid-cols-3">
<%= f.field :record_type, as: :select, label: "Type", collection: MajorRecord::RECORD_TYPES.invert %>
<%= f.field :date_performed, as: :date %>
<%= f.field :aircraft_hours, as: :number, step: 0.1 %>
</div>
<%= f.field :title, required: true %>
<%= f.field :description, as: :textarea, rows: 4 %>
<div class="grid gap-4 sm:grid-cols-2">
<%= f.field :performed_by %>
<%= f.field :component_id, as: :select, label: "Component", collection: component_options(aircraft) %>
<%= f.field :form_337_document_id, as: :select, label: "Form 337 document", collection: document_options(aircraft) %>
<%= f.field :logbook_entry_id, as: :select, label: "Logbook entry", collection: logbook_options(aircraft) %>
<%= f.field :stc_number, label: "STC number" %>
<%= f.field :stc_holder, label: "STC holder" %>
<%= f.field :stc_document_id, as: :select, label: "STC document", collection: document_options(aircraft) %>
</div>
<%= f.field :has_ica, as: :checkbox, label: "Includes Instructions for Continued Airworthiness" %>
<%= f.field :ica_notes, as: :textarea, rows: 2, label: "ICA notes" %>
<%= f.field :notes, as: :textarea, rows: 2 %>
<div class="flex gap-2"><%= f.submit "Save" %><%= link_to "Cancel", aircraft_major_records_path(aircraft), class: "btn-secondary" %></div>
<% end %>
<% if record.persisted? %><div class="mt-4"><%= delete_button "Delete record", aircraft_major_record_path(aircraft, record) %></div><% end %>
+2
View File
@@ -0,0 +1,2 @@
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<%= render "form", aircraft: @aircraft, record: @record %>
+27
View File
@@ -0,0 +1,27 @@
<% content_for :title, "#{@aircraft.tail_number} Major Records" %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<section class="card">
<div class="card-header"><h2 class="card-title">Major Repairs & Alterations</h2>
<% if owner? %><div class="flex gap-2">
<%= link_to "+ Repair", new_aircraft_major_record_path(@aircraft, type: "repair"), class: "btn-secondary" %>
<%= link_to "+ Alteration", new_aircraft_major_record_path(@aircraft, type: "alteration"), class: "btn-primary" %></div><% end %></div>
<% if @records.any? %>
<table class="table">
<thead><tr><th>Date</th><th>Type</th><th>Title</th><th>Performed by</th><th>STC</th><th>ICA</th></tr></thead>
<tbody>
<% @records.each do |r| %>
<tr>
<td class="whitespace-nowrap"><%= r.date_performed %></td>
<td><%= tag.span r.type_label, class: r.record_type == "repair" ? "badge-orange" : "badge-blue" %></td>
<td><%= link_to r.title, aircraft_major_record_path(@aircraft, r), class: "link" %><%= tag.div(r.component, class: "text-xs text-slate-500") if r.component %></td>
<td class="text-xs"><%= r.performed_by %></td>
<td class="text-xs"><%= r.stc_number %></td>
<td><%= "✓" if r.has_ica? %></td>
</tr>
<% end %>
</tbody>
</table>
<% else %>
<%= empty_state "No major repairs or alterations recorded." %>
<% end %>
</section>
+2
View File
@@ -0,0 +1,2 @@
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<%= render "form", aircraft: @aircraft, record: @record %>
+19
View File
@@ -0,0 +1,19 @@
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<section class="card max-w-4xl">
<div class="card-header"><h2 class="card-title"><%= @record.type_label %>: <%= @record.title %></h2>
<% if owner? %><%= link_to "Edit", edit_aircraft_major_record_path(@aircraft, @record), class: "btn-secondary btn-sm" %><% end %></div>
<dl class="card-body grid grid-cols-2 gap-x-4 gap-y-2 text-sm sm:grid-cols-4">
<dt class="text-slate-500">Date</dt><dd><%= fmt_date(@record.date_performed) %></dd>
<dt class="text-slate-500">Aircraft hours</dt><dd><%= hours(@record.aircraft_hours) %></dd>
<dt class="text-slate-500">Performed by</dt><dd><%= @record.performed_by.presence || "—" %></dd>
<dt class="text-slate-500">Component</dt><dd><%= @record.component || "—" %></dd>
<dt class="text-slate-500">Form 337</dt><dd><%= @record.form_337_document ? link_to(@record.form_337_document.name, aircraft_document_path(@aircraft, @record.form_337_document), class: "link") : "—" %></dd>
<dt class="text-slate-500">STC</dt><dd><%= [@record.stc_number, @record.stc_holder].compact_blank.join(" · ").presence || "—" %>
<%= link_to("(docs)", aircraft_document_path(@aircraft, @record.stc_document), class: "link") if @record.stc_document %></dd>
<dt class="text-slate-500">Logbook</dt><dd><%= @record.logbook_entry ? link_to(@record.logbook_entry.date, aircraft_logbook_entry_path(@aircraft, @record.logbook_entry), class: "link") : "—" %></dd>
<dt class="text-slate-500">ICAs</dt><dd><%= @record.has_ica? ? "Yes" : "No" %></dd>
</dl>
<% [["Description", @record.description], ["ICA notes", @record.ica_notes], ["Notes", @record.notes]].each do |title, text| %>
<% if text.present? %><div class="border-t border-slate-100 px-4 py-3 text-sm"><h3 class="mb-1 font-medium"><%= title %></h3><%= simple_format text %></div><% end %>
<% end %>
</section>
+7
View File
@@ -0,0 +1,7 @@
<%= form_with model: note, url: note.new_record? ? aircraft_notes_path(aircraft) : aircraft_note_path(aircraft, note), class: "card card-body space-y-4 max-w-2xl" do |f| %>
<%= f.errors_summary %>
<%= f.field :text, as: :textarea, label: "Note", rows: 5, autofocus: true %>
<%= f.field :public, as: :checkbox, label: "Show on share links" %>
<div class="flex gap-2"><%= f.submit "Save Note" %><%= link_to "Cancel", aircraft_notes_path(aircraft), class: "btn-secondary" %></div>
<% end %>
<% if note.persisted? %><div class="mt-4"><%= delete_button "Delete note", aircraft_note_path(aircraft, note) %></div><% end %>
+2
View File
@@ -0,0 +1,2 @@
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<%= render "form", aircraft: @aircraft, note: @note %>
+24
View File
@@ -0,0 +1,24 @@
<% content_for :title, "#{@aircraft.tail_number} Notes" %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<section class="card">
<div class="card-header"><h2 class="card-title">Notes</h2><%= link_to "+ Add Note", new_aircraft_note_path(@aircraft), class: "btn-primary" %></div>
<% if @notes.any? %>
<ul class="divide-y divide-slate-100">
<% @notes.each do |note| %>
<li class="flex items-start justify-between gap-4 px-4 py-3">
<div>
<div class="text-sm"><%= simple_format note.text %></div>
<div class="mt-1 text-xs text-slate-500">
<%= note.user&.display_name || "Unknown" %> · <%= l note.created_at, format: :short %>
<%= "· edited" if note.edited_at %>
<% if note.public? %><span class="badge-green ml-1">Visible on share links</span><% end %>
</div>
</div>
<% if owner? %><%= link_to "Edit", edit_aircraft_note_path(@aircraft, note), class: "btn-secondary btn-sm" %><% end %>
</li>
<% end %>
</ul>
<% else %>
<%= empty_state "No notes yet." %>
<% end %>
</section>
+2
View File
@@ -0,0 +1,2 @@
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<%= render "form", aircraft: @aircraft, note: @note %>
+21
View File
@@ -0,0 +1,21 @@
<div class="mx-auto md:w-2/3 w-full">
<% if alert = flash[:alert] %>
<p class="py-2 px-3 bg-red-50 mb-5 text-red-500 font-medium rounded-lg inline-block" id="alert"><%= alert %></p>
<% end %>
<h1 class="font-bold text-4xl">Update your password</h1>
<%= form_with url: password_path(params[:token]), method: :put, class: "contents" do |form| %>
<div class="my-5">
<%= form.password_field :password, required: true, autocomplete: "new-password", placeholder: "Enter new password", maxlength: 72, class: "block shadow-sm rounded-md border border-gray-400 focus:outline-solid focus:outline-blue-600 px-3 py-2 mt-2 w-full" %>
</div>
<div class="my-5">
<%= form.password_field :password_confirmation, required: true, autocomplete: "new-password", placeholder: "Repeat new password", maxlength: 72, class: "block shadow-sm rounded-md border border-gray-400 focus:outline-solid focus:outline-blue-600 px-3 py-2 mt-2 w-full" %>
</div>
<div class="inline">
<%= form.submit "Save", class: "w-full sm:w-auto text-center rounded-md px-3.5 py-2.5 bg-blue-600 hover:bg-blue-500 text-white inline-block font-medium cursor-pointer" %>
</div>
<% end %>
</div>
+17
View File
@@ -0,0 +1,17 @@
<div class="mx-auto md:w-2/3 w-full">
<% if alert = flash[:alert] %>
<p class="py-2 px-3 bg-red-50 mb-5 text-red-500 font-medium rounded-lg inline-block" id="alert"><%= alert %></p>
<% end %>
<h1 class="font-bold text-4xl">Forgot your password?</h1>
<%= form_with url: passwords_path, class: "contents" do |form| %>
<div class="my-5">
<%= form.email_field :email_address, required: true, autofocus: true, autocomplete: "username", placeholder: "Enter your email address", value: params[:email_address], class: "block shadow-sm rounded-md border border-gray-400 focus:outline-solid focus:outline-blue-600 px-3 py-2 mt-2 w-full" %>
</div>
<div class="inline">
<%= form.submit "Email reset instructions", class: "w-full sm:w-auto text-center rounded-lg px-3.5 py-2.5 bg-blue-600 hover:bg-blue-500 text-white inline-block font-medium cursor-pointer" %>
</div>
<% end %>
</div>
@@ -0,0 +1,4 @@
<p>
You can reset your password within the next 15 minutes on
<%= link_to "this password reset page", edit_password_url(@user.password_reset_token) %>.
</p>
@@ -0,0 +1,2 @@
You can reset your password within the next 15 minutes on this password reset page:
<%= edit_password_url(@user.password_reset_token) %>
+9
View File
@@ -0,0 +1,9 @@
<h1 class="mb-4 text-2xl font-bold">Your Profile</h1>
<%= form_with model: @user, url: profile_path, method: :patch, class: "card card-body space-y-4 max-w-md" do |f| %>
<%= f.errors_summary %>
<%= f.field :name %>
<%= f.field :email_address, as: :email, label: "Email" %>
<%= f.field :password, as: :password, label: "New password", hint: "Leave blank to keep your current password.", autocomplete: "new-password" %>
<%= f.field :password_confirmation, as: :password, label: "Confirm new password" %>
<%= f.submit "Save" %>
<% end %>
+22
View File
@@ -0,0 +1,22 @@
{
"name": "SimpleAircraftManager",
"icons": [
{
"src": "/icon.png",
"type": "image/png",
"sizes": "512x512"
},
{
"src": "/icon.png",
"type": "image/png",
"sizes": "512x512",
"purpose": "maskable"
}
],
"start_url": "/",
"display": "standalone",
"scope": "/",
"description": "SimpleAircraftManager.",
"theme_color": "red",
"background_color": "red"
}
+26
View File
@@ -0,0 +1,26 @@
// Add a service worker for processing Web Push notifications:
//
// self.addEventListener("push", async (event) => {
// const { title, options } = await event.data.json()
// event.waitUntil(self.registration.showNotification(title, options))
// })
//
// self.addEventListener("notificationclick", function(event) {
// event.notification.close()
// event.waitUntil(
// clients.matchAll({ type: "window" }).then((clientList) => {
// for (let i = 0; i < clientList.length; i++) {
// let client = clientList[i]
// let clientPath = (new URL(client.url)).pathname
//
// if (clientPath == event.notification.data.path && "focus" in client) {
// return client.focus()
// }
// }
//
// if (clients.openWindow) {
// return clients.openWindow(event.notification.data.path)
// }
// })
// )
// })
+12
View File
@@ -0,0 +1,12 @@
<% content_for :title, "Sign in" %>
<div class="mx-auto max-w-sm">
<h1 class="mb-4 text-2xl font-bold">Sign in</h1>
<%= form_with url: session_path, class: "card card-body space-y-4" do |form| %>
<div><%= form.label :email_address, "Email", class: "label" %>
<%= form.email_field :email_address, required: true, autofocus: true, autocomplete: "username", value: params[:email_address], class: "input" %></div>
<div><%= form.label :password, class: "label" %>
<%= form.password_field :password, required: true, autocomplete: "current-password", maxlength: 72, class: "input" %></div>
<%= form.submit "Sign in", class: "btn-primary w-full justify-center" %>
<p class="text-center text-sm"><%= link_to "Forgot password?", new_password_path, class: "link" %></p>
<% end %>
</div>
+12
View File
@@ -0,0 +1,12 @@
<div class="mx-auto max-w-md">
<h1 class="mb-1 text-2xl font-bold">Welcome</h1>
<p class="mb-4 text-sm text-slate-600">Create the administrator account to get started.</p>
<%= form_with model: @user, url: setup_path, class: "card card-body space-y-4" do |f| %>
<%= f.errors_summary %>
<%= f.field :name %>
<%= f.field :email_address, as: :email, label: "Email", required: true %>
<%= f.field :password, as: :password, required: true, hint: "At least 8 characters." %>
<%= f.field :password_confirmation, as: :password, required: true %>
<%= f.submit "Create Admin Account", class: "btn-primary w-full justify-center" %>
<% end %>
</div>
@@ -0,0 +1,30 @@
<%# Header + tab bar shown on every aircraft page. %>
<% aw = aircraft.airworthiness %>
<div class="mb-4 flex flex-wrap items-center justify-between gap-3">
<div class="flex items-center gap-3">
<% if aircraft.picture.attached? %>
<%= image_tag aircraft.picture, class: "h-12 w-12 rounded-md object-cover" %>
<% end %>
<div>
<h1 class="text-2xl font-bold tracking-tight">
<%= link_to aircraft.tail_number, aircraft_path(aircraft) %>
<span class="ml-1 text-base font-normal text-slate-500"><%= [aircraft.make, aircraft.model].compact_blank.join(" ") %></span>
</h1>
<div class="mt-1 flex flex-wrap items-center gap-2 text-sm">
<%= airworthiness_badge(aw) %>
<%= aircraft_status_badge(aircraft) %>
<span class="text-slate-500">Tach <%= hours(aircraft.tach_time) %> · Hobbs <%= hours(aircraft.hobbs_time) %></span>
<span class="badge-gray"><%= current_role.capitalize %></span>
</div>
</div>
</div>
<div class="flex gap-2">
<%= link_to "Log Flight", new_aircraft_flight_log_path(aircraft), class: "btn-primary" %>
<%= link_to "Report Squawk", new_aircraft_squawk_path(aircraft), class: "btn-secondary" %>
</div>
</div>
<nav class="mb-5 flex overflow-x-auto border-b border-slate-200">
<% aircraft_tabs(aircraft).each do |label, path, names| %>
<%= nav_tab label, path, names.include?(controller_name) %>
<% end %>
</nav>
@@ -0,0 +1,14 @@
<%# ADs and inspection types: which parts of THIS aircraft they apply to. %>
<fieldset>
<legend class="label">Applies to on <%= aircraft.tail_number %></legend>
<label class="flex items-center gap-2 text-sm"><%= check_box_tag :applies_to_airframe, "1", applies_to_airframe %> Airframe</label>
<% comps = aircraft.components.where.not(status: "DISPOSED").includes(:component_type) %>
<% if comps.any? %>
<div class="mt-1 grid gap-1 sm:grid-cols-2">
<% comps.each do |c| %>
<label class="flex items-center gap-2 text-sm"><%= check_box_tag "component_ids[]", c.id, record.components.include?(c), id: "comp_#{c.id}" %> <%= c %> <span class="text-xs text-slate-500"><%= c.manufacturer %> <%= c.model %></span></label>
<% end %>
</div>
<% end %>
<p class="hint">Component-level items follow the component if it moves to another aircraft.</p>
</fieldset>
+6
View File
@@ -0,0 +1,6 @@
<% if notice.present? %>
<div class="mb-4 rounded-md bg-emerald-50 px-4 py-2 text-sm text-emerald-800 ring-1 ring-emerald-200"><%= notice %></div>
<% end %>
<% if alert.present? %>
<div class="mb-4 rounded-md bg-red-50 px-4 py-2 text-sm text-red-800 ring-1 ring-red-200"><%= alert %></div>
<% end %>
+101
View File
@@ -0,0 +1,101 @@
<% content_for :title, @aircraft.tail_number %>
<div class="mb-5 flex flex-wrap items-center justify-between gap-3">
<div class="flex items-center gap-3">
<% if @aircraft.picture.attached? %><%= image_tag rails_blob_path(@aircraft.picture, disposition: :inline), class: "h-16 w-16 rounded-md object-cover" %><% end %>
<div>
<h1 class="text-2xl font-bold"><%= @aircraft.tail_number %> <span class="text-base font-normal text-slate-500"><%= [@aircraft.make, @aircraft.model].compact_blank.join(" ") %></span></h1>
<div class="mt-1 flex flex-wrap items-center gap-2 text-sm">
<%= airworthiness_badge(@airworthiness) %> <%= aircraft_status_badge(@aircraft) %>
<span class="text-slate-500">Tach <%= hours(@aircraft.tach_time) %> · Hobbs <%= hours(@aircraft.hobbs_time) %></span>
</div>
</div>
</div>
<span class="badge-gray">Shared view · <%= ShareToken::PRIVILEGES[@share.privilege] %></span>
</div>
<div class="space-y-5">
<section class="card">
<div class="card-header"><h2 class="card-title">Airworthiness</h2><%= airworthiness_badge(@airworthiness, large: true) %></div>
<div class="card-body">
<% if @airworthiness.issues.empty? %><p class="text-sm text-emerald-700">No open issues.</p><% else %>
<ul class="space-y-1 text-sm"><% @airworthiness.issues.each do |i| %><li><span class="<%= i.severity == 'RED' ? 'badge-red' : 'badge-orange' %>"><%= i.category %></span> <%= i.title %> <span class="text-xs text-slate-500"><%= i.description %></span></li><% end %></ul>
<% end %>
</div>
</section>
<div class="grid gap-5 lg:grid-cols-2">
<section class="card">
<div class="card-header"><h2 class="card-title">Open Squawks</h2></div>
<% if @active_squawks.any? %>
<ul class="divide-y divide-slate-100"><% @active_squawks.each do |s| %><li class="px-4 py-2 text-sm"><%= squawk_priority_badge(s) %> <%= s.issue_reported %></li><% end %></ul>
<% else %><%= empty_state "None." %><% end %>
</section>
<section class="card">
<div class="card-header"><h2 class="card-title">Consumption</h2></div>
<div class="card-body grid grid-cols-2 gap-4 text-center">
<div><div class="text-2xl font-semibold"><%= @oil.average || "—" %></div><div class="text-xs text-slate-500">Oil hrs/qt</div></div>
<div><div class="text-2xl font-semibold"><%= @fuel.average || "—" %></div><div class="text-xs text-slate-500">Fuel gal/hr</div></div>
</div>
</section>
</div>
<section class="card">
<div class="card-header"><h2 class="card-title">Components</h2></div>
<div class="overflow-x-auto"><table class="table">
<thead><tr><th>Component</th><th>Make / Model</th><th class="text-right">In service</th><th class="text-right">Since OH/svc</th><th>TBO</th><th>Life</th></tr></thead>
<tbody><% @components.each do |c| %><tr>
<td><%= c %></td><td><%= c.manufacturer %> <%= c.model %></td>
<td class="text-right"><%= hours(c.hours_in_service) %></td><td class="text-right"><%= hours(c.hours_since_overhaul) %></td>
<td><%= c.tbo_hours %></td><td><%= life_badge(c.life_status) %></td></tr><% end %></tbody>
</table></div>
</section>
<div class="grid gap-5 lg:grid-cols-2">
<section class="card">
<div class="card-header"><h2 class="card-title">Inspections</h2></div>
<table class="table"><tbody><% @inspection_rows.each do |r| %><tr>
<td><%= r.type.name %></td><td class="text-xs"><%= r.latest&.date || "—" %></td><td><%= compliance_badge(r.status) %></td></tr><% end %></tbody></table>
</section>
<section class="card">
<div class="card-header"><h2 class="card-title">ADs</h2></div>
<table class="table"><tbody><% @ad_rows.each do |r| %><tr>
<td><%= r.ad.name %><div class="text-xs text-slate-500"><%= r.ad.short_description %></div></td><td class="text-xs"><%= r.latest&.date_complied || "—" %></td><td><%= compliance_badge(r.status) %></td></tr><% end %></tbody></table>
</section>
</div>
<% if @notes.any? %>
<section class="card"><div class="card-header"><h2 class="card-title">Notes</h2></div>
<ul class="divide-y divide-slate-100"><% @notes.each do |n| %><li class="px-4 py-2 text-sm"><%= simple_format n.text %><div class="text-xs text-slate-500"><%= n.created_at.to_date %></div></li><% end %></ul></section>
<% end %>
<% if @documents.any? %>
<section class="card"><div class="card-header"><h2 class="card-title">Documents</h2></div>
<ul class="divide-y divide-slate-100"><% @documents.each do |d| %><li class="px-4 py-2 text-sm">
<span class="font-medium"><%= d.name %></span> <span class="text-xs text-slate-500"><%= d.type_label %></span>
<div class="mt-1 flex flex-wrap gap-2"><% d.pages.each_with_index do |p, i| %><%= link_to "#{i + 1}. #{p.filename}", rails_blob_path(p, disposition: :inline), class: "link text-xs", target: "_blank" %><% end %></div>
</li><% end %></ul></section>
<% end %>
<% if @share.maintenance? %>
<section class="card"><div class="card-header"><h2 class="card-title">Logbook</h2></div>
<% if @logbook.any? %><table class="table"><tbody><% @logbook.each do |e| %><tr>
<td class="whitespace-nowrap"><%= e.date %></td><td><span class="badge-gray"><%= LogbookEntry::LOG_TYPES[e.log_type] %></span></td>
<td class="text-right"><%= hours(e.aircraft_hours_at_entry) %></td><td class="whitespace-pre-wrap text-xs"><%= e.text %></td><td class="text-xs"><%= e.signoff_person %></td></tr><% end %></tbody></table>
<% else %><%= empty_state "No entries." %><% end %></section>
<div class="grid gap-5 lg:grid-cols-2">
<section class="card"><div class="card-header"><h2 class="card-title">Inspection History</h2></div>
<table class="table"><tbody><% @inspection_history.each do |r| %><tr><td><%= r.date %></td><td><%= r.inspection_type.name %></td><td class="text-right"><%= hours(r.hours_at_inspection) %></td></tr><% end %></tbody></table></section>
<section class="card"><div class="card-header"><h2 class="card-title">AD Compliance History</h2></div>
<table class="table"><tbody><% @ad_history.each do |c| %><tr><td><%= c.date_complied %></td><td><%= c.airworthiness_directive.name %></td><td class="text-xs"><%= c.compliance_notes %></td></tr><% end %></tbody></table></section>
</div>
<section class="card"><div class="card-header"><h2 class="card-title">Major Repairs & Alterations</h2></div>
<% if @major_records.any? %><table class="table"><tbody><% @major_records.each do |r| %><tr><td><%= r.date_performed %></td><td><%= r.type_label %></td><td><%= r.title %><div class="text-xs text-slate-500"><%= r.description %></div></td><td class="text-xs"><%= r.stc_number %></td></tr><% end %></tbody></table>
<% else %><%= empty_state "None recorded." %><% end %></section>
<section class="card"><div class="card-header"><h2 class="card-title">Resolved Squawks</h2></div>
<% if @resolved_squawks.any? %><ul class="divide-y divide-slate-100"><% @resolved_squawks.each do |s| %><li class="px-4 py-2 text-sm"><%= squawk_priority_badge(s) %> <%= s.issue_reported %> <span class="text-xs text-slate-500">resolved <%= s.resolved_at&.to_date %></span></li><% end %></ul>
<% else %><%= empty_state "None." %><% end %></section>
<% end %>
</div>
+15
View File
@@ -0,0 +1,15 @@
<%= form_with model: [aircraft, squawk], class: "card card-body space-y-4 max-w-2xl" do |f| %>
<%= f.errors_summary %>
<%= f.field :priority, as: :select, collection: Squawk::PRIORITIES.invert, hint: "“Ground Aircraft” makes the aircraft not airworthy until resolved." %>
<%= f.field :issue_reported, as: :textarea, label: "Issue", required: true, autofocus: true %>
<%= f.field :component_id, as: :select, label: "Component (optional)", collection: component_options(aircraft) %>
<%= f.field :attachment, as: :file, label: "Photo / attachment" %>
<% if squawk.persisted? %><%= f.field :notes, as: :textarea, rows: 3 %><% end %>
<div class="flex gap-2">
<%= f.submit squawk.new_record? ? "Report Squawk" : "Save" %>
<%= link_to "Cancel", aircraft_squawks_path(aircraft), class: "btn-secondary" %>
</div>
<% end %>
<% if squawk.persisted? && owner? %>
<div class="mt-4"><%= delete_button "Delete squawk", aircraft_squawk_path(aircraft, squawk) %></div>
<% end %>
+25
View File
@@ -0,0 +1,25 @@
<div class="overflow-x-auto">
<table class="table">
<thead><tr><th>Priority</th><th>Issue</th><th>Component</th><th>Reported</th><th></th></tr></thead>
<tbody>
<% squawks.each do |s| %>
<tr>
<td><%= squawk_priority_badge(s) %></td>
<td class="max-w-md">
<%= s.issue_reported %>
<% if s.attachment.attached? %><div><%= link_to "📎 #{s.attachment.filename}", rails_blob_path(s.attachment, disposition: :inline), class: "link text-xs", target: "_blank" %></div><% end %>
<% if s.notes.present? %><div class="mt-1 text-xs text-slate-500"><%= s.notes %></div><% end %>
</td>
<td><%= s.component&.to_s || "—" %></td>
<td class="whitespace-nowrap text-xs text-slate-500"><%= s.created_at.to_date %><br><%= s.reported_by&.display_name %></td>
<td class="whitespace-nowrap text-right">
<% if owner? %>
<%= button_to "Resolve", resolve_aircraft_squawk_path(aircraft, s), method: :patch, class: "btn-secondary btn-sm", form: { class: "inline" } %>
<%= link_to "Edit", edit_aircraft_squawk_path(aircraft, s), class: "btn-secondary btn-sm" %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
+3
View File
@@ -0,0 +1,3 @@
<% content_for :title, "Edit Squawk" %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<%= render "form", aircraft: @aircraft, squawk: @squawk %>
+31
View File
@@ -0,0 +1,31 @@
<% content_for :title, "#{@aircraft.tail_number} Squawks" %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<section class="card">
<div class="card-header">
<h2 class="card-title">Open Squawks</h2>
<%= link_to "+ Report Squawk", new_aircraft_squawk_path(@aircraft), class: "btn-primary" %>
</div>
<% if @active.any? %><%= render "squawks/table", squawks: @active, aircraft: @aircraft %><% else %><%= empty_state "No open squawks." %><% end %>
</section>
<section class="card mt-5">
<div class="card-header"><h2 class="card-title">Resolved</h2></div>
<% if @resolved.any? %>
<table class="table">
<thead><tr><th>Priority</th><th>Issue</th><th>Resolution</th><th>Resolved</th><th></th></tr></thead>
<tbody>
<% @resolved.each do |s| %>
<tr>
<td><%= squawk_priority_badge(s) %></td>
<td><%= s.issue_reported %></td>
<td class="text-xs text-slate-600"><%= s.notes %></td>
<td class="text-xs text-slate-500"><%= s.resolved_at&.to_date %></td>
<td class="text-right"><% if owner? %><%= button_to "Reopen", reopen_aircraft_squawk_path(@aircraft, s), method: :patch, class: "btn-secondary btn-sm" %><% end %></td>
</tr>
<% end %>
</tbody>
</table>
<% else %>
<%= empty_state "No resolved squawks." %>
<% end %>
</section>
+3
View File
@@ -0,0 +1,3 @@
<% content_for :title, "Report Squawk" %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<%= render "form", aircraft: @aircraft, squawk: @squawk %>