%# One page of days. Rendered inside its own frame; the last day is followed
by a lazy frame that loads the next page when it scrolls into view.
Links in it open in the whole page (target _top). %>
<% blank = tag.span("—", class: "text-slate-300") %>
<% qty = ->(v) { v ? number_with_precision(v, precision: 2, strip_insignificant_zeros: true) : blank } %>
<%= turbo_frame_tag "flight-days-#{page}", target: "_top", class: "block" do %>
<% days.each do |day| %>
<%= l(day.date, format: :weekday) %><%= t("counts.flight", count: day.flights.size) %>
<%= day.route.presence || blank %>
<% if day.track_log? %>" aria-label="<%= t(".gps_track_attached") %>">📍<% end %>
<% if day.engine_data? %>" aria-label="<%= t(".engine_data_attached") %>">📈<% end %>
<% if day.pilots.any? %><%= day.pilots.to_sentence %><% end %>
<%= t(".tach") %> <%= day.tach_time ? hours(day.tach_time) : blank %>
<%= t(".hobbs") %> <%= day.hobbs_time ? hours(day.hobbs_time) : blank %>
<%= t(".fuel") %> <%= qty.(day.fuel_added) %>
<%= t(".oil") %> <%= qty.(day.oil_added) %>
<% day.flights.each_with_index do |fl, i| %>
<%= t(".leg") %> <%= t(".route") %> <%= t(".tach") %> <%= t(".hobbs") %> <%= t(".fuel_gal") %> <%= t(".oil_qt") %> <%= t(".pilot") %>
<% end %>
<%= link_to t(".leg_2", i: i + 1), aircraft_flight_log_path(@aircraft, fl), class: "link" %>
<%= fl.route_summary.presence || blank %>
<% if fl.track_log.attached? %>" aria-label="<%= t(".gps_track_attached") %>">📍<% end %>
<% if fl.engine_data.attached? %>" aria-label="<%= t(".engine_data_attached") %>">📈<% end %>
<%= fl.tach_time ? hours(fl.tach_time) : blank %>
<%= fl.hobbs_time ? hours(fl.hobbs_time) : blank %>
<%= qty.(fl.fuel_added) %>
<%= qty.(fl.oil_added) %>
<%= fl.user&.display_name || blank %>
<%= t(".loading_earlier_flights_html", link: (link_to t(".load_more"), aircraft_flight_logs_path(@aircraft, page: page + 1), class: "link", data: { turbo_frame: "flight-days-#{page + 1}" })) %>
<% end %> <% end %> <% end %>