Fill the vehicle into issue subjects (<VEHICLE>)

An issue subject containing the placeholder (e.g. an issue template's "Frame Evaluation // <VEHICLE>") gets
the issue's vehicle when it's saved with one: on creation, or the first save after a vehicle is added
(journaled like any subject change). The placeholder is a plugin setting, "Vehicle in subjects": <VEHICLE>
by default (also for settings saved before it existed), blank turns it off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rickyandClaude Opus 5.5 committed 2026-11-02 18:23:07 -05:00
1 parent ff6522ad77
commit 2074ec65b9
6 files changed
+32 -1

No files matched your search

+12
View File
@@ -35,6 +35,18 @@ class Vehicle < ApplicationRecord
issues.includes(:invoices).flat_map(&:invoices).uniq.compact
end
# Text in an issue's subject replaced by its vehicle (e.g. a template's "Frame Evaluation // <VEHICLE>"), or nil
# when turned off in the plugin settings. Settings saved before this option existed get the default.
DEFAULT_SUBJECT_PLACEHOLDER = '<VEHICLE>'
def self.subject_placeholder
settings = Setting.plugin_redmine_qbo_vehicles || {}
key = ['subject_placeholder', :subject_placeholder].detect { |k| settings.key?(k) }
return DEFAULT_SUBJECT_PLACEHOLDER unless key
settings[key].to_s.strip.presence
end
# The issue custom field holding mileage: the one chosen in the plugin settings, else one named "Mileage"
def self.mileage_custom_field
settings = Setting.plugin_redmine_qbo_vehicles || {}
@@ -6,4 +6,9 @@
include_blank: true, id: 'settings_mileage_custom_field_id' %>
<em class="info"><%= l(:text_mileage_custom_field_info) %></em>
</p>
<p>
<label for="settings_subject_placeholder"><%= l(:label_subject_vehicle_placeholder) %></label>
<%= text_field_tag 'settings[subject_placeholder]', Vehicle.subject_placeholder, id: 'settings_subject_placeholder', size: 20 %>
<em class="info"><%= l(:text_subject_vehicle_placeholder_info) %></em>
</p>
</div>