Files
simple-aircraft-manager-rails/app/views/components/_form.html.erb
T
rickyandClaude Opus 5.5 352a38c7fb 2026.11.1: offline flight logging fixed, inspections from logbook entries, life limits from installation, component inspections moved to inspection types
- Service worker keeps the Log Flight form when opened via Turbo, serves the offline page's script and icon, and treats 502/503/504 as offline; the offline page only links forms actually kept
- Serviced sub-components restart from the airframe time flown since the entry
- New logbook entries can complete inspections (recorded and linked to the entry)
- Components: replacement limit can count from installation (life limit)
- Component-level "Inspect every" / "Inspection critical" removed; a migration converts any unlinked settings into inspection types with a first record; component page lists its inspections

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 07:30:59 -05:00

58 lines
3.9 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: "Type",
collection: ComponentType.ordered.map { [_1.name, _1.id] }, include_blank: "— Select —" %>
<%= text_field_tag :new_component_type, params[:new_component_type], class: "input mt-2", placeholder: "…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: "e.g. Left mag, #3 cylinder" %>
<%= f.field :status, as: :select, collection: Component::STATUSES.invert %>
<%= f.field :parent_component_id, as: :select, label: "Parent component",
collection: [["— 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">Time</legend>
<%= f.field :date_in_service, as: :date, required: true %>
<%= f.field :hours_in_service, as: :number, step: 0.1, label: "Total time (hours)" %>
<%= f.field :overhaul_date, as: :date, label: "Last overhaul / service" %>
<%= f.field :hours_since_overhaul, as: :number, step: 0.1, label: "Hours since OH / service" %>
<%= f.field :overhaul_kind, as: :select, label: "Overhaul type", include_blank: "—", collection: Component::OVERHAUL_KINDS.invert,
wrapper: { class: "sm:col-span-2" }, hint: "For engines and propellers: printed in logbook entries as SMOH, SFOH or SNEW." %>
</fieldset>
<fieldset class="grid gap-4 sm:grid-cols-3">
<legend class="mb-2 text-sm font-semibold text-slate-900">Limits</legend>
<%= f.field :replacement_hours, as: :number, label: "Replace every (hrs)" %>
<%= f.interval :replacement, label: "Replace every" %>
<%= f.field :replacement_from_install, as: :select, label: "Replacement counts from",
collection: [ [ "Last service", false ], [ "Installation (life limit)", true ] ],
hint: "Installation: for a part that's cleaned and reused but has a life limit (e.g. a reusable oil filter); only Replaced restarts it." %>
<%= f.field :replacement_critical, as: :checkbox, label: "Replacement critical", hint: "Overdue replacement or expiry grounds the aircraft (oil, filters, ELT battery…)." %>
<%= f.field :expires_on, as: :date, label: "Expires on",
hint: "The date marked on the part, e.g. an ELT battery's replacement date (14 CFR 91.207(c): also replace it after 1 hour of cumulative use)." %>
<%= f.field :tbo_hours, as: :number, label: "TBO (hrs)" %>
<%= f.interval :tbo, label: "TBO (calendar)" %>
<div class="space-y-2">
<%= f.field :tbo_critical, as: :checkbox, label: "Treat TBO as a hard limit",
hint: "Under Part 91, TBO is usually the manufacturer's recommendation, unless an AD or the Airworthiness Limitations make it mandatory." %>
<%= f.field :on_condition, as: :checkbox, label: "On condition (Part 91)",
hint: "Run past TBO based on condition: TBO is shown for reference, never as a limit (this overrides the hard limit)." %>
</div>
<p class="hint sm:col-span-3">Recurring inspections of this part (e.g. a 500-hour magneto inspection) are set up on the Inspections tab and applied to it.</p>
</fieldset>
<%= f.field :notes, as: :textarea, rows: 3 %>
<div class="flex gap-2">
<%= f.submit component.new_record? ? "Add Component" : "Save" %>
<%= link_to "Cancel", aircraft_components_path(aircraft), class: "btn-secondary" %>
</div>
<% end %>
<% if component.persisted? %>
<div class="mt-4"><%= delete_button "Delete component", aircraft_component_path(aircraft, component), confirm: "Delete #{component} and its sub-components?" %></div>
<% end %>