mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 15:50:36 -05:00
- Views use lazy t(".key") lookups; sentences with values or links stay
whole (interpolation, _html keys); counts use one/other plurals
- Stored-value labels (statuses, types, priorities...) are LabelSets read
from labels: in the current locale; field names and validation messages
under activerecord:; flash and activity text under flash:
- Services, models, helpers, mailer subjects, the logbook PDF, procedures
templates, records package README and transcription warnings localized;
the PDF reuses LogbookEntry#certification_statement instead of a copy
- Scripts read js: strings from a JSON tag via app/javascript/i18n.js
- Dates through I18n.l (app, weekday, month_year, long formats); html lang
follows the locale
- APP_LOCALE picks the language (falls back to English); missing
translations raise in development and tests
- README: Translating section and APP_LOCALE
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
89 lines
5.7 KiB
ERB
89 lines
5.7 KiB
ERB
<% content_for :title, @component.to_s %>
|
|
<%= render "shared/aircraft_header", aircraft: @aircraft %>
|
|
<div class="grid gap-5 lg:grid-cols-3">
|
|
<section class="card lg:col-span-2">
|
|
<div class="card-header">
|
|
<h2 class="card-title"><%= @component %> <%= life_badge(@component.life_status) %></h2>
|
|
<% if owner? %>
|
|
<div class="flex gap-2">
|
|
<%= link_to t(".sub_component"), new_aircraft_component_path(@aircraft, parent_id: @component.id), class: "btn-secondary btn-sm" %>
|
|
<%= link_to t(".edit"), edit_aircraft_component_path(@aircraft, @component), class: "btn-secondary btn-sm" %>
|
|
</div>
|
|
<% end %>
|
|
</div>
|
|
<dl class="card-body grid grid-cols-2 gap-x-4 gap-y-2 text-sm sm:grid-cols-4">
|
|
<dt class="text-slate-500"><%= t(".manufacturer") %></dt><dd><%= @component.manufacturer %></dd>
|
|
<dt class="text-slate-500"><%= t(".model") %></dt><dd><%= @component.model %></dd>
|
|
<dt class="text-slate-500"><%= t(".serial") %></dt><dd><%= @component.serial_number.presence || "—" %></dd>
|
|
<dt class="text-slate-500"><%= t(".status") %></dt><dd><%= @component.status_label %></dd>
|
|
<dt class="text-slate-500"><%= t(".parent") %></dt><dd><%= @component.parent_component ? link_to(@component.parent_component, aircraft_component_path(@aircraft, @component.parent_component), class: "link") : "—" %></dd>
|
|
<dt class="text-slate-500"><%= t(".location") %></dt><dd><%= @component.install_location.presence || "—" %></dd>
|
|
<dt class="text-slate-500"><%= t(".in_service_since") %></dt><dd><%= fmt_date(@component.date_in_service) %></dd>
|
|
<dt class="text-slate-500"><%= t(".last_oh_service") %></dt><dd><%= fmt_date(@component.overhaul_date) %></dd>
|
|
<dt class="text-slate-500"><%= t(".hours_in_service") %></dt><dd><%= hours(@component.hours_in_service) %></dd>
|
|
<dt class="text-slate-500"><%= t(".since_oh_service") %></dt><dd><%= hours(@component.hours_since_overhaul) %></dd>
|
|
<dt class="text-slate-500"><%= t(".tbo") %></dt><dd><%= @component.tbo_hours ? t(".h_remaining", tbo_hours: @component.tbo_hours, hours_to_tbo: (hours(@component.hours_to_tbo))) : "—" %></dd>
|
|
<dt class="text-slate-500"><%= t(".replacement") %></dt><dd>
|
|
<%= [@component.replacement_hours && "#{@component.replacement_hours} h", @component.replacement_interval_label].compact.join(" / ").presence&.then { @component.replacement_from_install? ? t(".since_installed", interval: _1) : _1 } || "—" %>
|
|
<% if (d = @component.next_replacement_date) %><div class="text-xs text-slate-500"><%= t(".next_by_html", d: (fmt_date(d))) %></div><% end %>
|
|
</dd>
|
|
<dt class="text-slate-500"><%= t(".flags") %></dt>
|
|
<dd class="col-span-3 flex flex-wrap gap-1">
|
|
<% { tbo_critical: t(".tbo_critical"), replacement_critical: t(".replacement_critical"), on_condition: t(".on_condition") }.each do |flag, label| %>
|
|
<% if @component.public_send("#{flag}?") %><span class="badge-blue"><%= label %></span><% end %>
|
|
<% end %>
|
|
</dd>
|
|
</dl>
|
|
<% if @component.notes.present? %><div class="border-t border-slate-100 px-4 py-3 text-sm"><%= simple_format @component.notes %></div><% end %>
|
|
</section>
|
|
|
|
<% if owner? %>
|
|
<section class="card" id="service">
|
|
<div class="card-header"><h2 class="card-title"><%= t(".service_replace") %></h2></div>
|
|
<%= form_with url: reset_service_aircraft_component_path(@aircraft, @component), method: :post, class: "card-body space-y-3",
|
|
data: { turbo_confirm: t(".reset_hours_for", component: @component) } do |f| %>
|
|
<p class="text-sm text-slate-600"><%= t(".resets_hours_since_overhaul_to_html") %></p>
|
|
<label class="flex items-start gap-2 text-sm">
|
|
<%= f.check_box :reset_in_service, class: "mt-0.5 h-4 w-4" %>
|
|
<span><%= t(".part_was_physically_replaced_also_html") %></span>
|
|
</label>
|
|
<%= f.submit t(".record_service"), class: "btn-primary" %>
|
|
<% end %>
|
|
</section>
|
|
<% end %>
|
|
</div>
|
|
|
|
<% if @inspection_rows.any? || owner? %>
|
|
<section class="card mt-5" id="inspections">
|
|
<div class="card-header">
|
|
<h2 class="card-title"><%= t(".inspections_of_this_component") %></h2>
|
|
<% if owner? %><%= link_to t(".inspection"), new_aircraft_inspection_type_path(@aircraft, component_id: @component.id), class: "btn-secondary btn-sm" %><% end %>
|
|
</div>
|
|
<% if @inspection_rows.any? %>
|
|
<table class="table">
|
|
<thead><tr><th><%= t(".inspection_2") %></th><th><%= t(".interval") %></th><th><%= t(".last_done") %></th><th><%= t(".next_due") %></th><th><%= t(".status") %></th></tr></thead>
|
|
<tbody>
|
|
<% @inspection_rows.each do |row| %>
|
|
<tr>
|
|
<td class="font-medium"><%= row.type.name %><%= tag.span(t(".advisory"), class: "text-xs text-slate-500") if row.type.advisory? %></td>
|
|
<td class="text-xs"><%= row.type.interval_description %></td>
|
|
<td class="text-xs"><%= row.latest ? "#{fmt_date(row.latest.date)} @ #{hours(row.latest.hours_at_inspection)} h" : "—" %></td>
|
|
<td class="text-xs"><%= [row.next_due_date&.to_s, row.next_due_hours && "#{hours(row.next_due_hours)} h"].compact.join(" / ").presence || "—" %></td>
|
|
<td><%= compliance_badge(row.status) %></td>
|
|
</tr>
|
|
<% end %>
|
|
</tbody>
|
|
</table>
|
|
<% else %>
|
|
<p class="card-body text-sm text-slate-500"><%= t(".none_add_one_for_a") %></p>
|
|
<% end %>
|
|
</section>
|
|
<% end %>
|
|
|
|
<% if @squawks.any? %>
|
|
<section class="card mt-5">
|
|
<div class="card-header"><h2 class="card-title"><%= t(".squawks_on_this_component") %></h2></div>
|
|
<%= render "squawks/table", squawks: @squawks, aircraft: @aircraft %>
|
|
</section>
|
|
<% end %>
|