mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 23:50:36 -05:00
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:
1 parent
a51f78ebf3
commit
72e1d7760f
22 files changed
+366
-74
No files matched your search
@@ -1,23 +1,26 @@
|
||||
<%= form_with model: [aircraft, entry], class: "card card-body space-y-4 max-w-3xl", data: { controller: "entry-template signer component-times" } do |f| %>
|
||||
<%= 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| %>
|
||||
<%= f.errors_summary %>
|
||||
<% if entry.new_record? %>
|
||||
<% templates = entry.new_record? ? LogbookTemplate.ordered.to_a : [] %>
|
||||
<% if templates.any? %>
|
||||
<div>
|
||||
<%= label_tag :template, "Preventive maintenance template", class: "label" %>
|
||||
<%= label_tag :template, "Template", class: "label" %>
|
||||
<select id="template" class="input" data-entry-template-target="template" data-action="entry-template#apply">
|
||||
<option value="">— Write it yourself —</option>
|
||||
<% PreventiveMaintenance::ITEMS.each do |item| %>
|
||||
<option value="<%= item.key %>" data-text="<%= PreventiveMaintenance.text_for(item) %>"><%= item.label %> (<%= item.paragraphs.join(", ") %>)</option>
|
||||
<% templates.each do |t| %>
|
||||
<option value="<%= t.id %>" data-text="<%= t.text %>" data-entry-type="<%= t.entry_type %>" data-log-type="<%= t.log_type %>"
|
||||
data-certificate="<%= t.certificate_type %>"><%= t.label %></option>
|
||||
<% end %>
|
||||
</select>
|
||||
<p class="hint">For a pilot doing preventive maintenance on an aircraft they own or operate (14 CFR 43.3(g)). Fill in the blanks (__) and add your name and pilot certificate number. The item list is paraphrased from Part 43 Appendix A(c); the rule sets each item's limits.</p>
|
||||
<p class="hint">Fill in the blanks (__). The built-in ones are for a pilot doing preventive maintenance on an aircraft they own or operate (14 CFR 43.3(g)); their wording is paraphrased from Part 43 Appendix A(c), which sets each item's limits.<% if current_user.admin? %> <%= link_to "Edit templates", admin_logbook_templates_path, class: "link" %><% end %></p>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="grid gap-4 sm:grid-cols-4">
|
||||
<%= f.field :date, as: :date %>
|
||||
<%= f.field :log_type, as: :select, label: "Logbook", collection: LogbookEntry::LOG_TYPES.invert,
|
||||
data: { component_times_target: "logType", action: "component-times#logTypeChanged" } %>
|
||||
data: { component_times_target: "logType", entry_template_target: "logType", action: "component-times#logTypeChanged" } %>
|
||||
<%= f.field :entry_type, as: :select, label: "Entry type", collection: LogbookEntry::ENTRY_TYPES.invert, data: { entry_template_target: "entryType" } %>
|
||||
<%= f.field :aircraft_hours_at_entry, as: :number, step: 0.1, label: "Airframe total time" %>
|
||||
<%= f.field :aircraft_hours_at_entry, as: :number, step: 0.1, label: "Airframe total time",
|
||||
data: { component_times_target: "airframe", action: "input->component-times#airframeChanged" } %>
|
||||
</div>
|
||||
<%= render "logbook_entries/component_fields", f: f, aircraft: aircraft %>
|
||||
<%= f.field :text, as: :textarea, label: "Entry text", rows: 8, data: { entry_template_target: "text" } %>
|
||||
|
||||
Reference in new issue
Block a user