Files
simple-aircraft-manager-rails/app/views/aircraft/show.html.erb
T
rickyandClaude Opus 5.5 a4b72cf2c1 Part 91 inspection rules: limitations, annual as 100-hour, overrun, clock
- Inspection types say what overdue means: grounds the aircraft, no IFR
  (91.411), no transponder (91.413) or advisory. Overdue limitations show
  as a new LIMITED status ("VFR only", "No transponder") and don't block
  flights under airworthiness enforcement
- "Also counts as": an annual satisfies the 100-hour (91.409(b))
- Overrun allowance: a 100-hour done within 10 hrs of due counts the next
  one from when it was due; done early, from when it was done
- Per-aircraft maintenance clock (tach or Hobbs) for time in service; new
  records default to it (fixes the tach-offset mismatch)
- Status labels Current / Due soon / limitation / Grounded, with the
  91.7 pilot-in-command note
- Migration converts existing types by name; archives carry the new fields

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 10:04:46 -05:00

111 lines
5.3 KiB
ERB

<% 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">Nothing overdue or due soon. 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_badge_class(issue) %> 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 aircraft shows Grounded.</p>
<% end %>
<p class="hint mt-3"><%= Airworthiness::DISCLAIMER %></p>
</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.recent || "—" %></div><div class="text-xs text-slate-500">Oil, hrs/qt (last ~100 hrs)</div></div>
<div><div class="text-2xl font-semibold"><%= @fuel.recent || "—" %></div><div class="text-xs text-slate-500">Fuel burn, gal/hr (last ~50 hrs)</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><%= markdown_excerpt note.text %></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>