mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 23:50:36 -05:00
Flights tab: - Summary cards for the past 30 days, this year, past 12 months and since the first flight (flight hours, flights, tach, fuel). - Flight hours by month (last 24 months) with the past-year monthly average, totals (flights, flight/tach time, average and longest flight, fuel, gal/hr, airports visited, most visited) and a by-year table. - Flight time is Hobbs time where recorded, otherwise tach time. Removed the per-aircraft DRS search link and its "Open in DRS" button: each AD's DRS link already comes from the Excel import. A guarded migration drops the column. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
89 lines
5.7 KiB
ERB
89 lines
5.7 KiB
ERB
<% 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 "Import from FAA DRS", new_aircraft_ad_import_path(@aircraft), class: "btn-secondary" %>
|
||
<%= 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_link(ad) %>
|
||
<% if ad.document %><%= link_to "📄", aircraft_document_path(@aircraft, ad.document), title: ad.document.name %><% end %>
|
||
<% 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.effective_date || ad.product_type.present? %><div class="text-slate-500"><%= [(ad.effective_date && "Effective #{ad.effective_date}"), ad.product_type.presence].compact.join(" · ") %></div><% end %>
|
||
<% if ad.superseded_by.present? %><div class="text-amber-700">Superseded by <%= ad.superseded_by %></div><% end %>
|
||
<% 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)} tach (#{hours(row.next_due_hours - @aircraft.current_hours)} h left)"].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" %>
|
||
<% if row.status.in?(%w[no_compliance overdue due_soon conditional]) %><%= link_to "N/A", new_aircraft_ad_compliance_path(@aircraft, ad_id: ad.id, not_applicable: 1), class: "btn-secondary btn-sm", title: "Record that this AD doesn't apply to this aircraft" %><% end %>
|
||
<%= 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 (tach)</th><th>Notes</th><th></th></tr></thead>
|
||
<tbody>
|
||
<% @history.each do |c| %>
|
||
<tr>
|
||
<td class="whitespace-nowrap"><%= c.date_complied %></td>
|
||
<% ad = c.airworthiness_directive %>
|
||
<td class="max-w-xs">
|
||
<span class="whitespace-nowrap font-medium"><%= ad_link(ad) %></span>
|
||
<% if ad.document %><%= link_to "📄", aircraft_document_path(@aircraft, ad.document), title: ad.document.name %><% end %>
|
||
<div class="text-xs text-slate-500"><%= ad.short_description %><%= " · #{c.component}" if c.component %></div>
|
||
</td>
|
||
<td class="text-right"><%= hours(c.aircraft_hours_at_compliance) %></td>
|
||
<td><%= c.not_applicable? ? "N/A" : 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 %>
|
||
<% if c.logbook_entry || c.inspection_record %>
|
||
<div class="mt-1 flex flex-wrap gap-x-3">
|
||
<% if c.logbook_entry %><%= link_to "Logbook #{c.logbook_entry.date}", aircraft_logbook_entry_path(@aircraft, c.logbook_entry), class: "link" %><% end %>
|
||
<% if c.inspection_record %><%= link_to "#{c.inspection_record.inspection_type.name} #{c.inspection_record.date}", aircraft_inspections_path(@aircraft), class: "link" %><% end %>
|
||
</div>
|
||
<% end %>
|
||
</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>
|