<%= form_with model: ad, url: ad.new_record? ? aircraft_airworthiness_directives_path(aircraft) : aircraft_airworthiness_directive_path(aircraft, ad), class: "card card-body space-y-4 max-w-3xl" do |f| %> <%= f.errors_summary %>
<%= f.field :name, label: "Number", required: true, placeholder: "2011-10-09" %> <%= f.field :bulletin_type, as: :select, label: "Type", collection: AirworthinessDirective::BULLETIN_TYPES.invert %> <%= f.field :compliance_type, as: :select, label: "Compliance", collection: AirworthinessDirective::COMPLIANCE_TYPES.invert, hint: "Conditional ADs only apply when a trigger occurs and don't affect airworthiness." %>
<%= f.field :short_description, required: true %> <%= f.field :required_action, as: :textarea, rows: 3 %> <%= f.field :trigger_condition, as: :textarea, rows: 2, hint: "For conditional ADs (e.g. “on prop strike”)." %>
<%= f.field :mandatory, as: :checkbox, label: "Mandatory" %> <%= f.field :recurring, as: :checkbox, label: "Recurring" %>
<%= f.field :recurring_hours, as: :number, step: 0.1, label: "Every (hours)" %> <%= f.field :recurring_months, as: :number, label: "Every (months)" %> <%= f.field :document_id, as: :select, label: "Reference document", collection: document_options(aircraft) %>
<%= f.field :document_url, label: "Link to AD document", placeholder: "https://…", hint: "Filled in automatically from a DRS Excel export. In DRS, open the AD and copy its link." %> <%= render "shared/applicability_fields", aircraft: aircraft, record: ad, applies_to_airframe: @applies_to_airframe %> <% if ad.persisted? && (ad.aircraft.count + ad.components.where.not(aircraft_id: aircraft.id).count) > 1 %>

This AD is shared with other aircraft; edits affect them too.

<% end %>
<%= f.submit "Save" %><%= link_to "Cancel", aircraft_airworthiness_directives_path(aircraft), class: "btn-secondary" %>
<% end %> <% if ad.persisted? %>
<%= delete_button "Remove from #{aircraft.tail_number}", aircraft_airworthiness_directive_path(aircraft, ad) %>
<% end %>