Add support for registering custom fields in Subtask Field Copier

This commit is contained in:
ricky committed 2026-08-26 21:18:29 -04:00
1 parent fbd394bbc9
commit 7772526c8d
3 files changed
+33 -11

No files matched your search

+3
View File
@@ -10,6 +10,9 @@
module SubtaskFieldCopier
mattr_accessor :registered_fields
self.registered_fields = []
def self.setup
unless IssuesController.ancestors.include?(SubtaskFieldCopier::Patches::IssuesControllerPatch)
IssuesController.prepend SubtaskFieldCopier::Patches::IssuesControllerPatch
@@ -28,17 +28,15 @@ module SubtaskFieldCopier
end
@issue.custom_field_values = cf_values
# --- COPY CUSTOMER, VEHICLE & ESTIMATE---
if @issue.respond_to?(:customer=) && parent_issue.respond_to?(:customer)
@issue.customer = parent_issue.customer
end
if @issue.respond_to?(:vehicle=) && parent_issue.respond_to?(:vehicle)
@issue.vehicle = parent_issue.vehicle
end
if @issue.respond_to?(:estimate=) && parent_issue.respond_to?(:estimate)
@issue.estimate = parent_issue.estimate
# --- COPY REGISTERED FIELDS ---
# Iterate over any fields registered by other plugins
SubtaskFieldCopier.registered_fields.each do |field|
setter = "#{field}="
# Use metaprogramming to check if the setter/getter exists, then apply
if @issue.respond_to?(setter) && parent_issue.respond_to?(field)
@issue.send(setter, parent_issue.send(field))
end
end
end
end