Files
rickyandClaude Opus 5.5 d8cd462194 Configurable roles: Owner, Mechanic, Pilot, Viewer and custom roles
What people can do on an aircraft now comes from their role there, and
administrators set what each role allows (Admin → Roles).

- Roles are installation-wide sets of permissions (31, grouped as flying,
  squawks and notes, maintenance records, imports and exports, the
  aircraft, notifications). Seeing an aircraft's records needs none.
- Built in: Owner (always every permission, so an aircraft can always be
  managed), Mechanic (shop maintenance: logbook, signing, components,
  inspections, ADs, squawks, reminders), Pilot (what pilots could do
  before) and Viewer (view only). Administrators can change all but
  Owner's, and add their own; a role can be deleted once nobody has it.
- Existing owners and pilots keep exactly what they could do.
- Admin → Users → a user lists their role on every aircraft, to change,
  remove or add. On the aircraft's Access page, anyone who manages people
  hands out roles, but only an Owner can give or take away Owner, nobody
  changes their own (except administrators), and an aircraft always
  keeps an Owner (AircraftAccess).
- Controllers declare the permission each action needs; a request that
  changes something with none declared is refused (and raises in
  development and tests), and a test walks every route to check.
- Weekly reminders and overdue alerts go to roles that get reminders;
  the DRS reminder also needs Manage ADs. The API follows the person's
  role; its owners_only error is now not_permitted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 17:43:38 -05:00

55 lines
3.8 KiB
ERB

<%# Header + tab bar shown on every aircraft page. %>
<% aw = aircraft.airworthiness %>
<div class="mb-4 flex flex-wrap items-center justify-between gap-3">
<div class="flex items-center gap-3">
<% if aircraft.picture_shown? %>
<%= image_tag aircraft.picture_for(:thumb), width: 48, height: 48, class: "h-12 w-12 rounded-md object-cover", alt: "" %>
<% end %>
<div>
<h1 class="text-2xl font-bold tracking-tight">
<%= link_to aircraft.tail_number, aircraft_path(aircraft) %>
<span class="ml-1 text-base font-normal text-slate-500"><%= [aircraft.make, aircraft.model].compact_blank.join(" ") %></span>
</h1>
<div class="mt-1 flex flex-wrap items-center gap-2 text-sm">
<%= airworthiness_badge(aw) %>
<%= aircraft_status_badge(aircraft) unless aircraft.status == "AVAILABLE" %>
<span class="text-slate-500"><%= t(".tach_hobbs_html", tach_time: (hours(aircraft.tach_time)), hobbs_time: (hours(aircraft.hobbs_time))) %></span>
<span class="badge-gray" title="<%= t(".your_access_to_this_aircraft") %>"><%= current_role&.name || t(".admin") %></span>
</div>
</div>
</div>
<div class="flex w-full gap-2 sm:w-auto [&>a]:flex-1 [&>a]:justify-center [&>a]:whitespace-nowrap max-sm:[&>a]:px-2 sm:[&>a]:flex-none">
<% if can?(:log_flights) %><%= link_to t(".log_flight"), new_aircraft_flight_log_path(aircraft), class: "btn-primary" %><% end %>
<% if can?(:report_squawks) %><%= link_to t(".report_squawk"), new_aircraft_squawk_path(aircraft), class: "btn-secondary" %><% end %>
<%= more_menu do %>
<%= link_to t(".status_report"), aircraft_report_path(aircraft), class: "menu-item" %>
<% if can?(:manage_people) || can?(:manage_sharing) || can?(:export_data) %><%= link_to t(".access_sharing"), aircraft_aircraft_roles_path(aircraft), class: "menu-item" %><% end %>
<% if can?(:edit_aircraft) %><%= link_to t(".edit_aircraft"), edit_aircraft_path(aircraft), class: "menu-item" %><% end %>
<% if can?(:export_data) %>
<%= link_to t(".download_sam_zip"), aircraft_export_path(aircraft), class: "menu-item", data: { turbo: false } %>
<%= link_to t(".download_records_package"), aircraft_records_package_path(aircraft), class: "menu-item", data: { turbo: false } %>
<% end %>
<% end %>
</div>
</div>
<% tabs = aircraft_tabs(aircraft) %>
<% current_tab = tabs.find { |_, _, names| names.include?(controller_name) } %>
<%# Phones: the current section, with every section a tap away. %>
<details class="relative mb-5 md:hidden" data-controller="dropdown" data-action="click@window->dropdown#closeOutside keydown.esc@window->dropdown#close">
<summary class="flex cursor-pointer list-none items-center justify-between rounded-md bg-surface px-4 py-3 font-medium shadow-sm ring-1 ring-slate-200 [&::-webkit-details-marker]:hidden">
<span><span class="text-xs font-normal text-slate-500"><%= t(".section") %></span><br><%= current_tab&.first || t(".choose_a_section") %></span>
<span aria-hidden="true" class="text-slate-500">▾</span>
</summary>
<nav class="absolute inset-x-0 z-30 mt-2 grid grid-cols-2 gap-1 rounded-md bg-surface p-2 shadow-lg ring-1 ring-slate-200" aria-label="<%= t(".aircraft_sections") %>">
<% tabs.each do |label, path, names| %>
<%= link_to label, path, class: [ "rounded px-3 py-2.5 text-sm hover:bg-slate-100", (names.include?(controller_name) ? "bg-slate-100 font-semibold text-sky-700" : "text-slate-700") ],
aria: { current: (names.include?(controller_name) ? "page" : nil) } %>
<% end %>
</nav>
</details>
<nav class="mb-5 hidden flex-wrap border-b border-slate-200 md:flex" aria-label="<%= t(".aircraft_sections") %>">
<% tabs.each do |label, path, names| %>
<%= nav_tab label, path, names.include?(controller_name) %>
<% end %>
</nav>