Files
simple-aircraft-manager-rails/app/views/oil_analyses/index.html.erb
T
rickyandClaude Opus 5.5 89ed0a76f9 Move all user-facing text into config/locales/en.yml for localization
- 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>
2026-11-13 22:08:20 -05:00

89 lines
5.1 KiB
ERB

<% content_for :title, t(".oil_analysis", tail_number: @aircraft.tail_number) %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<%= render "shared/oil_subnav", aircraft: @aircraft %>
<% recent = @analyses.first(OilAnalysesController::COMPARE_SAMPLES) %>
<div class="space-y-5">
<section class="card">
<div class="card-header">
<div>
<h2 class="card-title"><%= t(".import_a_lab_report") %></h2>
<p class="hint"><%= t(".avlab_or_blackstone_pdf_reports") %></p>
</div>
<%= render "import", aircraft: @aircraft %>
</div>
</section>
<section class="card">
<div class="card-header">
<h2 class="card-title"><%= t(".wear_metal_trends") %></h2>
<%= link_to t(".add_oil_analysis"), new_aircraft_oil_analysis_path(@aircraft), class: "btn-secondary btn-sm" %>
</div>
<div class="card-body">
<% series = oil_trend_series(@analyses) %>
<% if series.any? %>
<%= line_chart series, ytitle: "ppm", height: "260px", curve: false, colors: OilAnalysesHelper::TREND_COLORS, legend: "bottom" %>
<p class="hint"><%= t(".lead_is_left_out_of_html", excluded_from_averages: (t(".samples_marked_leave_out_of") if @analyses.any?(&:excluded_from_averages?))) %></p>
<% else %>
<%= empty_state @analyses.any? ? t(".add_another_sample_to_see") : t(".no_oil_analyses_yet_add") %>
<% end %>
</div>
</section>
<% if recent.any?(&:any_results?) %>
<section class="card">
<div class="card-header"><h2 class="card-title"><%= t(".results_ppm") %></h2>
<span class="text-xs text-slate-500"><%= t(".lab_average_for_similar_engines") %> <span class="font-semibold text-red-700"><%= t(".red") %></span> <%= t(".is_or_more_above_it_html", ratio: (OilAnalysis::FLAG_RATIO)) %></span></div>
<div class="overflow-x-auto">
<table class="table table-keep">
<thead>
<tr><th><%= t(".element") %></th>
<% recent.each do |a| %><th class="text-right whitespace-nowrap"><%= link_to fmt_date(a.sample_date), aircraft_oil_analysis_path(@aircraft, a), class: "link" %></th><% end %></tr>
</thead>
<tbody>
<tr class="text-xs text-slate-500"><td><%= t(".engine_oil_hrs") %></td>
<% recent.each do |a| %><td class="text-right tabular-nums"><%= a.engine_hours ? hours(a.engine_hours) : "—" %> / <%= a.oil_hours ? hours(a.oil_hours) : "—" %></td><% end %></tr>
<% OilAnalysis.elements_in(recent).each do |el| %>
<% label, source = OilAnalysis::ELEMENTS.fetch(el), OilAnalysis::ELEMENT_SOURCES[el] %>
<tr><td><span title="<%= source %>"><%= label %></span></td>
<% recent.each do |a| %><td class="text-right align-top"><%= ppm_cell(a, el) %></td><% end %></tr>
<% end %>
<% OilAnalysis::PROPERTIES.each_key do |key| %>
<% next if recent.none? { _1.property(key) } %>
<tr class="text-sm"><td class="text-slate-600"><%= OilAnalysis::PROPERTIES[key] %></td>
<% recent.each do |a| %><td class="text-right tabular-nums whitespace-nowrap text-slate-600"><%= oil_property(a, key) %></td><% end %></tr>
<% end %>
</tbody>
</table>
</div>
</section>
<% end %>
<section class="card">
<div class="card-header"><h2 class="card-title"><%= t(".samples") %></h2></div>
<% if @analyses.any? %>
<div class="overflow-x-auto">
<table class="table">
<thead><tr><th><%= t(".sampled") %></th><th><%= t(".result") %></th><th><%= t(".engine") %></th><th class="text-right"><%= t(".engine_hrs") %></th><th class="text-right"><%= t(".oil_hrs") %></th><th><%= t(".lab") %></th><th><%= t(".report") %></th></tr></thead>
<tbody>
<% @analyses.each do |a| %>
<tr>
<td class="whitespace-nowrap"><%= link_to fmt_date(a.sample_date), aircraft_oil_analysis_path(@aircraft, a), class: "link" %>
<% if a.excluded_from_averages? %><div class="text-xs text-slate-500"><%= t(".left_out_of_trends") %></div><% end %></td>
<td class="whitespace-nowrap"><%= oil_status_badge(a) %>
<% if (flags = a.flagged_elements).any? %><span class="ml-1 text-xs text-red-700"><%= t(".above_average_html", to_sentence: (flags.map { OilAnalysis.element_label(_1) }.to_sentence)) %></span><% end %></td>
<td><%= a.component&.to_s || "—" %></td>
<td class="text-right tabular-nums"><%= a.engine_hours ? hours(a.engine_hours) : "—" %></td>
<td class="text-right tabular-nums"><%= a.oil_hours ? hours(a.oil_hours) : "—" %></td>
<td><%= [ a.lab, a.sample_number ].compact.join(" · ").presence || "—" %></td>
<td><%= a.report.attached? ? link_to(t(".pdf"), rails_blob_path(a.report, disposition: :inline), class: "link", target: "_blank", rel: "noopener") : "—" %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
<% else %>
<%= empty_state t(".no_samples_recorded") %>
<% end %>
</section>
</div>