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:
rickyandClaude Opus 5.5 committed 2026-11-14 07:43:03 -05:00
1 parent 3452a35896
commit 03b9ad65cb
34 files changed
+303 -77

No files matched your search

+1
View File
@@ -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
+13 -2
View File
@@ -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
+3 -3
View File
@@ -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
+1 -1
View File
@@ -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