Files
rickyandClaude Opus 5.5 03b9ad65cb Workflow polish: setup checklist, next leg, grouped component limits
- Setup checklist on a new aircraft's Overview (owners): components,
  standard inspections, DRS AD import, registration/airworthiness
  certificate, weight and balance; hideable per device
- Log Flight: "Save and log next leg" reopens the form on the same date,
  starting where the leg ended
- Component form: limits in two collapsible groups (replacement and expiry;
  overhaul and TBO), open when in use
- Squawk form warns what "Ground Aircraft" does
- Logbook entry form: inspection result only for inspection entries
  (show-when controller); document names default from the file
- Dates in pickers, the activity log, airworthiness lines, search, audits
  and transcription notes use the app format
- No duplicate Report Squawk button on Squawks; "Record service" label

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 07:43:03 -05:00

68 lines
4.5 KiB
ERB

<%= form_with model: [aircraft, component], class: "card card-body space-y-5 max-w-4xl" do |f| %>
<%= f.errors_summary %>
<div class="grid gap-4 sm:grid-cols-3">
<div>
<%= f.field :component_type_id, as: :select, label: t(".type"),
collection: ComponentType.ordered.map { [_1.name, _1.id] }, include_blank: t(".select") %>
<%= text_field_tag :new_component_type, params[:new_component_type], class: "input mt-2", placeholder: t(".or_type_a_new_one") %>
</div>
<%= f.field :manufacturer, required: true %>
<%= f.field :model, required: true %>
<%= f.field :serial_number %>
<%= f.field :install_location, hint: t(".e_g_left_mag_3") %>
<%= f.field :status, as: :select, collection: Component::STATUSES.invert %>
<%= f.field :parent_component_id, as: :select, label: t(".parent_component"),
collection: [[t(".none"), nil]] + aircraft.components.where.not(id: component.id).includes(:component_type).map { [_1.to_s, _1.id] } %>
</div>
<fieldset class="grid gap-4 sm:grid-cols-4">
<legend class="mb-2 text-sm font-semibold text-slate-900"><%= t(".time") %></legend>
<%= f.field :date_in_service, as: :date, required: true %>
<%= f.field :hours_in_service, as: :number, step: 0.1, label: t(".total_time_hours") %>
<%= f.field :overhaul_date, as: :date, label: t(".last_overhaul_service") %>
<%= f.field :hours_since_overhaul, as: :number, step: 0.1, label: t(".hours_since_oh_service") %>
</fieldset>
<%# Limits, in two groups that open when they're in use (most parts need one or neither). %>
<% c = component %>
<% replacement_open = c.replacement_hours.present? || c.replacement_calendar? || c.replacement_critical? || c.expires_on.present? ||
%i[replacement_hours replacement_every expires_on].any? { c.errors[_1].any? } %>
<% tbo_open = c.tbo_hours.present? || c.tbo_calendar? || c.overhaul_kind.present? || c.on_condition? || %i[tbo_hours tbo_every].any? { c.errors[_1].any? } %>
<details class="rounded-md ring-1 ring-slate-200" <%= "open" if replacement_open %>>
<summary class="cursor-pointer px-3 py-2 text-sm font-semibold text-slate-900"><%= t(".replacement_group") %>
<span class="font-normal text-slate-500"><%= t(".replacement_group_hint") %></span></summary>
<div class="grid gap-4 border-t border-slate-200 p-3 sm:grid-cols-3">
<%= f.field :replacement_hours, as: :number, label: t(".replace_every_hrs") %>
<%= f.interval :replacement, label: t(".replace_every") %>
<%= f.field :replacement_from_install, as: :select, label: t(".replacement_counts_from"),
collection: [ [ t(".last_service"), false ], [ t(".installation_life_limit"), true ] ],
hint: t(".installation_for_a_part_that") %>
<%= f.field :replacement_critical, as: :checkbox, label: t(".replacement_critical"), hint: t(".overdue_replacement_or_expiry_grounds") %>
<%= f.field :expires_on, as: :date, label: t(".expires_on"),
hint: t(".the_date_marked_on_the") %>
</div>
</details>
<details class="rounded-md ring-1 ring-slate-200" <%= "open" if tbo_open %>>
<summary class="cursor-pointer px-3 py-2 text-sm font-semibold text-slate-900"><%= t(".tbo_group") %>
<span class="font-normal text-slate-500"><%= t(".tbo_group_hint") %></span></summary>
<div class="grid gap-4 border-t border-slate-200 p-3 sm:grid-cols-3">
<%= f.field :tbo_hours, as: :number, label: t(".tbo_hrs") %>
<%= f.interval :tbo, label: t(".tbo_calendar") %>
<%= f.field :overhaul_kind, as: :select, label: t(".overhaul_type"), include_blank: "—", collection: Component::OVERHAUL_KINDS.invert,
hint: t(".for_engines_and_propellers_printed") %>
<%= f.field :tbo_critical, as: :checkbox, label: t(".treat_tbo_as_a_hard"), hint: t(".under_part_91_tbo_is") %>
<%= f.field :on_condition, as: :checkbox, label: t(".on_condition_part_91"), hint: t(".run_past_tbo_based_on") %>
</div>
</details>
<p class="hint"><%= t(".recurring_inspections_of_this_part") %></p>
<%= f.field :notes, as: :textarea, rows: 3 %>
<div class="flex gap-2">
<%= f.submit component.new_record? ? t(".add_component") : t(".save") %>
<%= link_to t(".cancel"), aircraft_components_path(aircraft), class: "btn-secondary" %>
</div>
<% end %>
<% if component.persisted? %>
<div class="mt-4"><%= delete_button t(".delete_component"), aircraft_component_path(aircraft, component), confirm: t(".delete_and_its_sub_components", component: component) %></div>
<% end %>