<% content_for :title, t(".loading_setup", tail_number: @aircraft.tail_number) %> <%= render "shared/aircraft_header", aircraft: @aircraft %> <% stations = @setup.stations + Array.new([ 8 - @setup.stations.size, 2 ].max) { nil } %> <% points = @setup.entered_envelope + Array.new([ 10 - @setup.envelope.size, 2 ].max) { nil } %> <%= form_with url: aircraft_loading_setup_path(@aircraft), method: :patch, class: "card card-body max-w-3xl space-y-5" do %>

<%= t(".loading_setup_2") %>

<%= t(".from_the_poh_s_weight") %>

<% if @setup.errors.any? %> <% end %>
<%= t(".stations") %>
<%= t(".name") %><%= t(".arm_in") %><%= t(".max_lb_gal") %><%= t(".fuel") %>
<% stations.each_with_index do |st, i| %>
<%= text_field_tag "setup[stations][#{i}][name]", st&.name, class: "input", placeholder: (t(".front_seats") if i.zero?), "aria-label": t(".station_name", i: (i + 1)) %> <%= text_field_tag "setup[stations][#{i}][arm]", st&.arm&.to_s&.sub(/\.0\z/, ""), class: "input", inputmode: "decimal", "aria-label": t(".station_arm", i: (i + 1)) %> <%= text_field_tag "setup[stations][#{i}][max]", st&.max&.to_s&.sub(/\.0\z/, ""), class: "input", inputmode: "decimal", "aria-label": t(".station_maximum", i: (i + 1)) %> <%= check_box_tag "setup[stations][#{i}][fuel]", "1", st&.fuel, class: "mx-auto block h-4 w-4", "aria-label": t(".station_is_fuel", i: (i + 1)) %>
<% end %>

<%= t(".tick_fuel_for_fuel_tanks") %>

<%= label_tag "setup[fuel_lb_per_gal]", t(".fuel_weight_lb_per_gallon"), class: "label" %> <%= text_field_tag "setup[fuel_lb_per_gal]", @setup.fuel_lb_per_gal.to_s.sub(/\.0\z/, ""), class: "input", inputmode: "decimal" %>

<%= t(".n6_for_avgas_6_7") %>

<%= t(".cg_envelope") %>

<%= t(".the_corners_of_the_normal") %>

<%= label_tag "setup[envelope_unit]", t(".envelope_values_are"), class: "label" %> <%= select_tag "setup[envelope_unit]", options_for_select(LoadingSetup::ENVELOPE_UNITS.invert, @setup.envelope_unit), class: "input" %>

<%= t(".use_the_same_units_as") %>

<%= t(".weight_lb") %><%= @setup.moment? ? t(".moment_lb_in_1000") : t(".cg_in_2") %><%= t(".cg_in") if @setup.moment? %>
<% points.each_with_index do |pt, i| %>
<%= text_field_tag "setup[envelope][#{i}][weight]", pt&.first&.to_s&.sub(/\.0\z/, ""), class: "input", inputmode: "decimal", "aria-label": t(".envelope_point_weight", i: (i + 1)) %> <%= text_field_tag "setup[envelope][#{i}][cg]", pt&.last&.to_s&.sub(/\.0\z/, ""), class: "input", inputmode: "decimal", "aria-label": t(".envelope_point", i: (i + 1), moment: (@setup.moment? ? 'moment' : 'CG')) %> <%= "#{@setup.envelope[i].last.round(2)} in" if @setup.moment? && @setup.envelope[i] %>
<% end %>
<%= submit_tag t(".save"), class: "btn-primary" %><%= link_to t(".cancel"), aircraft_weight_balance_records_path(@aircraft), class: "btn-secondary" %>
<% end %>