mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 23: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>
85 lines
5.8 KiB
ERB
85 lines
5.8 KiB
ERB
<% content_for :title, t(".import_preview") %>
|
|
<%= render "shared/aircraft_header", aircraft: @aircraft %>
|
|
<% rows = @import.rows %>
|
|
<% problems = rows.select { _1.status.in?(%i[error warning]) } %>
|
|
<% last = @import.last_reading %>
|
|
|
|
<section class="card mb-5">
|
|
<div class="card-header">
|
|
<h2 class="card-title"><%= t(".preview_html", filename: @filename) %></h2>
|
|
<span class="text-xs text-slate-500"><%= t(".columns_found_html", columns: (@import.columns.keys.map { _1.to_s.humanize }.join(", "))) %></span>
|
|
</div>
|
|
<div class="card-body grid grid-cols-2 gap-4 text-center sm:grid-cols-5">
|
|
<div><div class="text-2xl font-semibold"><%= @import.importable.size %></div><div class="text-xs text-slate-500"><%= t(".flights_to_import") %></div></div>
|
|
<div><div class="text-2xl font-semibold"><%= hours(@import.total_tach_hours) %></div><div class="text-xs text-slate-500"><%= t(".tach_hours") %></div></div>
|
|
<div><div class="text-2xl font-semibold text-amber-700"><%= @import.count(:warning) %></div><div class="text-xs text-slate-500"><%= t(".warnings_imported") %></div></div>
|
|
<div><div class="text-2xl font-semibold text-red-700"><%= @import.count(:error) %></div><div class="text-xs text-slate-500"><%= t(".errors_skipped") %></div></div>
|
|
<div><div class="text-2xl font-semibold text-slate-500"><%= @import.count(:duplicate) %></div><div class="text-xs text-slate-500"><%= t(".already_imported") %></div></div>
|
|
</div>
|
|
|
|
<% if @import.importable.any? %>
|
|
<%= form_with url: confirm_aircraft_flight_import_path(@aircraft), class: "space-y-3 border-t border-slate-100 p-4",
|
|
data: { turbo_confirm: t(".import_flights", importable: @import.importable.size) } do |f| %>
|
|
<%= hidden_field_tag :token, @token %>
|
|
<%= hidden_field_tag :filename, @filename %>
|
|
<%= hidden_field_tag :starting_tach, @starting_tach %>
|
|
<%= hidden_field_tag :starting_hobbs, @starting_hobbs %>
|
|
<% if last && last.tach_in > @aircraft.tach_time %>
|
|
<label class="flex items-start gap-2 text-sm">
|
|
<%= check_box_tag :update_aircraft_hours, "1", true, class: "mt-0.5 h-4 w-4" %>
|
|
<span><%= t(".also_update_s_tach_from_html", tail_number: @aircraft.tail_number, tach_time: (hours(@aircraft.tach_time)), tach_in: (hours(last.tach_in))) %>
|
|
<%= t(".and_hobbs_to", hobbs_in: (hours(last.hobbs_in))) if last.hobbs_in && last.hobbs_in >= @aircraft.hobbs_time %>.
|
|
<span class="block text-xs text-slate-500"><%= t(".works_like_a_normal_hours_html", tach_time: (hours(last.tach_in - @aircraft.tach_time))) %></span></span>
|
|
</label>
|
|
<% elsif last %>
|
|
<p class="text-xs text-slate-500"><%= t(".the_aircraft_s_tach_is_html", tach_time: (hours(@aircraft.tach_time)), tach_in: (hours(last.tach_in))) %></p>
|
|
<% end %>
|
|
<div class="flex gap-2">
|
|
<%= f.submit t(".import_flights_2", importable: @import.importable.size), class: "btn-primary" %>
|
|
<%= link_to t(".upload_a_different_file"), new_aircraft_flight_import_path(@aircraft), class: "btn-secondary" %>
|
|
</div>
|
|
<% if @import.count(:error) > 0 %><p class="hint"><%= t(".rows_with_errors_are_skipped") %></p><% end %>
|
|
<% end %>
|
|
<% else %>
|
|
<p class="border-t border-slate-100 p-4 text-sm"><%= t(".nothing_to_import_html", link: (link_to t(".upload_a_different_file"), new_aircraft_flight_import_path(@aircraft), class: "link")) %></p>
|
|
<% end %>
|
|
</section>
|
|
|
|
<% if problems.any? %>
|
|
<section class="card mb-5">
|
|
<div class="card-header"><h2 class="card-title"><%= t(".rows_needing_attention") %></h2></div>
|
|
<table class="table">
|
|
<thead><tr><th><%= t(".row") %></th><th><%= t(".date") %></th><th><%= t(".route") %></th><th class="text-right"><%= t(".tach") %></th><th><%= t(".issue") %></th></tr></thead>
|
|
<tbody>
|
|
<% problems.each do |r| %>
|
|
<tr>
|
|
<td><%= r.line %></td><td class="whitespace-nowrap"><%= r.date || "—" %></td>
|
|
<td><%= [r.from, r.to].compact.join(" → ") %></td><td class="text-right"><%= r.tach_in %></td>
|
|
<td><%= tag.span(r.status == :error ? t(".skipped") : t(".warning"), class: r.status == :error ? "badge-red" : "badge-orange") %> <span class="text-xs"><%= r.messages.join("; ") %></span></td>
|
|
</tr>
|
|
<% end %>
|
|
</tbody>
|
|
</table>
|
|
</section>
|
|
<% end %>
|
|
|
|
<details class="card">
|
|
<summary class="card-header cursor-pointer"><span class="card-title"><%= t(".all_rows_html", rows: rows.size) %></span></summary>
|
|
<div class="overflow-x-auto">
|
|
<table class="table">
|
|
<thead><tr><th><%= t(".row") %></th><th><%= t(".date") %></th><th><%= t(".from") %></th><th><%= t(".to") %></th><th class="text-right"><%= t(".tach") %></th><th class="text-right"><%= t(".tach_hrs") %></th><th class="text-right"><%= t(".hobbs") %></th><th class="text-right"><%= t(".hobbs_hrs") %></th><th class="text-right"><%= t(".oil") %></th><th class="text-right"><%= t(".fuel") %></th><th></th></tr></thead>
|
|
<tbody>
|
|
<% rows.each do |r| %>
|
|
<tr class="<%= 'opacity-50' unless r.importable? %>">
|
|
<td><%= r.line %></td><td class="whitespace-nowrap"><%= fmt_date(r.date) %></td><td><%= r.from %></td><td><%= r.to %></td>
|
|
<td class="text-right tabular-nums"><%= r.tach_in %></td><td class="text-right tabular-nums"><%= hours(r.tach_time) if r.tach_time %></td>
|
|
<td class="text-right tabular-nums"><%= r.hobbs_in %></td><td class="text-right tabular-nums"><%= hours(r.hobbs_time) if r.hobbs_time %></td>
|
|
<td class="text-right"><%= r.oil %></td><td class="text-right"><%= r.fuel %></td>
|
|
<td><%= { ok: "", warning: tag.span("warning", class: "badge-orange"), error: tag.span("skipped", class: "badge-red"), duplicate: tag.span("duplicate", class: "badge-gray") }[r.status] %></td>
|
|
</tr>
|
|
<% end %>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</details>
|