Files
simple-aircraft-manager-rails/app/views/aircraft/_form.html.erb
T
rickyandClaude Opus 5.5 5bf682502b AirTrail sync and export, GPS tracks, airport database with autocomplete
AirTrail (https://github.com/johanohly/AirTrail):
- File export (Flights → Export for AirTrail) in AirTrail's import
  format, validated against its schema; same-day repeat legs get leg
  numbers so AirTrail's de-duplication doesn't merge them.
- Automatic sync through AirTrail's REST API (Profile → AirTrail sync):
  per-user connection with an encrypted API key and scope check; flights
  are created/updated/deleted in background jobs; a full sync first
  links flights already in AirTrail (e.g. from a file import) instead of
  duplicating them; airports are resolved and cached, with manual
  mapping for unknown codes.
- GPS tracks: GPX, KML and CSV track logs are converted to AirTrail's
  track format for both sync and export; the flight page shows a summary.
- Aircraft ICAO type (e.g. C150) for AirTrail's aircraft type.

Airport database (OurAirports, the source AirTrail uses):
- Managed like AirTrail: downloaded in the background on first start,
  updated in place from Admin → Airports (adds, changes, removes; ids
  stable), with admin-managed custom airports that updates never touch.
- Each airport carries AirTrail's code, so logged codes translate to
  AirTrail's exactly (1B9 → K1B9, 4MB → K5M3).
- From/To autocomplete on new flights (airports this aircraft has used
  rank first); From is pre-filled with the last flight's destination;
  codes are normalized to uppercase.
- Flights → Standardize airport codes: rewrite logged codes to the
  standard code, and fix codes not in the database (typos such as 0R8 →
  08R are suggested).

Also: admin pages grouped under an Admin dropdown menu.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 19:40:20 -05:00

32 lines
1.7 KiB
ERB

<%= 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 %>
<%= f.field :icao_type, label: "ICAO type", placeholder: "C150", maxlength: 4, hint: "Type designator, used for AirTrail." %>
</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 %>