<%= form_with model: [aircraft, analysis], class: "card card-body space-y-5 max-w-4xl" do |f| %> <%= f.errors_summary %>
<%= f.field :sample_date, as: :date, required: true %> <%= f.field :analysis_date, as: :date %> <%= f.field :status, as: :select, label: t(".lab_s_verdict"), collection: [ [ t(".not_rated"), "" ] ] + OilAnalysis::STATUSES.invert.to_a %> <%= f.field :component_id, as: :select, label: t(".engine"), collection: component_options(aircraft) %> <%= f.field :lab, placeholder: t(".avlab_blackstone") %> <%= f.field :sample_number, label: t(".sample_lab") %> <%= f.field :oil_type, label: t(".oil"), placeholder: t(".aeroshell_w100"), wrapper: { class: "sm:col-span-2" } %>
<%= t(".hours") %> <%= f.field :engine_hours, as: :number, step: 0.1, label: t(".engine_tsn_tso") %> <%= f.field :oil_hours, as: :number, step: 0.1, label: t(".on_oil") %> <%= f.field :filter_hours, as: :number, step: 0.1, label: t(".on_filter") %> <%= f.field :oil_added, as: :number, step: 0.25, label: t(".oil_added_qt") %>
<%= t(".results_ppm") %>

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

<%= render partial: "element_input", collection: OilAnalysis::COMMON_ELEMENTS, as: :element, locals: { analysis: analysis } %>
<% extra = OilAnalysis::ELEMENTS.keys - OilAnalysis::COMMON_ELEMENTS %>
> <%= t(".more_elements_blackstone_and_other") %>
<%= render partial: "element_input", collection: extra, as: :element, locals: { analysis: analysis } %>
> <%= t(".oil_properties") %>
<% OilAnalysis::PROPERTIES.each do |key, label| %><% unit = OilAnalysis::PROPERTY_UNITS[key] %>
<%= label_tag "oil_analysis_oil_properties_#{key}", [ label, (unit.presence && "(#{unit})") ].compact.join(" "), class: "label" %> <%= number_field_tag "oil_analysis[oil_properties][#{key}]", analysis.property(key), id: "oil_analysis_oil_properties_#{key}", step: "any", min: 0, class: "input" %>
<% end %>
<%= f.field :excluded_from_averages, as: :checkbox, label: t(".leave_out_of_trends"), hint: t(".for_a_sample_that_isn") %> <%= f.field :lab_comments, as: :textarea, rows: 2 %> <%= f.field :notes, as: :textarea, rows: 2 %> <%= f.field :report, as: :file, label: t(".lab_report_pdf"), accept: ".pdf,application/pdf,image/*" %> <% if analysis.report.attached? %>

<%= t(".current_choosing_a_file_replaces_html", filename: analysis.report.filename) %>

<% end %>
<%= f.submit t(".save") %><%= link_to t(".cancel"), analysis.persisted? ? aircraft_oil_analysis_path(aircraft, analysis) : aircraft_oil_analyses_path(aircraft), class: "btn-secondary" %>
<% end %>