mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 23:50:36 -05:00
- SSO via OmniAuth OpenID Connect (Authentik, Keycloak, …): link by stable subject, by verified email, or from the profile; optional auto-create, admin-group sync, and turning password sign-in off - Current password required to change email or password; password changes and resets sign out other sessions; idle sessions expire after 30 days; "sign out everywhere else"; session reset on sign-in - Rate-limit password resets; scope squawk components to the aircraft - Strict Content Security Policy with nonces (inline handlers removed), Permissions-Policy and COOP headers; file links expire after an hour Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
66 lines
4.4 KiB
ERB
66 lines
4.4 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" data-check-all></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 %>
|