Files
simple-aircraft-manager-rails/app/javascript/controllers/component_times_controller.js
T
rickyandClaude Opus 5.5 a51f78ebf3 Logbook entries link a component and its times; boxed page printouts
- An entry can link a component (engine, propeller…) and records its total
  time and time since overhaul at the entry; picking the engine or prop log
  selects that component and fills its current times (editable). Squawk
  fixes carry the squawk's component
- Components have an overhaul type (major, factory overhaul, factory new),
  shown as SMOH / SFOH / SNEW
- Printouts: engine and propeller entries add the serial number, total
  time and SMOH/SFOH (blanks when no component is linked); airframe total
  time is labelled as such; full-page layouts draw a box around each entry
- Archives carry the entry's component and times (the original format's
  components / component_hours), no longer dropped on import

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

26 lines
896 B
JavaScript

import { Controller } from "@hotwired/stimulus"
// Logbook entry form: picking an engine or propeller log selects that
// component (if none is chosen yet), and picking a component fills in its
// current total time and time since overhaul.
export default class extends Controller {
static targets = [ "logType", "component", "total", "since" ]
logTypeChanged() {
if (this.componentTarget.value) return
const kind = this.logTypeTarget.value
const match = [ ...this.componentTarget.options ].find((o) => o.dataset.kind && o.dataset.kind === kind)
if (match) {
this.componentTarget.value = match.value
this.componentChanged()
}
}
componentChanged() {
const option = this.componentTarget.selectedOptions[0]
if (!option?.dataset.total) return
this.totalTarget.value = option.dataset.total
this.sinceTarget.value = option.dataset.since
}
}