mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 23:50:36 -05:00
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>
This commit is contained in:
1 parent
3452a35896
commit
03b9ad65cb
34 files changed
+303
-77
No files matched your search
@@ -14,6 +14,7 @@ class DocumentsController < ApplicationController
|
||||
|
||||
def new
|
||||
@document = @aircraft.documents.new(document_collection_id: params[:collection_id])
|
||||
@document.doc_type = params[:doc_type] if Document::TYPES.key?(params[:doc_type])
|
||||
end
|
||||
|
||||
def create
|
||||
|
||||
@@ -49,7 +49,13 @@ class FlightLogsController < ApplicationController
|
||||
def new
|
||||
# Aircraft almost always depart from where they last landed.
|
||||
last = @aircraft.flight_logs.where.not(destination_location: [ nil, "" ]).recent_first.first
|
||||
@flight_log = @aircraft.flight_logs.new(date: Date.current, tach_out: @aircraft.tach_time,
|
||||
# "Save and log next leg" comes back here with that flight's date.
|
||||
date = begin
|
||||
Date.iso8601(params[:date].to_s)
|
||||
rescue Date::Error
|
||||
Date.current
|
||||
end
|
||||
@flight_log = @aircraft.flight_logs.new(date: date, tach_out: @aircraft.tach_time,
|
||||
hobbs_out: @aircraft.hobbs_time,
|
||||
departure_location: last&.destination_location)
|
||||
end
|
||||
@@ -62,7 +68,12 @@ class FlightLogsController < ApplicationController
|
||||
@flight_log = @aircraft.flight_logs.new(flight_log_params)
|
||||
if @flight_log.valid?
|
||||
HoursService.new(@aircraft).log_flight!(@flight_log)
|
||||
redirect_to aircraft_flight_logs_path(@aircraft), notice: t("flash.flight_logs.flight_logged_hrs", tach_time: @flight_log.tach_time)
|
||||
notice = t("flash.flight_logs.flight_logged_hrs", tach_time: @flight_log.tach_time)
|
||||
if params[:next_leg].present?
|
||||
redirect_to new_aircraft_flight_log_path(@aircraft, date: @flight_log.date.iso8601), notice: "#{notice} #{t('flash.flight_logs.next_leg')}"
|
||||
else
|
||||
redirect_to aircraft_flight_logs_path(@aircraft), notice: notice
|
||||
end
|
||||
else
|
||||
render :new, status: :unprocessable_entity
|
||||
end
|
||||
|
||||
@@ -18,7 +18,7 @@ class LogbookEntriesController < ApplicationController
|
||||
# Someone has checked a transcribed entry against the scan.
|
||||
def verify
|
||||
@entry.update!(verified: true)
|
||||
log_event("logbook", t("flash.logbook_entries.transcribed_logbook_entry_verified", date: @entry.date))
|
||||
log_event("logbook", t("flash.logbook_entries.transcribed_logbook_entry_verified", date: l(@entry.date, format: :app)))
|
||||
next_entry = @aircraft.logbook_entries.unverified.order(:date, :id).first
|
||||
redirect_to next_entry ? aircraft_logbook_entry_path(@aircraft, next_entry) : aircraft_logbook_entries_path(@aircraft),
|
||||
notice: next_entry ? t("flash.logbook_entries.verified_next") : t("flash.logbook_entries.verified_all")
|
||||
@@ -36,7 +36,7 @@ class LogbookEntriesController < ApplicationController
|
||||
@entry.supersedes = correctable(params.dig(:logbook_entry, :supersedes_id))
|
||||
@entry.assign_parts(parts_params, @aircraft)
|
||||
if @entry.save
|
||||
log_event("logbook", t(@entry.supersedes ? "flash.logbook_entries.correction_added_event" : "flash.logbook_entries.logbook_entry_added", date: @entry.date))
|
||||
log_event("logbook", t(@entry.supersedes ? "flash.logbook_entries.correction_added_event" : "flash.logbook_entries.logbook_entry_added", date: l(@entry.date, format: :app)))
|
||||
record_parts_service
|
||||
record_inspections
|
||||
redirect_to aircraft_logbook_entry_path(@aircraft, @entry),
|
||||
@@ -52,7 +52,7 @@ class LogbookEntriesController < ApplicationController
|
||||
@entry.assign_attributes(entry_params)
|
||||
@entry.assign_parts(parts_params, @aircraft)
|
||||
if @entry.save
|
||||
log_event("logbook", t("flash.logbook_entries.logbook_entry_updated_2", date: @entry.date))
|
||||
log_event("logbook", t("flash.logbook_entries.logbook_entry_updated_2", date: l(@entry.date, format: :app)))
|
||||
redirect_to aircraft_logbook_entry_path(@aircraft, @entry), notice: t("flash.logbook_entries.logbook_entry_updated")
|
||||
else
|
||||
render :edit, status: :unprocessable_entity
|
||||
@@ -61,7 +61,7 @@ class LogbookEntriesController < ApplicationController
|
||||
|
||||
def destroy
|
||||
@entry.destroy!
|
||||
log_event("logbook", t("flash.logbook_entries.logbook_entry_deleted_2", date: @entry.date))
|
||||
log_event("logbook", t("flash.logbook_entries.logbook_entry_deleted_2", date: l(@entry.date, format: :app)))
|
||||
redirect_to aircraft_logbook_entries_path(@aircraft), notice: t("flash.logbook_entries.logbook_entry_deleted")
|
||||
end
|
||||
|
||||
@@ -98,8 +98,8 @@ class LogbookEntriesController < ApplicationController
|
||||
next unless p["include"] == "1" && %w[serviced replaced].include?(p["service"])
|
||||
part = @entry.parts.find { _1.component_id == id.to_i } or next
|
||||
component = part.component
|
||||
component.service_from_entry!(date: @entry.date, hours_at_entry: part.hours_at_entry, flown_since: flown, replaced: p["service"] == "replaced")
|
||||
log_event("component", t(p["service"] == "replaced" ? "flash.logbook_entries.replaced_event" : "flash.logbook_entries.serviced_event", component: component, date: @entry.date))
|
||||
component.service_from_entry!(date: l(@entry.date, format: :app), hours_at_entry: part.hours_at_entry, flown_since: flown, replaced: p["service"] == "replaced")
|
||||
log_event("component", t(p["service"] == "replaced" ? "flash.logbook_entries.replaced_event" : "flash.logbook_entries.serviced_event", component: component, date: l(@entry.date, format: :app)))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -108,9 +108,9 @@ class LogbookEntriesController < ApplicationController
|
||||
def record_inspections
|
||||
ids = Array(params.dig(:logbook_entry, :inspection_type_ids)).compact_blank
|
||||
@aircraft.applicable_inspection_types.where(id: ids).find_each do |type|
|
||||
@aircraft.inspection_records.create!(inspection_type: type, logbook_entry: @entry, date: @entry.date,
|
||||
@aircraft.inspection_records.create!(inspection_type: type, logbook_entry: @entry, date: l(@entry.date, format: :app),
|
||||
aircraft_hours: @entry.aircraft_hours_at_entry)
|
||||
log_event("inspection", t("flash.logbook_entries.inspection_completed_logbook_entry", name: type.name, date: @entry.date))
|
||||
log_event("inspection", t("flash.logbook_entries.inspection_completed_logbook_entry", name: type.name, date: l(@entry.date, format: :app)))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ class OilAnalysesController < ApplicationController
|
||||
def create
|
||||
@analysis = @aircraft.oil_analyses.new(analysis_params)
|
||||
if @analysis.save
|
||||
log_event("oil_analysis", t("flash.oil_analyses.oil_analysis_added_sampled", sample_date: @analysis.sample_date))
|
||||
log_event("oil_analysis", t("flash.oil_analyses.oil_analysis_added_sampled", sample_date: l(@analysis.sample_date, format: :app)))
|
||||
redirect_to aircraft_oil_analysis_path(@aircraft, @analysis), notice: t("flash.oil_analyses.oil_analysis_saved")
|
||||
else
|
||||
render :new, status: :unprocessable_entity
|
||||
@@ -69,7 +69,7 @@ class OilAnalysesController < ApplicationController
|
||||
|
||||
def update
|
||||
if @analysis.update(analysis_params)
|
||||
log_event("oil_analysis", t("flash.oil_analyses.oil_analysis_updated_sampled", sample_date: @analysis.sample_date))
|
||||
log_event("oil_analysis", t("flash.oil_analyses.oil_analysis_updated_sampled", sample_date: l(@analysis.sample_date, format: :app)))
|
||||
redirect_to aircraft_oil_analysis_path(@aircraft, @analysis), notice: t("flash.oil_analyses.oil_analysis_updated")
|
||||
else
|
||||
render :edit, status: :unprocessable_entity
|
||||
@@ -78,7 +78,7 @@ class OilAnalysesController < ApplicationController
|
||||
|
||||
def destroy
|
||||
@analysis.destroy!
|
||||
log_event("oil_analysis", t("flash.oil_analyses.oil_analysis_deleted_sampled", sample_date: @analysis.sample_date))
|
||||
log_event("oil_analysis", t("flash.oil_analyses.oil_analysis_deleted_sampled", sample_date: l(@analysis.sample_date, format: :app)))
|
||||
redirect_to aircraft_oil_analyses_path(@aircraft), notice: t("flash.oil_analyses.oil_analysis_deleted")
|
||||
end
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ class SigningInvitationsController < ApplicationController
|
||||
PushNotifier.notify(invitee, :signing_request, path: invited_signing_path(@invitation.token), tag: "sign-#{@invitation.id}",
|
||||
tail: @aircraft.tail_number, name: current_user.display_name)
|
||||
end
|
||||
log_event("logbook", t("flash.signing_invitations.signature_requested_from_entry", email: @invitation.email, date: @entry.date))
|
||||
log_event("logbook", t("flash.signing_invitations.signature_requested_from_entry", email: @invitation.email, date: l(@entry.date, format: :app)))
|
||||
redirect_to aircraft_logbook_entry_path(@aircraft, @entry), notice: t("flash.signing_invitations.invitation_sent_to_the", email: @invitation.email, days: SigningInvitation::VALID_FOR.in_days.to_i)
|
||||
else
|
||||
render :new, status: :unprocessable_entity
|
||||
|
||||
@@ -64,7 +64,7 @@ class SquawksController < ApplicationController
|
||||
@entry = @aircraft.logbook_entries.new(resolution_entry_params.merge(entry_type: "MAINTENANCE"))
|
||||
@entry.assign_parts(params.fetch(:logbook_entry, {}).permit(parts: {})[:parts]&.to_h || {}, @aircraft)
|
||||
return render(:resolution, status: :unprocessable_entity) unless @entry.save
|
||||
log_event("logbook", t("flash.squawks.logbook_entry_added", date: @entry.date))
|
||||
log_event("logbook", t("flash.squawks.logbook_entry_added", date: l(@entry.date, format: :app)))
|
||||
@entry
|
||||
when "existing" then @aircraft.logbook_entries.find_by(id: params[:logbook_entry_id])
|
||||
end
|
||||
|
||||
@@ -30,7 +30,7 @@ class WeightBalanceRecordsController < ApplicationController
|
||||
|
||||
def update
|
||||
if @record.update(record_params)
|
||||
log_event("aircraft", t("flash.weight_balance_records.weight_balance_updated_2", date: @record.date))
|
||||
log_event("aircraft", t("flash.weight_balance_records.weight_balance_updated_2", date: l(@record.date, format: :app)))
|
||||
redirect_to aircraft_weight_balance_records_path(@aircraft), notice: t("flash.weight_balance_records.weight_balance_updated")
|
||||
else
|
||||
render :edit, status: :unprocessable_entity
|
||||
@@ -39,7 +39,7 @@ class WeightBalanceRecordsController < ApplicationController
|
||||
|
||||
def destroy
|
||||
@record.destroy!
|
||||
log_event("aircraft", t("flash.weight_balance_records.weight_balance_record_deleted", date: @record.date))
|
||||
log_event("aircraft", t("flash.weight_balance_records.weight_balance_record_deleted", date: l(@record.date, format: :app)))
|
||||
redirect_to aircraft_weight_balance_records_path(@aircraft), notice: t("flash.weight_balance_records.record_deleted")
|
||||
end
|
||||
|
||||
|
||||
@@ -30,6 +30,17 @@ module AircraftHelper
|
||||
]
|
||||
end
|
||||
|
||||
# Getting a new aircraft set up (Overview): [key, done?, path] for each step.
|
||||
def setup_steps(aircraft)
|
||||
[
|
||||
[ :components, aircraft.components.exists?, new_aircraft_component_path(aircraft) ],
|
||||
[ :inspections, aircraft.applicable_inspection_types.exists?, new_aircraft_standard_inspections_path(aircraft) ],
|
||||
[ :ads, aircraft.drs_imports.exists? || aircraft.applicable_ads.exists?, new_aircraft_ad_import_path(aircraft) ],
|
||||
[ :documents, aircraft.documents.where(doc_type: %w[REGISTRATION AIRWORTHINESS_CERT]).exists?, new_aircraft_document_path(aircraft, doc_type: "REGISTRATION") ],
|
||||
[ :weight_balance, aircraft.weight_balance_records.exists?, new_aircraft_weight_balance_record_path(aircraft) ]
|
||||
]
|
||||
end
|
||||
|
||||
def component_options(aircraft, include_blank: true)
|
||||
opts = aircraft.components.where.not(status: "DISPOSED").includes(:component_type).map { [ _1.to_s, _1.id ] }
|
||||
include_blank ? [ [ I18n.t("helpers.aircraft.none"), nil ] ] + opts : opts
|
||||
@@ -40,6 +51,6 @@ module AircraftHelper
|
||||
end
|
||||
|
||||
def logbook_options(aircraft)
|
||||
[ [ I18n.t("helpers.aircraft.none"), nil ] ] + aircraft.logbook_entries.recent_first.limit(300).map { [ I18n.t("helpers.aircraft.text", date: _1.date, truncate: (_1.text.truncate(60))), _1.id ] }
|
||||
[ [ I18n.t("helpers.aircraft.none"), nil ] ] + aircraft.logbook_entries.recent_first.limit(300).map { [ I18n.t("helpers.aircraft.entry_option", date: fmt_date(_1.date), text: _1.text.truncate(60)), _1.id ] }
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,15 @@
|
||||
import { Controller } from "@hotwired/stimulus"
|
||||
|
||||
// A card that can be hidden for good on this device (e.g. the setup checklist).
|
||||
export default class extends Controller {
|
||||
static values = { key: String }
|
||||
|
||||
connect() {
|
||||
try { if (localStorage.getItem(this.keyValue)) this.element.hidden = true } catch (_) { /* storage off */ }
|
||||
}
|
||||
|
||||
hide() {
|
||||
try { localStorage.setItem(this.keyValue, "1") } catch (_) { /* storage off */ }
|
||||
this.element.hidden = true
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,10 @@ export default class extends Controller {
|
||||
if (this.textTarget.value.trim() && !confirm(t("entry_template.confirm"))) return
|
||||
const { text, entryType, logType, certificate } = option.dataset
|
||||
this.textTarget.value = text
|
||||
if (entryType && this.hasEntryTypeTarget) this.entryTypeTarget.value = entryType
|
||||
if (entryType && this.hasEntryTypeTarget) {
|
||||
this.entryTypeTarget.value = entryType
|
||||
this.entryTypeTarget.dispatchEvent(new Event("change", { bubbles: true }))
|
||||
}
|
||||
if (logType && this.hasLogTypeTarget && this.logTypeTarget.value !== logType) {
|
||||
this.logTypeTarget.value = logType
|
||||
this.logTypeTarget.dispatchEvent(new Event("change", { bubbles: true }))
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import { Controller } from "@hotwired/stimulus"
|
||||
|
||||
// A new document's name, when left blank, comes from its first file's name
|
||||
// ("annual-2026_scan.pdf" → "annual 2026 scan").
|
||||
export default class extends Controller {
|
||||
static targets = [ "name", "file" ]
|
||||
|
||||
fill() {
|
||||
const file = this.fileTarget.files[0]
|
||||
if (!file || this.nameTarget.value.trim()) return
|
||||
this.nameTarget.value = file.name.replace(/\.[^.]+$/, "").replace(/[_-]+/g, " ").replace(/\s+/g, " ").trim()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import { Controller } from "@hotwired/stimulus"
|
||||
|
||||
// Shows parts of a form only when a select has a given value, e.g. the
|
||||
// inspection result only for inspection entries. A part hidden by changing
|
||||
// the select is cleared, so it isn't saved.
|
||||
// <select data-show-when-target="source" data-action="show-when#update">
|
||||
// <div data-show-when-target="item" data-show-when-value="INSPECTION">
|
||||
export default class extends Controller {
|
||||
static targets = [ "source", "item" ]
|
||||
|
||||
connect() { this.update() }
|
||||
|
||||
update(event) {
|
||||
for (const item of this.itemTargets) {
|
||||
const show = item.dataset.showWhenValue.split(" ").includes(this.sourceTarget.value)
|
||||
if (event && !show && !item.hidden) item.querySelectorAll("select, input:not([type=hidden]), textarea").forEach((el) => { el.value = "" })
|
||||
item.hidden = !show
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -112,7 +112,7 @@ class LogbookTranscriptionJob < ApplicationJob
|
||||
text = entry["text"].to_s.strip.presence || I18n.t("jobs.logbook_transcription.no_text")
|
||||
unless date
|
||||
text = "#{I18n.t('jobs.logbook_transcription.date_unreadable')} #{text}"
|
||||
warn(@last_date ? I18n.t("jobs.logbook_transcription.no_date_previous", page: page_number, date: @last_date)
|
||||
warn(@last_date ? I18n.t("jobs.logbook_transcription.no_date_previous", page: page_number, date: I18n.l(@last_date, format: :app))
|
||||
: I18n.t("jobs.logbook_transcription.no_date_today", page: page_number))
|
||||
end
|
||||
date ||= @last_date || Date.current
|
||||
@@ -129,7 +129,7 @@ class LogbookTranscriptionJob < ApplicationJob
|
||||
verified: false, transcription_confidence: (entry["confidence"] if %w[high medium low].include?(entry["confidence"]))
|
||||
)
|
||||
@import.increment!(:entries_created)
|
||||
warn(I18n.t("jobs.logbook_transcription.hard_to_read", date: date, page: page_number)) if entry["confidence"] == "low"
|
||||
warn(I18n.t("jobs.logbook_transcription.hard_to_read", date: I18n.l(date, format: :app), page: page_number)) if entry["confidence"] == "low"
|
||||
end
|
||||
|
||||
def note_skipped(result, label)
|
||||
|
||||
@@ -95,7 +95,7 @@ class Airworthiness
|
||||
end
|
||||
@aircraft.squawks.deferred.find_each do |squawk|
|
||||
add("DEFERRED", INFO, t(:inoperative, issue: squawk.issue_reported.to_s.truncate(80)),
|
||||
t(:deferred, date: squawk.deferred_at.to_date, name: squawk.deferred_by_name), squawk)
|
||||
t(:deferred, date: I18n.l(squawk.deferred_at.to_date, format: :app), name: squawk.deferred_by_name), squawk)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -134,9 +134,9 @@ class Airworthiness
|
||||
grounds = Document::GROUNDING_EXPIRY_TYPES.include?(doc.doc_type)
|
||||
if doc.expired?(@today)
|
||||
add("DOCUMENT", grounds ? RED : ORANGE, t(:expired_title, name: doc.name),
|
||||
t(grounds ? :document_expired_grounds : :document_expired, type: doc.type_label, date: doc.expires_on), doc)
|
||||
t(grounds ? :document_expired_grounds : :document_expired, type: doc.type_label, date: I18n.l(doc.expires_on, format: :app)), doc)
|
||||
elsif @today + doc.expiry_warning_days >= doc.expires_on
|
||||
add("DOCUMENT", ORANGE, t(:expires_soon_title, name: doc.name), t(:document_expires, type: doc.type_label, date: doc.expires_on), doc)
|
||||
add("DOCUMENT", ORANGE, t(:expires_soon_title, name: doc.name), t(:document_expires, type: doc.type_label, date: I18n.l(doc.expires_on, format: :app)), doc)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -163,7 +163,7 @@ class Airworthiness
|
||||
if c.replacement_critical? && (due = c.next_replacement_date)
|
||||
if @today >= due
|
||||
overdue = true
|
||||
desc = t(c.replacement_from_install? ? :replace_every_installed : :replace_every_serviced, interval: c.replacement_interval_label, date: c.replacement_counted_from)
|
||||
desc = t(c.replacement_from_install? ? :replace_every_installed : :replace_every_serviced, interval: c.replacement_interval_label, date: c.replacement_counted_from && I18n.l(c.replacement_counted_from, format: :app))
|
||||
elsif @today + DAYS_WARNING >= due
|
||||
approaching = true
|
||||
desc = t(:replace_in_days, count: (due - @today).to_i)
|
||||
@@ -174,11 +174,11 @@ class Airworthiness
|
||||
if c.expires_on
|
||||
if c.expired?(@today)
|
||||
expired = true
|
||||
desc = t(:component_expired, date: c.expires_on)
|
||||
desc = t(:component_expired, date: I18n.l(c.expires_on, format: :app))
|
||||
elsif @today + DAYS_WARNING >= c.expires_on
|
||||
approaching = true
|
||||
expiring = true
|
||||
desc = t(:component_expires, date: c.expires_on)
|
||||
desc = t(:component_expires, date: I18n.l(c.expires_on, format: :app))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ class EntrySigner
|
||||
auth_method: @auth_method, ip_address: @request&.remote_ip, user_agent: @request&.user_agent.to_s.first(255)
|
||||
)
|
||||
@entry.supersedes&.update_column(:superseded_at, signature.signed_at)
|
||||
@entry.aircraft.log_event!("logbook", "Logbook entry signed electronically (#{@entry.date})",
|
||||
@entry.aircraft.log_event!("logbook", I18n.t("services.entry_signer.signed_event", date: I18n.l(@entry.date, format: :app)),
|
||||
notes: I18n.t("services.entry_signer.text", signer_name: signature.signer_name, certificate_label: signature.certificate_label, certificate_number: signature.certificate_number), user: @user)
|
||||
signature
|
||||
end
|
||||
|
||||
@@ -27,7 +27,7 @@ class RecordsAudit
|
||||
drs_item,
|
||||
Item.new("procedures", t(:procedures), true,
|
||||
revision.present? && @policy.complete?,
|
||||
revision ? t(:revision, number: revision.number, date: revision.adopted_at.to_date) : t(:not_adopted)),
|
||||
revision ? t(:revision, number: revision.number, date: I18n.l(revision.adopted_at.to_date, format: :app)) : t(:not_adopted)),
|
||||
Item.new("signatures", t(:signatures), true,
|
||||
check.present? && check.ok, t(:signed_since, count: signatures_since.count, since: since_label)),
|
||||
Item.new("certificates", t(:certificates), true, true,
|
||||
|
||||
@@ -23,7 +23,7 @@ class RecordsIntegrity
|
||||
next if sig.imported? || sig.status != :altered
|
||||
entry = sig.logbook_entry
|
||||
problems << I18n.t(sig.seal_valid? ? "services.records_integrity.entry_changed" : "services.records_integrity.signature_altered",
|
||||
tail_number: entry.aircraft.tail_number, date: entry.date, signer: sig.signer_name)
|
||||
tail_number: entry.aircraft.tail_number, date: I18n.l(entry.date, format: :app), signer: sig.signer_name)
|
||||
end
|
||||
AppRevision.touch_current!
|
||||
IntegrityCheck.create!(ok: problems.empty?, versions_checked: versions, signatures_checked: signatures, problems: problems.first(200))
|
||||
|
||||
@@ -23,11 +23,11 @@ class SiteSearch
|
||||
return {} unless searchable?
|
||||
@results ||= {
|
||||
"logbook" => find(LogbookEntry.where(aircraft_id: @ids).order(date: :desc), %w[text signoff_person signoff_location]) { |e, s|
|
||||
[ I18n.t("services.site_search.logbook", date: e.date, log: LogbookEntry::LOG_TYPES[e.log_type]), s, @urls.aircraft_logbook_entry_path(e.aircraft_id, e) ] },
|
||||
[ I18n.t("services.site_search.logbook", date: I18n.l(e.date, format: :app), log: LogbookEntry::LOG_TYPES[e.log_type]), s, @urls.aircraft_logbook_entry_path(e.aircraft_id, e) ] },
|
||||
"squawk" => find(Squawk.where(aircraft_id: @ids).order(created_at: :desc), %w[issue_reported notes deferral_notes]) { |q, s|
|
||||
[ q.resolved? ? I18n.t("services.site_search.resolved", issue: q.issue_reported.truncate(80)) : q.issue_reported.truncate(80), s, @urls.aircraft_squawks_path(q.aircraft_id) ] },
|
||||
"note" => find(AircraftNote.where(aircraft_id: @ids).order(created_at: :desc), %w[text]) { |n, s|
|
||||
[ I18n.t("services.site_search.note", date: n.created_at.to_date), s, @urls.aircraft_notes_path(n.aircraft_id) ] },
|
||||
[ I18n.t("services.site_search.note", date: I18n.l(n.created_at.to_date, format: :app)), s, @urls.aircraft_notes_path(n.aircraft_id) ] },
|
||||
"ad" => ads,
|
||||
"document" => find(Document.where(aircraft_id: @ids).order(:name), %w[name description pages_text]) { |d, s|
|
||||
[ d.name, s, @urls.aircraft_document_path(d.aircraft_id, d) ] },
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<%# Shown to owners until the aircraft is set up; Hide keeps it hidden on this device. %>
|
||||
<% steps = setup_steps(aircraft) %>
|
||||
<% if steps.any? { !_2 } %>
|
||||
<section class="card" data-controller="dismiss" data-dismiss-key-value="sam-setup-hidden-<%= aircraft.id %>">
|
||||
<div class="card-header">
|
||||
<div>
|
||||
<h2 class="card-title"><%= t(".title", tail_number: aircraft.tail_number) %></h2>
|
||||
<p class="text-xs text-slate-500"><%= t(".progress", done: steps.count { _2 }, total: steps.size) %></p>
|
||||
</div>
|
||||
<button type="button" class="btn-secondary btn-sm" data-action="dismiss#hide"><%= t(".hide") %></button>
|
||||
</div>
|
||||
<ol class="divide-y divide-slate-100">
|
||||
<% steps.each do |key, done, path| %>
|
||||
<li class="flex items-start gap-3 px-4 py-3">
|
||||
<span aria-hidden="true" class="<%= done ? "text-emerald-600" : "text-slate-400" %>"><%= done ? "✓" : "○" %></span>
|
||||
<div class="min-w-0 flex-1 text-sm">
|
||||
<% if done %>
|
||||
<span class="text-slate-500 line-through"><%= t(".#{key}.title") %></span>
|
||||
<% else %>
|
||||
<%= link_to t(".#{key}.title"), path, class: "link font-medium" %>
|
||||
<p class="hint"><%= t(".#{key}.why") %></p>
|
||||
<% end %>
|
||||
</div>
|
||||
</li>
|
||||
<% end %>
|
||||
</ol>
|
||||
</section>
|
||||
<% end %>
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
<div class="grid gap-5 lg:grid-cols-3">
|
||||
<div class="space-y-5 lg:col-span-2">
|
||||
<% if owner? %><%= render "aircraft/setup", aircraft: @aircraft %><% end %>
|
||||
<section class="card">
|
||||
<div class="card-header">
|
||||
<h2 class="card-title"><%= t(".airworthiness") %></h2>
|
||||
|
||||
@@ -21,30 +21,40 @@
|
||||
<%= 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") %>
|
||||
<%= f.field :overhaul_kind, as: :select, label: t(".overhaul_type"), include_blank: "—", collection: Component::OVERHAUL_KINDS.invert,
|
||||
wrapper: { class: "sm:col-span-2" }, hint: t(".for_engines_and_propellers_printed") %>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="grid gap-4 sm:grid-cols-3">
|
||||
<legend class="mb-2 text-sm font-semibold text-slate-900"><%= t(".limits") %></legend>
|
||||
<%= 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") %>
|
||||
<%= f.field :tbo_hours, as: :number, label: t(".tbo_hrs") %>
|
||||
<%= f.interval :tbo, label: t(".tbo_calendar") %>
|
||||
<div class="space-y-2">
|
||||
<%= 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") %>
|
||||
<%# 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>
|
||||
<p class="hint sm:col-span-3"><%= t(".recurring_inspections_of_this_part") %></p>
|
||||
</fieldset>
|
||||
</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">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<%= form_with model: [aircraft, document], class: "card card-body space-y-4 max-w-3xl", multipart: true do |f| %>
|
||||
<%= form_with model: [aircraft, document], class: "card card-body space-y-4 max-w-3xl", multipart: true, data: { controller: "name-from-file" } do |f| %>
|
||||
<%= f.errors_summary %>
|
||||
<div class="grid gap-4 sm:grid-cols-2">
|
||||
<%= f.field :name, required: true %>
|
||||
<%= f.field :name, required: true, data: { name_from_file_target: "name" } %>
|
||||
<%= f.field :doc_type, as: :select, label: t(".type"), collection: Document::TYPES.invert %>
|
||||
<%= f.field :document_collection_id, as: :select, label: t(".collection"),
|
||||
collection: [[t(".none"), nil]] + aircraft.document_collections.ordered.map { [_1.name, _1.id] } %>
|
||||
@@ -14,7 +14,7 @@
|
||||
hint: t(".optional_registration_good_for_7") %>
|
||||
<%= f.field :description, as: :textarea, rows: 2 %>
|
||||
<%= f.field :pages, as: :file, multiple: true, label: document.persisted? ? t(".add_files") : t(".files"),
|
||||
hint: t(".images_pdfs_or_text_up", max_upload_mb: Setting.max_upload_mb) %>
|
||||
hint: t(".images_pdfs_or_text_up", max_upload_mb: Setting.max_upload_mb), data: { name_from_file_target: "file", action: "name-from-file#fill" } %>
|
||||
<% if document.persisted? && document.pages.any? %>
|
||||
<div>
|
||||
<p class="label"><%= t(".remove_existing_files") %></p>
|
||||
|
||||
@@ -39,5 +39,9 @@
|
||||
<%= f.field :engine_data, as: :file, label: t(".engine_monitor_data"), hint: t(".cgr_30p_cgr_30c_flight"), accept: ".csv,text/csv" %>
|
||||
</div>
|
||||
<p class="hint"><%= t(".saving_adds_the_tach_time") %></p>
|
||||
<div class="flex gap-2"><%= f.submit t(".log_flight") %><%= link_to t(".cancel"), aircraft_flight_logs_path(@aircraft), class: "btn-secondary" %></div>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<%= f.submit t(".log_flight") %>
|
||||
<%= f.submit t(".log_and_next_leg"), name: "next_leg", class: "btn-secondary", title: t(".log_and_next_leg_title") %>
|
||||
<%= link_to t(".cancel"), aircraft_flight_logs_path(@aircraft), class: "btn-secondary" %>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -1,4 +1,4 @@
|
||||
<%= form_with model: [aircraft, entry], class: "card card-body space-y-4 max-w-3xl", data: { controller: "entry-template signer component-times", component_times_aircraft_hours_value: aircraft.current_hours.to_f } do |f| %>
|
||||
<%= form_with model: [aircraft, entry], class: "card card-body space-y-4 max-w-3xl", data: { controller: "entry-template signer component-times show-when", component_times_aircraft_hours_value: aircraft.current_hours.to_f } do |f| %>
|
||||
<%= f.errors_summary %>
|
||||
<% if entry.supersedes %>
|
||||
<%= f.hidden_field :supersedes_id %>
|
||||
@@ -25,7 +25,8 @@
|
||||
<%= f.field :date, as: :date %>
|
||||
<%= f.field :log_type, as: :select, label: t(".logbook"), collection: LogbookEntry::LOG_TYPES.invert,
|
||||
data: { component_times_target: "logType", entry_template_target: "logType", action: "component-times#logTypeChanged" } %>
|
||||
<%= f.field :entry_type, as: :select, label: t(".entry_type"), collection: LogbookEntry::ENTRY_TYPES.invert, data: { entry_template_target: "entryType" } %>
|
||||
<%= f.field :entry_type, as: :select, label: t(".entry_type"), collection: LogbookEntry::ENTRY_TYPES.invert,
|
||||
data: { entry_template_target: "entryType", show_when_target: "source", action: "show-when#update" } %>
|
||||
<%= f.field :aircraft_hours_at_entry, as: :number, step: 0.1, label: t(".airframe_total_time"),
|
||||
data: { component_times_target: "airframe", action: "input->component-times#airframeChanged" } %>
|
||||
</div>
|
||||
@@ -57,8 +58,10 @@
|
||||
<%= f.field :signoff_certificate_number, label: t(".certificate_number"), placeholder: "e.g. 1234567", data: { signer_target: "number" } %>
|
||||
</div>
|
||||
<div class="grid gap-4 sm:grid-cols-2">
|
||||
<%= f.field :inspection_result, as: :select, label: t(".inspection_result"), include_blank: t(".not_an_inspection"),
|
||||
collection: LogbookEntry::INSPECTION_RESULTS.invert, hint: t(".for_inspection_entries_43_11") %>
|
||||
<div data-show-when-target="item" data-show-when-value="INSPECTION">
|
||||
<%= f.field :inspection_result, as: :select, label: t(".inspection_result"), include_blank: t(".not_an_inspection"),
|
||||
collection: LogbookEntry::INSPECTION_RESULTS.invert, hint: t(".for_inspection_entries_43_11") %>
|
||||
</div>
|
||||
<%= f.field :signoff_location, label: t(".location_shop") %>
|
||||
<%= f.field :document_id, as: :select, label: t(".scanned_page_document"), collection: document_options(aircraft) %>
|
||||
<%= f.field :page_number, as: :number, label: t(".page_in_document") %>
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
<%= form_with model: [aircraft, squawk], multipart: true, class: "card card-body space-y-4 max-w-2xl",
|
||||
data: (squawk.new_record? ? { controller: "offline-form", offline_form_kind_value: "squawk", offline_form_tail_value: aircraft.tail_number,
|
||||
action: "submit->offline-form#submit turbo:submit-start->offline-form#remember turbo:fetch-request-error->offline-form#networkFailed turbo:before-fetch-response->offline-form#gatewayFailed" } : {}) do |f| %>
|
||||
data: (squawk.new_record? ? { controller: "offline-form show-when", offline_form_kind_value: "squawk", offline_form_tail_value: aircraft.tail_number,
|
||||
action: "submit->offline-form#submit turbo:submit-start->offline-form#remember turbo:fetch-request-error->offline-form#networkFailed turbo:before-fetch-response->offline-form#gatewayFailed" } : { controller: "show-when" }) do |f| %>
|
||||
<% if squawk.new_record? %>
|
||||
<%= f.hidden_field :client_key, data: { offline_form_target: "key" } %>
|
||||
<div class="hidden rounded-md bg-sky-50 px-3 py-2 text-sm text-sky-900 ring-1 ring-sky-200" data-offline-form-target="notice" role="status"></div>
|
||||
<% end %>
|
||||
<%= f.errors_summary %>
|
||||
<%= f.field :priority, as: :select, collection: Squawk::PRIORITIES.invert, hint: t(".ground_aircraft_makes_the_aircraft") %>
|
||||
<%= f.field :priority, as: :select, collection: Squawk::PRIORITIES.invert, hint: t(".ground_aircraft_makes_the_aircraft"),
|
||||
data: { show_when_target: "source", action: "show-when#update" } %>
|
||||
<p class="rounded-md bg-red-50 px-3 py-2 text-sm text-red-800 ring-1 ring-red-200" role="alert" data-show-when-target="item" data-show-when-value="0" hidden>
|
||||
<%= t(".grounding_warning", tail_number: aircraft.tail_number) %>
|
||||
</p>
|
||||
<%= f.field :issue_reported, as: :textarea, label: t(".issue"), required: true, autofocus: true %>
|
||||
<%= f.field :component_id, as: :select, label: t(".component_optional"), collection: component_options(aircraft) %>
|
||||
<%= f.field :attachments, as: :file, multiple: true, label: squawk.attachments.attached? ? t(".add_photos_files") : t(".photos_files"),
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
<section class="card">
|
||||
<div class="card-header">
|
||||
<h2 class="card-title"><%= t(".open_squawks") %></h2>
|
||||
<%= link_to t(".report_squawk"), new_aircraft_squawk_path(@aircraft), class: "btn-primary" %>
|
||||
</div>
|
||||
<% if @active.any? %><%= render "squawks/table", squawks: @active, aircraft: @aircraft %><% else %><%= empty_state t(".no_open_squawks") %><% end %>
|
||||
</section>
|
||||
|
||||
+30
-4
@@ -789,6 +789,7 @@ en:
|
||||
flight_log_deleted: Flight log deleted
|
||||
track_unreadable: 'Couldn''t read track: %{message}'
|
||||
engine_data_unreadable: 'Couldn''t read engine data: %{message}'
|
||||
next_leg: The next leg starts where it ended.
|
||||
inspection_records:
|
||||
inspection_recorded: Inspection recorded.
|
||||
inspection_record_updated: Inspection record updated.
|
||||
@@ -1690,6 +1691,25 @@ en:
|
||||
recent_activity: Recent Activity
|
||||
all: All →
|
||||
public: "· public"
|
||||
setup:
|
||||
title: Set up %{tail_number}
|
||||
progress: "%{done} of %{total} done"
|
||||
hide: Hide
|
||||
components:
|
||||
title: Add the components you track
|
||||
why: 'The engine and propeller, and parts with limits: oil, filters, the ELT battery, magnetos. Flight hours are added to each one.'
|
||||
inspections:
|
||||
title: Add the standard inspections
|
||||
why: 'Annual, 100-hour, transponder, pitot-static, ELT: pick the ones that apply, then record when each was last done.'
|
||||
ads:
|
||||
title: Import the ADs from FAA DRS
|
||||
why: Export the ADs for the aircraft, engine and propeller from drs.faa.gov and upload the file.
|
||||
documents:
|
||||
title: Upload the registration and airworthiness certificate
|
||||
why: With the registration's expiry date, you're reminded before it lapses.
|
||||
weight_balance:
|
||||
title: Enter the weight and balance
|
||||
why: The empty weight and CG from the latest W&B, for the loading calculator.
|
||||
aircraft_imports:
|
||||
new:
|
||||
import_aircraft: Import Aircraft
|
||||
@@ -1920,7 +1940,6 @@ en:
|
||||
hours_since_oh_service: Hours since OH / service
|
||||
overhaul_type: Overhaul type
|
||||
for_engines_and_propellers_printed: 'For engines and propellers: printed in logbook entries as SMOH, SFOH or SNEW.'
|
||||
limits: Limits
|
||||
replace_every_hrs: Replace every (hrs)
|
||||
replace_every: Replace every
|
||||
replacement_counts_from: Replacement counts from
|
||||
@@ -1944,6 +1963,10 @@ en:
|
||||
last_service: Last service
|
||||
none: "— None —"
|
||||
save: Save
|
||||
replacement_group: Replacement and expiry
|
||||
replacement_group_hint: "· oil, filters, ELT battery, life-limited parts"
|
||||
tbo_group: Overhaul and TBO
|
||||
tbo_group_hint: "· engines and propellers"
|
||||
index:
|
||||
components: "%{tail_number} Components"
|
||||
components_2: Components
|
||||
@@ -1960,7 +1983,7 @@ en:
|
||||
tbo_h_html: 'TBO: %{tbo_hours} h%{on_condition}<br>'
|
||||
expires_html: 'Expires: %{expires_on}'
|
||||
edit: Edit
|
||||
service: Service
|
||||
service: Record service
|
||||
since_installed: " since installed"
|
||||
on_condition: " (on condition)"
|
||||
hide_disposed: Hide disposed
|
||||
@@ -2296,6 +2319,8 @@ en:
|
||||
cgr_30p_cgr_30c_flight: CGR-30P / CGR-30C flight recording (.csv).
|
||||
saving_adds_the_tach_time: Saving adds the tach time to the aircraft and all in-service components, and records any oil/fuel added.
|
||||
cancel: Cancel
|
||||
log_and_next_leg: Save and log next leg
|
||||
log_and_next_leg_title: Saves this flight and opens the form for the next one, starting where it ended
|
||||
show:
|
||||
flight_on_html: Flight on %{date}
|
||||
delete_this_flight_log_aircraft: Delete this flight log? Aircraft and component hours will NOT be rolled back.
|
||||
@@ -3235,10 +3260,10 @@ en:
|
||||
photos_files: Photos / files
|
||||
report_squawk: Report Squawk
|
||||
save: Save
|
||||
grounding_warning: 'This grounds %{tail_number}: it shows Grounded until the squawk is resolved or deferred, and its owners and pilots who turned on notifications are told.'
|
||||
index:
|
||||
squawks: "%{tail_number} Squawks"
|
||||
open_squawks: Open Squawks
|
||||
report_squawk: "+ Report Squawk"
|
||||
no_open_squawks: No open squawks.
|
||||
resolved: Resolved
|
||||
priority: Priority
|
||||
@@ -3373,8 +3398,8 @@ en:
|
||||
notes: Notes
|
||||
activity: Activity
|
||||
none: "— None —"
|
||||
text: "%{date} – %{truncate}"
|
||||
w_b: W&B
|
||||
entry_option: "%{date} – %{text}"
|
||||
application:
|
||||
more: More
|
||||
are_you_sure: Are you sure?
|
||||
@@ -3635,6 +3660,7 @@ en:
|
||||
that_certificate_isn_t_yours: That certificate isn't yours
|
||||
this_entry_can_t_be: 'This entry can''t be signed: %{to_sentence}'
|
||||
text: "%{signer_name}, %{certificate_label} %{certificate_number}"
|
||||
signed_event: Logbook entry signed electronically (%{date})
|
||||
air_trail:
|
||||
can_t_reach_airtrail_at: 'Can''t reach AirTrail at %{host}: %{message}'
|
||||
airtrail_username_must_be_3: AirTrail username must be 3–20 letters, numbers, “.”, “_” or “-”
|
||||
|
||||
@@ -44,7 +44,7 @@ class ElectronicSignaturesTest < ActionDispatch::IntegrationTest
|
||||
assert_equal [ @entry.content_digest, :valid ], [ sig.content_digest, sig.status ]
|
||||
assert_equal "Replaced left landing light lamp P/N 4509.", JSON.parse(sig.content_snapshot)["text"]
|
||||
assert_equal "You signed a logbook entry for N12345", ActionMailer::Base.deliveries.last.subject
|
||||
assert_equal "Logbook entry signed electronically (2026-10-01)", @a.events.last.event_name
|
||||
assert_equal "Logbook entry signed electronically (Oct 1, 2026)", @a.events.last.event_name
|
||||
|
||||
get aircraft_logbook_entry_path(@a, @entry)
|
||||
assert_includes response.body, "Certified by Sam Mechanic, A&P 7654321"
|
||||
|
||||
@@ -61,7 +61,7 @@ class LogbookEntryPartsTest < ActionDispatch::IntegrationTest
|
||||
# dated to the entry; the 10 hours flown since the entry carry over
|
||||
assert_equal [ Date.new(2026, 8, 20), 10.0, 120.5 ], [ @filter.overhaul_date, @filter.hours_since_overhaul.to_f, @filter.hours_in_service.to_f ]
|
||||
assert_equal [ 10.0, 10.0, Date.new(2026, 8, 20) ], [ oil.hours_since_overhaul.to_f, oil.hours_in_service.to_f, oil.date_in_service ]
|
||||
assert @a.events.exists?(event_name: "Replaced: #{oil} (logbook entry 2026-08-20)")
|
||||
assert @a.events.exists?(event_name: "Replaced: #{oil} (logbook entry Aug 20, 2026)")
|
||||
|
||||
entry = @a.logbook_entries.last # editing doesn't offer it again (it would apply twice)
|
||||
get edit_aircraft_logbook_entry_path(@a, entry)
|
||||
@@ -84,7 +84,7 @@ class LogbookEntryPartsTest < ActionDispatch::IntegrationTest
|
||||
entry = @a.logbook_entries.sole
|
||||
record = @a.inspection_records.sole
|
||||
assert_equal [ oil_change, entry, Date.new(2026, 8, 20), 4200.3 ], [ record.inspection_type, record.logbook_entry, record.date, record.aircraft_hours.to_f ]
|
||||
assert @a.events.exists?(event_name: "Inspection completed: Oil Change (logbook entry 2026-08-20)")
|
||||
assert @a.events.exists?(event_name: "Inspection completed: Oil Change (logbook entry Aug 20, 2026)")
|
||||
|
||||
get edit_aircraft_logbook_entry_path(@a, entry) # not offered again on edit (it would record twice)
|
||||
assert_select "input[name='logbook_entry[inspection_type_ids][]']", 0
|
||||
|
||||
@@ -26,7 +26,7 @@ class OilAnalysisFlowTest < ActionDispatch::IntegrationTest
|
||||
latest = @aircraft.oil_analyses.recent_first.first
|
||||
assert_redirected_to aircraft_oil_analysis_path(@aircraft, latest)
|
||||
assert latest.report.attached?
|
||||
assert_equal [ "Oil analysis added (sampled 2026-08-01)" ], @aircraft.events.where(category: "oil_analysis").limit(1).pluck(:event_name)
|
||||
assert_equal [ "Oil analysis added (sampled Aug 1, 2026)" ], @aircraft.events.where(category: "oil_analysis").limit(1).pluck(:event_name)
|
||||
|
||||
get aircraft_oil_analyses_path(@aircraft)
|
||||
assert_response :success
|
||||
|
||||
@@ -68,7 +68,7 @@ class PwaFeaturesTest < ActionDispatch::IntegrationTest
|
||||
test "squawks can be reported offline and are received once" do
|
||||
sign_in @pilot
|
||||
get new_aircraft_squawk_path(@a)
|
||||
assert_select "form[data-controller=offline-form][data-offline-form-kind-value=squawk][data-offline-form-tail-value=N12345]"
|
||||
assert_select "form[data-controller~=offline-form][data-offline-form-kind-value=squawk][data-offline-form-tail-value=N12345]"
|
||||
assert_select "input[type=hidden][name='squawk[client_key]']"
|
||||
|
||||
params = { squawk: { priority: 1, issue_reported: "Left landing light inop", client_key: "sq-1" } }
|
||||
@@ -78,7 +78,7 @@ class PwaFeaturesTest < ActionDispatch::IntegrationTest
|
||||
get edit_aircraft_squawk_path(@a, @a.squawks.last) # pilots can't edit; owners' edit form isn't queued
|
||||
sign_in @owner
|
||||
get edit_aircraft_squawk_path(@a, @a.squawks.last)
|
||||
assert_select "form[data-controller=offline-form]", count: 0
|
||||
assert_select "form[data-controller~=offline-form]", count: 0
|
||||
end
|
||||
|
||||
test "home-screen shortcuts open the form for your only aircraft, or let you choose" do
|
||||
|
||||
@@ -51,7 +51,7 @@ class RecordsIntegrityTest < ActionDispatch::IntegrationTest
|
||||
RecordVersion.where(id: victim.id).delete_all
|
||||
check = RecordsIntegrity.check!
|
||||
refute check.ok
|
||||
assert(check.problems.any? { _1.include?("the 2026-10-01 logbook entry (signed by Sam Mechanic) changed after it was signed") })
|
||||
assert(check.problems.any? { _1.include?("the Oct 1, 2026 logbook entry (signed by Sam Mechanic) changed after it was signed") })
|
||||
assert(check.problems.any? { _1.include?("doesn't follow the one before it") || _1.include?("missing") } || RecordVersion.where(aircraft_id: other.id).count.zero?)
|
||||
|
||||
RecordVersion.where(aircraft_id: @a.id).last.then { RecordVersion.where(id: _1.id).update_all(payload: _1.payload.sub("Changed oil", "Changed gas")) }
|
||||
|
||||
@@ -36,7 +36,7 @@ class UserCertificatesTest < ActionDispatch::IntegrationTest
|
||||
@owner.certificates.create!(kind: "IA", number: "7654321", expires_on: 1.day.ago.to_date) # expired: not offered
|
||||
sign_in @owner
|
||||
get new_aircraft_logbook_entry_path(@a)
|
||||
assert_select "form[data-controller='entry-template signer component-times']"
|
||||
assert_select "form[data-controller~=signer]"
|
||||
assert_select "select[data-signer-target=choice] option[data-kind=AP][data-number='7654321'][data-name='Sam Mechanic']"
|
||||
assert_select "select[data-signer-target=choice] option[data-kind=IA]", 0
|
||||
assert_select "input[name='logbook_entry[signoff_person]'][data-signer-target=name]"
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
require "test_helper"
|
||||
|
||||
# Small workflow refinements: readable dates in pickers and the activity log,
|
||||
# fields that appear when they apply, the next-leg button, grouped component
|
||||
# limits and the setup checklist for a new aircraft.
|
||||
class WorkflowPolishTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
@owner = create_user("owner@example.com")
|
||||
@pilot = create_user("pilot@example.com")
|
||||
@a = create_aircraft(owner: @owner, pilot: @pilot, tail_number: "N12345", tach_time: 1000)
|
||||
end
|
||||
|
||||
test "logbook entry pickers and activity show dates the app's way" do
|
||||
entry = @a.logbook_entries.create!(date: Date.new(2025, 12, 14), entry_type: "MAINTENANCE", log_type: "AC", text: "Oil changed")
|
||||
sign_in @owner
|
||||
get new_aircraft_inspection_record_path(@a)
|
||||
assert_select "select[name='inspection_record[logbook_entry_id]'] option[value='#{entry.id}']", text: /\ADec 14, 2025 – Oil changed/
|
||||
end
|
||||
|
||||
test "the inspection result appears only for inspection entries" do
|
||||
sign_in @owner
|
||||
get new_aircraft_logbook_entry_path(@a)
|
||||
assert_select "form[data-controller~=show-when] select[name='logbook_entry[entry_type]'][data-show-when-target=source]"
|
||||
assert_select "[data-show-when-target=item][data-show-when-value=INSPECTION] select[name='logbook_entry[inspection_result]']"
|
||||
end
|
||||
|
||||
test "choosing Ground Aircraft warns what it does" do
|
||||
sign_in @pilot
|
||||
get new_aircraft_squawk_path(@a)
|
||||
assert_select "[data-show-when-target=item][data-show-when-value='0'][hidden]", /This grounds N12345/
|
||||
get aircraft_squawks_path(@a)
|
||||
assert_select "main a[href='#{new_aircraft_squawk_path(@a)}']", 1 # just the header's Report Squawk
|
||||
end
|
||||
|
||||
test "Save and log next leg comes back to the form, starting where the flight ended" do
|
||||
sign_in @pilot
|
||||
post aircraft_flight_logs_path(@a), params: { next_leg: "1", flight_log: { date: "2026-11-08", tach_out: 1000, tach_in: 1001.2, departure_location: "KOQU", destination_location: "KBID" } }
|
||||
assert_redirected_to new_aircraft_flight_log_path(@a, date: "2026-11-08")
|
||||
follow_redirect!
|
||||
assert_match "The next leg starts where it ended.", flash[:notice]
|
||||
assert_select "input[name='flight_log[date]'][value='2026-11-08']"
|
||||
assert_select "input[name='flight_log[tach_out]'][value='1001.2']"
|
||||
assert_select "input[name='flight_log[departure_location]'][value=KBID]"
|
||||
end
|
||||
|
||||
test "a new document is named from its file, and the setup checklist can preset its type" do
|
||||
sign_in @owner
|
||||
get new_aircraft_document_path(@a, doc_type: "REGISTRATION")
|
||||
assert_select "form[data-controller=name-from-file] input[name='document[name]'][data-name-from-file-target=name]"
|
||||
assert_select "input[type=file][data-action='name-from-file#fill']"
|
||||
assert_select "select[name='document[doc_type]'] option[selected][value=REGISTRATION]"
|
||||
end
|
||||
|
||||
test "component limits are grouped and open when in use" do
|
||||
sign_in @owner
|
||||
get new_aircraft_component_path(@a)
|
||||
assert_select "form details:not([open])", 2 # replacement and expiry; overhaul and TBO
|
||||
engine = @a.components.create!(component_type: ComponentType.find_or_create_by!(name: "Engine"), manufacturer: "Continental", model: "O-200", date_in_service: Date.current, status: "IN-USE", tbo_hours: 1800)
|
||||
get edit_aircraft_component_path(@a, engine)
|
||||
assert_select "details[open] input[name='component[tbo_hours]']"
|
||||
get aircraft_components_path(@a)
|
||||
assert_select "a", text: "Record service"
|
||||
end
|
||||
|
||||
test "owners see what's left to set up a new aircraft; pilots don't" do
|
||||
sign_in @owner
|
||||
get aircraft_path(@a)
|
||||
assert_select "[data-controller=dismiss] li", 5
|
||||
assert_select "[data-controller=dismiss]", /0 of 5 done/
|
||||
@a.components.create!(component_type: ComponentType.find_or_create_by!(name: "Engine"), manufacturer: "Continental", model: "O-200", date_in_service: Date.current, status: "IN-USE")
|
||||
get aircraft_path(@a)
|
||||
assert_select "[data-controller=dismiss]", /1 of 5 done/
|
||||
sign_in @pilot
|
||||
get aircraft_path(@a)
|
||||
assert_select "[data-controller=dismiss]", 0
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user