mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 23:50:36 -05:00
Import ADs from FAA DRS exports; N/A determinations and DRS links
AD import (owners, ADs tab → Import from FAA DRS): - Upload a DRS export (.xlsx recommended, .csv works), preview, confirm. - Per AD: track, not applicable, or skip, with suggestions and flags for superseded/non-current ADs, model mismatches, appliance and STC-only ADs, repetitive actions, and older ADs this one supersedes. - ADs are matched by number; re-importing updates existing ADs from the FAA data (preview lists what will change) without touching compliance records, recurrence or applicability. Superseded tracked ADs are updated and flagged rather than skipped. - DRS's Excel export hyperlinks each AD number to its DRS page; those links are kept (http(s) only). DRS ids aren't derivable from the AD number, so no links are guessed. Also: - Per-aircraft "not applicable" AD determinations (N/A badge, quick action, excluded from airworthiness). - AD numbers link to their DRS document in the AD list, compliance history (now with description, logbook/inspection links) and share page. - Saved DRS search link per aircraft with an "Open in DRS" button. - Upload storage extracted to a StoredUpload concern shared with the flight import. - document_url / drs_search_url added in their own guarded migration (they were briefly in an already-applied migration). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f94ccee99b
commit
b75fd7cf62
31 files changed
+817
-57
No files matched your search
@@ -18,7 +18,10 @@
|
||||
<p class="rounded-md bg-sky-50 px-3 py-2 text-sm text-sky-900 ring-1 ring-sky-200" data-next-due-target="preview" hidden></p>
|
||||
<%= f.field :permanent, as: :checkbox, label: "Permanently complied (terminating action)",
|
||||
data: { next_due_target: "permanent", action: "change->next-due#changed" } %>
|
||||
<%= f.field :compliance_notes, as: :textarea, label: "Method of compliance", rows: 3, required: true %>
|
||||
<%= f.field :not_applicable, as: :checkbox, label: "Not applicable to this aircraft",
|
||||
hint: "E.g. serial number outside the affected range, or the equipment isn't installed. Record why below.",
|
||||
data: { next_due_target: "permanent", action: "change->next-due#changed" } %>
|
||||
<%= f.field :compliance_notes, as: :textarea, label: "Method of compliance / reason", 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 %>
|
||||
@@ -0,0 +1,24 @@
|
||||
<% content_for :title, "Import ADs" %>
|
||||
<%= render "shared/aircraft_header", aircraft: @aircraft %>
|
||||
<div class="grid gap-5 lg:grid-cols-3">
|
||||
<%= form_with url: aircraft_ad_import_path(@aircraft), multipart: true, class: "card card-body space-y-4 lg:col-span-2" do |f| %>
|
||||
<h2 class="card-title">Import ADs from the FAA DRS</h2>
|
||||
<div>
|
||||
<%= f.label :file, "DRS export (.csv or .xlsx)", class: "label" %>
|
||||
<%= f.file_field :file, accept: ".xlsx,.csv", required: true,
|
||||
class: "block text-sm text-slate-600 file:mr-3 file:rounded-md file:border-0 file:bg-slate-100 file:px-3 file:py-1.5 file:text-sm file:font-medium hover:file:bg-slate-200" %>
|
||||
</div>
|
||||
<%= f.submit "Upload & Preview", class: "btn-primary" %>
|
||||
<p class="hint">Nothing is saved until you confirm on the next page.</p>
|
||||
<% end %>
|
||||
<section class="card card-body space-y-2 text-sm text-slate-700">
|
||||
<h3 class="font-semibold">Getting the file</h3>
|
||||
<ol class="list-decimal space-y-1 pl-4 text-xs">
|
||||
<li>On <a href="<%= @aircraft.drs_search_url.presence || "https://drs.faa.gov" %>" class="link" target="_blank" rel="noopener noreferrer"><%= @aircraft.drs_search_url.present? ? "your saved DRS search" : "drs.faa.gov" %></a>, search Airworthiness Directives for this aircraft's make and model (add the engine and propeller too).</li>
|
||||
<li>Save the results as <strong>Excel</strong>. The Excel file links each AD number to its DRS page; the CSV doesn't, so a CSV import won't have links.</li>
|
||||
<li>Upload it here.</li>
|
||||
</ol>
|
||||
<% unless @aircraft.drs_search_url.present? %><p class="text-xs">Tip: save the DRS search link on the aircraft (Edit aircraft) for a one-click “Open in DRS” button.</p><% end %>
|
||||
<p class="text-xs">ADs already tracked are matched by number, so importing the Excel file after a CSV import just adds the links.</p>
|
||||
</section>
|
||||
</div>
|
||||
@@ -0,0 +1,54 @@
|
||||
<% content_for :title, "AD Import Preview" %>
|
||||
<%= render "shared/aircraft_header", aircraft: @aircraft %>
|
||||
<% rows = @import.rows %>
|
||||
<%= form_with url: confirm_aircraft_ad_import_path(@aircraft), class: "space-y-5" do |f| %>
|
||||
<%= hidden_field_tag :token, @token %>
|
||||
<%= hidden_field_tag :filename, @filename %>
|
||||
<section class="card">
|
||||
<div class="card-header">
|
||||
<h2 class="card-title">Preview: <%= @filename %></h2>
|
||||
<span class="text-xs text-slate-500"><%= pluralize(rows.size, "AD") %> found · <%= rows.count(&:url) %> with DRS links</span>
|
||||
</div>
|
||||
<div class="card-body space-y-3 text-sm">
|
||||
<% if rows.none?(&:url) %><p class="rounded-md bg-amber-50 px-3 py-2 text-amber-900 ring-1 ring-amber-200">This file has no links to the AD documents. DRS's <strong>Excel</strong> export includes them; import that file instead (or afterwards) to get clickable AD numbers.</p><% end %>
|
||||
<p>Choose what to do with each AD. The suggestions are based on the FAA data and your aircraft's model (<%= @aircraft.model.presence || "not set" %>); you make the call.</p>
|
||||
<ul class="list-disc space-y-1 pl-5 text-xs text-slate-600">
|
||||
<li><strong>Track</strong>: adds the AD. Until you record compliance, it counts against airworthiness, so <%= @aircraft.tail_number %> will show <span class="badge-red">Not Airworthy</span> for each tracked AD without a compliance record.</li>
|
||||
<li><strong>Not applicable</strong>: adds the AD with an N/A record (e.g. the equipment isn't installed). You can edit the reason afterwards.</li>
|
||||
<li><strong>Update</strong> (ADs already tracked): refreshes the FAA details: subject, summary, dates, supersession and DRS link. Compliance records aren't touched.</li>
|
||||
<li><strong>Skip</strong>: not imported, or left exactly as is.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="card">
|
||||
<div class="overflow-x-auto">
|
||||
<table class="table">
|
||||
<thead><tr><th>AD</th><th>Subject</th><th>Effective</th><th>Notes</th><th class="w-44">Action</th></tr></thead>
|
||||
<tbody>
|
||||
<% rows.each do |r| %>
|
||||
<tr>
|
||||
<td class="whitespace-nowrap font-medium"><%= r.number %><%= link_to " 🔗", r.url, target: "_blank", rel: "noopener noreferrer", title: "Link found in file" if r.url %>
|
||||
<% if r.product_type %><div class="text-xs font-normal text-slate-500"><%= r.product_type %></div><% end %></td>
|
||||
<td class="max-w-md">
|
||||
<%= r.subject %>
|
||||
<% if r.summary %><details class="mt-1 text-xs text-slate-600"><summary class="cursor-pointer text-sky-700">Summary</summary><%= r.summary %></details><% end %>
|
||||
</td>
|
||||
<td class="whitespace-nowrap text-xs"><%= r.effective_date %></td>
|
||||
<td class="text-xs">
|
||||
<% r.notes.each do |n| %><div class="<%= n.start_with?("Already", "Matches") ? 'text-slate-500' : 'text-amber-800' %>">• <%= n %></div><% end %>
|
||||
</td>
|
||||
<td><% choices = r.tracked ? [ [ "Update", "track" ], [ "Not applicable", "na" ], [ "Skip (leave as is)", "skip" ] ] : AdImport::ACTIONS.invert %>
|
||||
<%= select_tag "decisions[#{r.number}]", options_for_select(choices, r.suggested), class: "input" %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div class="flex gap-2">
|
||||
<%= f.submit "Import ADs", class: "btn-primary", data: { turbo_confirm: "Import these ADs to #{@aircraft.tail_number}?" } %>
|
||||
<%= link_to "Upload a different file", new_aircraft_ad_import_path(@aircraft), class: "btn-secondary" %>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -20,6 +20,8 @@
|
||||
<% 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 :drs_search_url, label: "FAA DRS AD search link", placeholder: "https://drs.faa.gov/browse/ADFRAWD/doctypeDetails?…",
|
||||
hint: "Run the AD search for this aircraft on drs.faa.gov and paste the page link. The ADs tab then gets a one-click “Open in DRS” button." %>
|
||||
<%= 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." %>
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
<%= f.field :recurring_months, as: :number, label: "Every (months)" %>
|
||||
<%= f.field :document_id, as: :select, label: "Reference document", collection: document_options(aircraft) %>
|
||||
</div>
|
||||
<%= f.field :document_url, label: "Link to AD document", placeholder: "https://…",
|
||||
hint: "Filled in automatically from a DRS Excel export. In DRS, open the AD and copy its link." %>
|
||||
<%= 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>
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
<%= f.submit "Link existing", class: "btn-secondary" %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% if @aircraft.drs_search_url.present? %><%= link_to "Open in DRS ↗", @aircraft.drs_search_url, class: "btn-secondary", target: "_blank", rel: "noopener noreferrer" %><% 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 %>
|
||||
@@ -22,9 +24,12 @@
|
||||
<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 %>
|
||||
<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>
|
||||
@@ -33,6 +38,7 @@
|
||||
<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>
|
||||
@@ -55,10 +61,23 @@
|
||||
<% @history.each do |c| %>
|
||||
<tr>
|
||||
<td class="whitespace-nowrap"><%= c.date_complied %></td>
|
||||
<td><%= c.airworthiness_directive.name %><%= " (#{c.component})" if c.component %></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.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><%= 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 %>
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
<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>
|
||||
<td><%= ad_link(r.ad) %><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>
|
||||
|
||||
@@ -87,7 +87,7 @@
|
||||
<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>
|
||||
<table class="table"><tbody><% @ad_history.each do |c| %><tr><td class="whitespace-nowrap"><%= c.date_complied %></td><td><%= ad_link(c.airworthiness_directive) %><div class="text-xs text-slate-500"><%= c.airworthiness_directive.short_description %></div></td><td class="text-xs"><%= c.not_applicable? ? "N/A: " : "" %><%= 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>
|
||||
|
||||
Reference in new issue
Block a user