mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 23:50:36 -05:00
Flights can be corrected after they're saved
- Edit on a flight: owners can correct any flight; a pilot, the flights they logged (the same rule as its engine data). - Date, airports, route, notes, oil and fuel (its oil and fuel records follow) and the attached files can always be changed. - The meter readings only on the latest flight, while its tach in is still the aircraft's tach: the aircraft and installed components move by the difference, and with both readings the duration is worked out from them. On earlier flights they're locked (later flights started from them), pointing to Update Hours; the server ignores them too. - Each correction is in the activity log with what changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
34879e7310
commit
d2cd60c6a7
11 files changed
+274
-38
No files matched your search
@@ -0,0 +1,38 @@
|
||||
<%# The flight's fields, for Log Flight and for correcting one. Its meter
|
||||
readings are locked (meters_locked) on all but the latest flight. %>
|
||||
<% meters_locked = local_assigns.fetch(:meters_locked, false) %>
|
||||
<div class="grid gap-4 sm:grid-cols-3">
|
||||
<%= f.field :date, as: :date, required: true %>
|
||||
<%= render "shared/airport_field", f: f, attribute: :departure_location, label: t("flight_logs.new.from"), aircraft: @aircraft, placeholder: t("flight_logs.new.koqu") %>
|
||||
<%= render "shared/airport_field", f: f, attribute: :destination_location, label: t("flight_logs.new.to"), aircraft: @aircraft, placeholder: t("flight_logs.new.code_or_name") %>
|
||||
</div>
|
||||
<% if meters_locked %>
|
||||
<p class="hint"><%= t("flight_logs.fields.meters_locked_html", link: link_to(t("flight_logs.fields.update_hours"), aircraft_path(@aircraft), class: "link")) %></p>
|
||||
<% end %>
|
||||
<%= tag.fieldset class: "grid gap-4 sm:grid-cols-3", disabled: meters_locked do %>
|
||||
<legend class="mb-2 text-sm font-semibold"><%= t("flight_logs.new.tach_required") %></legend>
|
||||
<%= f.field :tach_out, as: :number, step: 0.1, label: t("flight_logs.new.tach_out") %>
|
||||
<%= f.field :tach_in, as: :number, step: 0.1, label: t("flight_logs.new.tach_in") %>
|
||||
<%= f.field :tach_time, as: :number, step: 0.1, label: t("flight_logs.new.or_duration"), hint: t("flight_logs.new.calculated_from_out_in_if") %>
|
||||
<% end %>
|
||||
<%= tag.fieldset class: "grid gap-4 sm:grid-cols-3", disabled: meters_locked do %>
|
||||
<legend class="mb-2 text-sm font-semibold"><%= t("flight_logs.new.hobbs_optional") %></legend>
|
||||
<%= f.field :hobbs_out, as: :number, step: 0.1, label: t("flight_logs.new.hobbs_out") %>
|
||||
<%= f.field :hobbs_in, as: :number, step: 0.1, label: t("flight_logs.new.hobbs_in") %>
|
||||
<%= f.field :hobbs_time, as: :number, step: 0.1, label: t("flight_logs.new.or_duration") %>
|
||||
<% end %>
|
||||
<fieldset class="grid gap-4 sm:grid-cols-3">
|
||||
<legend class="mb-2 text-sm font-semibold"><%= t("flight_logs.new.oil_fuel_added") %></legend>
|
||||
<%= f.field :oil_added, as: :number, step: 0.25, label: t("flight_logs.new.oil_added_qt") %>
|
||||
<%= f.field :oil_level_after, as: :number, step: 0.25, label: t("flight_logs.new.oil_level_after_qt") %>
|
||||
<%= f.field :oil_added_type, label: t("flight_logs.new.oil_type"), placeholder: t("flight_logs.new.aeroshell_w100") %>
|
||||
<%= f.field :fuel_added, as: :number, step: 0.1, label: t("flight_logs.new.fuel_added_gal") %>
|
||||
<%= f.field :fuel_level_after, as: :number, step: 0.1, label: t("flight_logs.new.fuel_level_after_gal") %>
|
||||
<%= f.field :fuel_added_type, label: t("flight_logs.new.fuel_type"), placeholder: t("flight_logs.new.n100ll") %>
|
||||
</fieldset>
|
||||
<%= f.field :route, as: :textarea, rows: 2 %>
|
||||
<%= f.field :notes, as: :textarea, rows: 2 %>
|
||||
<div class="grid gap-4 sm:grid-cols-2">
|
||||
<%= f.field :track_log, as: :file, label: t("flight_logs.new.track_log_gpx_kml_csv") %>
|
||||
<%= f.field :engine_data, as: :file, label: t("flight_logs.new.engine_monitor_data"), hint: t("flight_logs.new.cgr_30p_cgr_30c_flight"), accept: ".csv,text/csv" %>
|
||||
</div>
|
||||
@@ -0,0 +1,12 @@
|
||||
<% content_for :title, t(".correct_flight") %>
|
||||
<%= render "shared/aircraft_header", aircraft: @aircraft %>
|
||||
<%= form_with model: [@aircraft, @flight_log], class: "card card-body space-y-5 max-w-3xl" do |f| %>
|
||||
<h2 class="card-title"><%= t(".correct_the_flight_on", date: fmt_date(@flight_log.date_was)) %></h2>
|
||||
<%= f.errors_summary %>
|
||||
<%= render "flight_logs/fields", f: f, meters_locked: !@meters_editable %>
|
||||
<% if @meters_editable %><p class="hint"><%= t(".changing_the_readings") %></p><% end %>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<%= f.submit t(".save"), data: { turbo_submits_with: t("flight_logs.new.sending") } %>
|
||||
<%= link_to t(".cancel"), aircraft_flight_log_path(@aircraft, @flight_log), class: "btn-secondary" %>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -6,38 +6,7 @@
|
||||
<%= 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>
|
||||
<%= f.errors_summary %>
|
||||
<div class="grid gap-4 sm:grid-cols-3">
|
||||
<%= f.field :date, as: :date, required: true %>
|
||||
<%= render "shared/airport_field", f: f, attribute: :departure_location, label: t(".from"), aircraft: @aircraft, placeholder: t(".koqu") %>
|
||||
<%= render "shared/airport_field", f: f, attribute: :destination_location, label: t(".to"), aircraft: @aircraft, placeholder: t(".code_or_name") %>
|
||||
</div>
|
||||
<fieldset class="grid gap-4 sm:grid-cols-3">
|
||||
<legend class="mb-2 text-sm font-semibold"><%= t(".tach_required") %></legend>
|
||||
<%= f.field :tach_out, as: :number, step: 0.1, label: t(".tach_out") %>
|
||||
<%= f.field :tach_in, as: :number, step: 0.1, label: t(".tach_in") %>
|
||||
<%= f.field :tach_time, as: :number, step: 0.1, label: t(".or_duration"), hint: t(".calculated_from_out_in_if") %>
|
||||
</fieldset>
|
||||
<fieldset class="grid gap-4 sm:grid-cols-3">
|
||||
<legend class="mb-2 text-sm font-semibold"><%= t(".hobbs_optional") %></legend>
|
||||
<%= f.field :hobbs_out, as: :number, step: 0.1, label: t(".hobbs_out") %>
|
||||
<%= f.field :hobbs_in, as: :number, step: 0.1, label: t(".hobbs_in") %>
|
||||
<%= f.field :hobbs_time, as: :number, step: 0.1, label: t(".or_duration") %>
|
||||
</fieldset>
|
||||
<fieldset class="grid gap-4 sm:grid-cols-3">
|
||||
<legend class="mb-2 text-sm font-semibold"><%= t(".oil_fuel_added") %></legend>
|
||||
<%= f.field :oil_added, as: :number, step: 0.25, label: t(".oil_added_qt") %>
|
||||
<%= f.field :oil_level_after, as: :number, step: 0.25, label: t(".oil_level_after_qt") %>
|
||||
<%= f.field :oil_added_type, label: t(".oil_type"), placeholder: t(".aeroshell_w100") %>
|
||||
<%= f.field :fuel_added, as: :number, step: 0.1, label: t(".fuel_added_gal") %>
|
||||
<%= f.field :fuel_level_after, as: :number, step: 0.1, label: t(".fuel_level_after_gal") %>
|
||||
<%= f.field :fuel_added_type, label: t(".fuel_type"), placeholder: t(".n100ll") %>
|
||||
</fieldset>
|
||||
<%= f.field :route, as: :textarea, rows: 2 %>
|
||||
<%= f.field :notes, as: :textarea, rows: 2 %>
|
||||
<div class="grid gap-4 sm:grid-cols-2">
|
||||
<%= f.field :track_log, as: :file, label: t(".track_log_gpx_kml_csv") %>
|
||||
<%= f.field :engine_data, as: :file, label: t(".engine_monitor_data"), hint: t(".cgr_30p_cgr_30c_flight"), accept: ".csv,text/csv" %>
|
||||
</div>
|
||||
<%= render "flight_logs/fields", f: f %>
|
||||
<p class="hint"><%= t(".saving_adds_the_tach_time") %></p>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<%= f.submit t(".log_flight"), data: { turbo_submits_with: t(".sending") } %>
|
||||
|
||||
@@ -2,7 +2,10 @@
|
||||
<div class="space-y-6">
|
||||
<section class="card max-w-3xl">
|
||||
<div class="card-header"><h2 class="card-title"><%= t(".flight_on_html", date: (fmt_date(@flight_log.date))) %></h2>
|
||||
<% if owner? %><%= delete_button t(".delete"), aircraft_flight_log_path(@aircraft, @flight_log), confirm: t(".delete_this_flight_log_aircraft") %><% end %></div>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<% if can_edit_flight?(@flight_log) %><%= link_to t(".edit"), edit_aircraft_flight_log_path(@aircraft, @flight_log), class: "btn-secondary btn-sm" %><% end %>
|
||||
<% if owner? %><%= delete_button t(".delete"), aircraft_flight_log_path(@aircraft, @flight_log), confirm: t(".delete_this_flight_log_aircraft") %><% end %>
|
||||
</div></div>
|
||||
<%# One item per row on a phone (label, then value); two columns on wider screens. %>
|
||||
<dl class="card-body grid gap-x-8 gap-y-3 text-sm sm:grid-cols-2">
|
||||
<div class="detail-row"><dt><%= t(".tach") %></dt><dd><%= hours(@flight_log.tach_time) %> <span class="text-xs text-slate-500"><%= "(#{@flight_log.tach_out} → #{@flight_log.tach_in})" if @flight_log.tach_out && @flight_log.tach_in %></span></dd></div>
|
||||
|
||||
Reference in new issue
Block a user