Editable logbook templates; component times follow the airframe time

- Templates move to the database (Admin -> Logbook templates: add, edit,
  delete, restore the built-in ones). The built-in preventive maintenance
  set is added once on first use; deletions stick. A template can set the
  entry type, logbook (picking the matching component) and certificate
- Template list shows "Name — Part 43 App. A (c)(6), (c)(23)" instead of
  the doubled parentheses
- Component total time and time since overhaul are worked out from the
  entry's airframe total time (current times shifted by the difference);
  blank when the entry predates the overhaul; typing them stops the
  automatic updates

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rickyandClaude Opus 5.5 committed 2026-11-07 11:40:23 -05:00
1 parent a51f78ebf3
commit 72e1d7760f
22 files changed
+366 -74

No files matched your search

@@ -0,0 +1,17 @@
<%= form_with model: [ :admin, template ], class: "card card-body max-w-3xl space-y-4" do |f| %>
<%= f.errors_summary %>
<div class="grid gap-4 sm:grid-cols-2">
<%= f.field :name, required: true, placeholder: "Oil and filter change" %>
<%= f.field :reference, placeholder: "Part 43 App. A (c)(6)", hint: "Shown next to the name, e.g. the regulation or manual paragraph." %>
</div>
<%= f.field :text, as: :textarea, rows: 5, required: true, hint: "The entry text. Use __ for blanks to fill in (quantities, part numbers…)." %>
<div class="grid gap-4 sm:grid-cols-4">
<%= f.field :entry_type, as: :select, label: "Entry type", collection: LogbookEntry::ENTRY_TYPES.invert %>
<%= f.field :log_type, as: :select, label: "Logbook", include_blank: "— Leave as is —", collection: LogbookEntry::LOG_TYPES.invert %>
<%= f.field :certificate_type, as: :select, label: "Kind of certificate", include_blank: "— Leave as is —", collection: LogbookEntry::CERTIFICATE_TYPES.invert,
hint: "Only filled in when none is chosen yet." %>
<%= f.field :position, as: :number, label: "Order" %>
</div>
<div class="flex gap-2"><%= f.submit "Save Template" %><%= link_to "Cancel", admin_logbook_templates_path, class: "btn-secondary" %></div>
<% end %>
<% if template.persisted? %><div class="mt-4"><%= delete_button "Delete template", admin_logbook_template_path(template) %></div><% end %>