<% ads = aircraft.applicable_ads.ordered %> <% rules = ads.each_with_object({}) { |ad, h| (r = ad.due_rule) && h[ad.id.to_s] = r } %> <%= form_with model: compliance, url: compliance.new_record? ? aircraft_ad_compliances_path(aircraft) : aircraft_ad_compliance_path(aircraft, compliance), class: "card card-body space-y-4 max-w-2xl", data: { controller: "next-due", next_due_rules_value: rules.to_json } do |f| %> <%= f.errors_summary %> <%= f.field :airworthiness_directive_id, as: :select, label: t(".ad"), collection: ads.map { ["#{_1.name} – #{_1.short_description.truncate(50)}", _1.id] }, data: { next_due_target: "rule", action: "change->next-due#changed" } %>
<%= f.field :date_complied, as: :date, data: { next_due_target: "date", action: "change->next-due#changed" } %> <%= f.field :aircraft_hours_at_compliance, as: :number, step: 0.1, label: t(".aircraft_hours", time_basis_label: aircraft.time_basis_label.downcase), data: { next_due_target: "hours", action: "input->next-due#changed" } %> <%= f.field :next_due_at_time, as: :number, step: 0.1, label: t(".next_due_at_reading", time_basis_label: aircraft.time_basis_label.downcase), hint: t(".calculated_from_the_ad_s"), data: { next_due_target: "dueHours", action: "input->next-due#markManual" } %> <%= f.field :component_id, as: :select, label: t(".component"), collection: component_options(aircraft) %> <%= f.field :logbook_entry_id, as: :select, label: t(".logbook_entry"), collection: logbook_options(aircraft) %>
<%= f.field :compliance_method, as: :select, label: t(".method_of_compliance"), collection: AdCompliance::METHODS.invert, data: { next_due_target: "permanent", action: "change->next-due#changed" } %> <%= f.field :ad_revision, label: t(".ad_revision_complied_with"), placeholder: t(".e_g_2011_10_09"), hint: t(".ad_number_and_revision_or") %>
<%= f.field :permanent, as: :checkbox, label: t(".no_further_action_required_ends"), hint: t(".set_automatically_for_terminating_action"), data: { next_due_target: "permanent", action: "change->next-due#changed" } %> <%= f.field :compliance_notes, as: :textarea, label: t(".details"), rows: 3, required: true, hint: t(".what_was_done_and_per") %>
<%= f.submit t(".save") %><%= link_to t(".cancel"), aircraft_airworthiness_directives_path(aircraft), class: "btn-secondary" %>
<% end %> <% if compliance.persisted? %>
<%= delete_button t(".delete_record"), aircraft_ad_compliance_path(aircraft, compliance) %>
<% end %>