Files
simple-aircraft-manager-rails/app/views/airport_codes/show.html.erb
T
rickyandClaude Opus 5.5 86aadfcf6c Add dark mode; align table headers with numeric columns
Dark mode:
- Theme toggle in the header (System → Light → Dark); "System" follows
  the OS setting and its changes. The choice is kept per browser and
  applied before first paint, so there's no light flash.
- Implemented by remapping the palette under :root[data-theme=dark]:
  grays flip, color tints become translucent, dark colored text becomes
  its light counterpart. Page, surface, header and accent colors are
  semantic tokens. Native controls follow via color-scheme.
- Chart text and grid colors follow the theme.
- Public share pages get the toggle too.
- Contrast checked against WCAG 4.5:1 (primary button text and error
  text adjusted for dark).

Tables:
- Shared table style no longer forces header text left, so right-aligned
  numeric headers line up with their columns everywhere.
- Flight log: units in headers, muted dashes for empty cells, GPS marker
  beside the route instead of its own column.

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

66 lines
4.5 KiB
ERB

<% content_for :title, "Standardize airport codes" %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<% changes = @standardizer.changes %>
<%= form_with url: aircraft_airport_codes_path(@aircraft), method: :patch, class: "space-y-5" do |f| %>
<section class="card">
<div class="card-header">
<h2 class="card-title">Standardize airport codes</h2>
<span class="text-xs text-slate-500"><%= pluralize(changes.size, "code") %> to update · <%= changes.sum(&:flights) %> entries</span>
</div>
<div class="card-body text-sm text-slate-600">
Rewrites the airport codes in <%= @aircraft.tail_number %>'s flight log to the airport database's standard code: the ICAO-style code AirTrail uses (e.g. 1B9 → K1B9). New flights picked from autocomplete already use these codes. Untick anything you'd rather keep as is.
</div>
<% if changes.any? %>
<table class="table">
<thead><tr><th class="w-8"><input type="checkbox" checked aria-label="Select all" onclick="this.closest('table').querySelectorAll('tbody input[type=checkbox]').forEach(c => c.checked = this.checked)"></th><th>Logged</th><th>Standard</th><th>Airport</th><th class="text-right">Entries</th></tr></thead>
<tbody>
<% changes.each do |c| %>
<tr>
<td><%= check_box_tag "codes[]", c.from, c.suggested, id: "code_#{c.from.parameterize}" %></td>
<td class="font-mono"><%= label_tag "code_#{c.from.parameterize}", c.from %></td>
<td class="font-mono font-semibold"><%= c.to %></td>
<td><%= c.airport.name %> <span class="text-xs text-slate-500"><%= c.airport.place %></span>
<% if c.note %><div class="text-xs text-amber-700"><%= c.note %></div><% end %></td>
<td class="text-right tabular-nums"><%= c.flights %></td>
</tr>
<% end %>
</tbody>
</table>
<% else %>
<%= empty_state "All logged codes already match the airport database." %>
<% end %>
</section>
<% if @standardizer.unknown.any? %>
<section class="card">
<div class="card-header"><h2 class="card-title">Not in the airport database</h2></div>
<div class="card-body space-y-3 text-sm">
<p class="text-slate-600">Often a typo. Tick “Fix” and choose the airport these entries should be. Unticked codes are left unchanged.<% if current_user.admin? %> For a private strip that isn't listed, add it as a <%= link_to "custom airport", admin_airports_path, class: "link" %>.<% end %></p>
<% @standardizer.unknown.each do |u| %>
<div class="flex flex-wrap items-start gap-3">
<label class="mt-2 flex items-center gap-2"><%= check_box_tag "fix[]", u.code, u.suggestion.present?, id: "fix_#{u.code.parameterize}" %> Fix</label>
<div class="mt-2 w-16 font-mono"><%= u.code %></div>
<div class="mt-2 text-xs text-slate-500"><%= pluralize(u.flights, "entry") %> →</div>
<div class="relative w-72" data-controller="airport-autocomplete"
data-airport-autocomplete-url-value="<%= airport_search_path(aircraft_id: @aircraft.id) %>">
<%= text_field_tag "fixes[#{u.code}]", u.suggestion&.code, class: "input font-mono uppercase placeholder:normal-case placeholder:font-sans",
placeholder: "Airport code or name", "aria-label": "Airport for #{u.code}",
data: { airport_autocomplete_target: "input",
action: "input->airport-autocomplete#search keydown->airport-autocomplete#keydown blur->airport-autocomplete#blur" } %>
<ul data-airport-autocomplete-target="list" role="listbox" hidden
class="absolute z-20 mt-1 max-h-72 w-[min(28rem,90vw)] overflow-auto rounded-md bg-surface py-1 shadow-lg ring-1 ring-slate-200"></ul>
<p class="hint min-h-4" data-airport-autocomplete-target="hint"></p>
</div>
<% if u.suggestion %><div class="mt-2 text-xs text-sky-800">Suggested: <%= u.suggestion.name %>, <%= u.suggestion.place %> (letters swapped?)</div><% end %>
</div>
<% end %>
</div>
</section>
<% end %>
<div class="flex gap-2">
<% if changes.any? || @standardizer.unknown.any? %><%= f.submit "Update selected codes", class: "btn-primary", data: { turbo_confirm: "Rewrite the selected airport codes in #{@aircraft.tail_number}'s flight log?" } %><% end %>
<%= link_to "Back to flights", aircraft_flight_logs_path(@aircraft), class: "btn-secondary" %>
</div>
<% end %>