diff --git a/app/models/component.rb b/app/models/component.rb
index b4b52db..32dbcb1 100644
--- a/app/models/component.rb
+++ b/app/models/component.rb
@@ -49,6 +49,9 @@ class Component < ApplicationRecord
def engine? = component_type&.name.to_s.match?(/engine/i)
def propeller? = component_type&.name.to_s.match?(/propell?er|\bprop\b/i)
+ # "On condition" means TBO isn't a limit, so it's never also a hard limit.
+ before_validation { self.tbo_critical = false if on_condition? }
+
def hours_to_tbo
tbo_hours - hours_since_overhaul if tbo_hours
end
diff --git a/app/services/records_package.rb b/app/services/records_package.rb
index 7e0cb9d..4052abb 100644
--- a/app/services/records_package.rb
+++ b/app/services/records_package.rb
@@ -95,16 +95,17 @@ class RecordsPackage
# The status report as one self-contained HTML file (styles inlined).
def status_report_html
- inline_styles(ApplicationController.render("maintenance_reports/show", layout: "report", assigns: { report: MaintenanceReport.new(@aircraft) }))
+ inline_styles(ApplicationController.render("maintenance_reports/show", layout: "report", assigns: { report: MaintenanceReport.new(@aircraft), standalone: true }))
end
def standalone_html(body, title)
- inline_styles(ApplicationController.render(html: body.html_safe, layout: "report", assigns: {}).sub(%r{
.*?}m, "#{ERB::Util.h(title)}"))
+ inline_styles(ApplicationController.render(html: body.html_safe, layout: "report", assigns: { standalone: true }).sub(%r{.*?}m) { "#{ERB::Util.h(title)}" })
end
def inline_styles(html)
css = %w[tailwind.css application.css].filter_map { Rails.application.assets.load_path.find(_1)&.content }.join("\n")
- html.gsub(%r{]*>\s*}, "").sub("", "")
+ # Block forms: a replacement string would treat "\\&" etc. in the CSS as back-references.
+ html.gsub(%r{]*>\s*}) { "" }.sub("") { "" }
.gsub(%r{}m, "").gsub(%r{]*>\s*}, "")
end
end
diff --git a/app/views/components/_form.html.erb b/app/views/components/_form.html.erb
index e3de65b..d77b29b 100644
--- a/app/views/components/_form.html.erb
+++ b/app/views/components/_form.html.erb
@@ -37,7 +37,8 @@
<%= f.field :tbo_critical, as: :checkbox, label: "Treat TBO as a hard limit",
hint: "Under Part 91, TBO is usually the manufacturer's recommendation, unless an AD or the Airworthiness Limitations make it mandatory." %>
- <%= f.field :on_condition, as: :checkbox, label: "On condition (Part 91)" %>
+ <%= f.field :on_condition, as: :checkbox, label: "On condition (Part 91)",
+ hint: "Run past TBO based on condition: TBO is shown for reference, never as a limit (this overrides the hard limit)." %>