mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 15:50:36 -05:00
Since invitations from an aircraft's Access page only worked for existing accounts, they did almost what "Add by email" does. The Access page keeps adding people by email; new people come through the administrator (Admin → Users or Admin → Invitations), and outside mechanics through an Owner's signing invitation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
98 lines
5.4 KiB
ERB
98 lines
5.4 KiB
ERB
<% content_for :title, t(".access", tail_number: @aircraft.tail_number) %>
|
|
<%= render "shared/aircraft_header", aircraft: @aircraft %>
|
|
<h2 class="mb-4 text-lg font-semibold"><%= t(".access_sharing_html") %></h2>
|
|
<div class="grid gap-5 lg:grid-cols-2">
|
|
<% if can?(:manage_people) %>
|
|
<section class="card">
|
|
<div class="card-header"><h2 class="card-title"><%= t(".people") %></h2></div>
|
|
<% roles = @access.assignable_roles %>
|
|
<table class="table">
|
|
<tbody>
|
|
<% @roles.each do |r| %>
|
|
<tr>
|
|
<td><%= r.user.display_name %><div class="text-xs text-slate-500"><%= r.user.email_address %></div></td>
|
|
<td>
|
|
<% if roles.include?(r.role) && (r.user != current_user || current_user.admin?) %>
|
|
<%= form_with url: aircraft_aircraft_role_path(@aircraft, r), method: :patch do |f| %>
|
|
<%= f.select :role_id, roles.map { [ _1.name, _1.id ] }, { selected: r.role_id }, class: "input w-36", "aria-label": t(".role_for", display_name: r.user.display_name), data: { submit_on_change: true } %>
|
|
<% end %>
|
|
<% else %>
|
|
<span class="badge-gray" title="<%= r.role.description %>"><%= r.role.name %></span>
|
|
<% end %>
|
|
</td>
|
|
<td class="text-right"><% if r.user != current_user && roles.include?(r.role) %><%= delete_button t(".remove"), aircraft_aircraft_role_path(@aircraft, r), confirm: t(".remove_s_access", display_name: r.user.display_name) %><% end %></td>
|
|
</tr>
|
|
<% end %>
|
|
</tbody>
|
|
</table>
|
|
<%= form_with url: aircraft_aircraft_roles_path(@aircraft), class: "flex flex-wrap items-end gap-2 border-t border-slate-100 p-4" do |f| %>
|
|
<div class="w-full sm:w-auto sm:flex-1"><%= f.label :email_address, t(".add_by_email"), class: "label" %><%= f.email_field :email_address, class: "input", required: true %></div>
|
|
<%= f.select :role_id, roles.map { [ _1.name, _1.id ] }, { selected: Role.for_key("pilot").id }, class: "input w-36", "aria-label": t(".role") %>
|
|
<%= f.submit t(".add"), class: "btn-primary" %>
|
|
<% end %>
|
|
<details class="px-4 pb-4 text-sm">
|
|
<summary class="cursor-pointer text-slate-600"><%= t(".what_each_role_can_do") %></summary>
|
|
<dl class="mt-2 space-y-1">
|
|
<% Role.ordered.each do |role| %><div><dt class="inline font-semibold"><%= role.name %>:</dt> <dd class="inline text-slate-600"><%= role.description.presence || role.permissions.map { Permission.label(_1) }.to_sentence %></dd></div><% end %>
|
|
</dl>
|
|
<p class="hint mt-2"><%= t(".roles_are_set_by_an_administrator") %></p>
|
|
</details>
|
|
</section>
|
|
|
|
<% end %>
|
|
|
|
<% if can?(:manage_sharing) %>
|
|
<section class="card">
|
|
<div class="card-header"><h2 class="card-title"><%= t(".share_links") %></h2></div>
|
|
<% if @share_tokens.any? %>
|
|
<ul class="divide-y divide-slate-100">
|
|
<% @share_tokens.each do |t| %>
|
|
<li class="px-4 py-3">
|
|
<div class="flex items-center justify-between gap-2">
|
|
<div>
|
|
<span class="font-medium"><%= t.label.presence || t(".untitled_link") %></span>
|
|
<%= tag.span ShareToken::PRIVILEGES[t.privilege], class: t.maintenance? ? "badge-blue" : "badge-green" %>
|
|
<% if t.expired? %><span class="badge-red"><%= t(".expired") %></span><% end %>
|
|
</div>
|
|
<%= delete_button t(".revoke"), aircraft_share_token_path(@aircraft, t), confirm: t(".revoke_this_link_anyone_using") %>
|
|
</div>
|
|
<input type="text" readonly value="<%= shared_url(t.token) %>" class="input mt-2 font-mono text-xs" data-select-on-click>
|
|
<div class="mt-1 text-xs text-slate-500"><%= t(".created_html", to_date: (fmt_date(t.created_at.to_date)), created_by: (" by #{t.created_by.display_name}" if t.created_by), expires: (t.expires_at ? "expires #{l t.expires_at, format: :short}" : t(".never_expires"))) %></div>
|
|
</li>
|
|
<% end %>
|
|
</ul>
|
|
<% else %>
|
|
<%= empty_state t(".no_share_links") %>
|
|
<% end %>
|
|
<%= form_with model: ShareToken.new, url: aircraft_share_tokens_path(@aircraft), class: "space-y-3 border-t border-slate-100 p-4" do |f| %>
|
|
<div class="grid gap-3 sm:grid-cols-3">
|
|
<%= f.field :label, placeholder: t(".mechanic_buyer") %>
|
|
<%= f.field :privilege, as: :select, label: t(".shows"), collection: ShareToken::PRIVILEGES.invert %>
|
|
<%= f.field :expires_at, as: :datetime, label: t(".expires_optional") %>
|
|
</div>
|
|
<p class="hint"><%= t(".current_status_overview_airworthiness_components_html") %></p>
|
|
<%= f.submit t(".create_share_link") %>
|
|
<% end %>
|
|
</section>
|
|
<% end %>
|
|
|
|
<% if can?(:export_data) %>
|
|
<section class="card lg:col-span-2">
|
|
<div class="card-header">
|
|
<div>
|
|
<h2 class="card-title"><%= t(".backup_transfer_html") %></h2>
|
|
<p class="hint"><%= t(".everything_recorded_for_with_its_html", tail_number: @aircraft.tail_number) %></p>
|
|
</div>
|
|
<%= link_to t(".download_sam_zip"), aircraft_export_path(@aircraft), class: "btn-secondary", data: { turbo: false } %>
|
|
</div>
|
|
<div class="card-header border-t border-slate-100">
|
|
<div>
|
|
<h2 class="card-title"><%= t(".records_package") %></h2>
|
|
<p class="hint"><%= t(".for_an_faa_or_ntsb") %></p>
|
|
</div>
|
|
<%= link_to t(".download_records_package"), aircraft_records_package_path(@aircraft), class: "btn-secondary", data: { turbo: false } %>
|
|
</div>
|
|
</section>
|
|
<% end %>
|
|
</div>
|