%# 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| %>
<%= day.date.strftime("%a %b %-d, %Y") %><%= pluralize(day.flights.size, "flight") %>
<%= day.route.presence || blank %>
<% if day.track_log? %>π<% end %>
<% if day.engine_data? %>π<% end %>
<% if day.pilots.any? %><%= day.pilots.to_sentence %><% end %>
Tach <%= day.tach_time ? hours(day.tach_time) : blank %>
Hobbs <%= day.hobbs_time ? hours(day.hobbs_time) : blank %>
Fuel <%= qty.(day.fuel_added) %>
Oil <%= qty.(day.oil_added) %>
<% day.flights.each_with_index do |fl, i| %>
Leg Route Tach Hobbs Fuel (gal) Oil (qt) Pilot
<% end %>
<%= link_to "Leg #{i + 1}", aircraft_flight_log_path(@aircraft, fl), class: "link" %>
<%= fl.route_summary.presence || blank %>
<% if fl.track_log.attached? %>π<% end %>
<% if fl.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 %>
Loading earlier flights⦠<%= link_to "Load more", aircraft_flight_logs_path(@aircraft, page: page + 1), class: "link", data: { turbo_frame: "flight-days-#{page + 1}" } %>
<% end %> <% end %> <% end %>