mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2026-11-17 18:20:36 -05:00
Let plugins add fields to the Create issues from estimate page
View hook view_qbo_estimate_issues_form draws plugins' fields in the shared Issue fields box; values posted as issue_plugin_fields[name] override the plugin defaults and reach qbo_billing_build_issue. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BiwYMjhoQvL7XsKKfRz4pM
This commit is contained in:
4 files changed
+21
-4
No files matched your search
@@ -155,7 +155,8 @@ class QboEstimatesController < ApplicationController
|
||||
end
|
||||
return render_404 unless @estimate
|
||||
|
||||
@defaults = issue_defaults
|
||||
# Values plugins' fields posted with the form (e.g. redmine_qbo_vehicles' vehicle) override their defaults
|
||||
@defaults = issue_defaults.merge(submitted_plugin_fields)
|
||||
@builder = RedmineQboBilling::EstimateIssueBuilder.new(@estimate, defaults: @defaults)
|
||||
@return_path = @defaults[:return_path].presence || edit_qbo_estimate_path(@estimate.id)
|
||||
@return_label = @defaults[:return_label].presence || "#{l(:label_estimate)} ##{@estimate.doc_number}"
|
||||
@@ -185,6 +186,15 @@ class QboEstimatesController < ApplicationController
|
||||
(results.detect { |r| r.is_a?(Hash) && r.any? } || {}).symbolize_keys
|
||||
end
|
||||
|
||||
# Plugins' own fields on the preview form (issue_plugin_fields[...], drawn by :view_qbo_estimate_issues_form),
|
||||
# only when the form was posted: { vehicle_id: "5" }
|
||||
def submitted_plugin_fields
|
||||
return {} unless request.post?
|
||||
|
||||
values = params[:issue_plugin_fields]
|
||||
values.respond_to?(:to_unsafe_h) ? values.to_unsafe_h.to_h.transform_keys(&:to_sym).transform_values(&:to_s) : {}
|
||||
end
|
||||
|
||||
# The shared custom field values from the preview form: { custom_field_id => value }
|
||||
def submitted_custom_field_values
|
||||
values = params.dig(:issue, :custom_field_values)
|
||||
|
||||
Reference in new issue
Block a user