Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

redirect to project context upon saving

ulferts86746cff1736
diff --git a/modules/reporting_engine/lib/report/controller.rb b/modules/reporting_engine/lib/report/controller.rb
index 8b66bad99b0..36b86f23eca 100644
--- a/modules/reporting_engine/lib/report/controller.rb
+++ b/modules/reporting_engine/lib/report/controller.rb
@@ -65,10 +65,14 @@ module Report::Controller
@query.public! if make_query_public?
@query.send("#{user_key}=", current_user.id)
@query.save!
+
+ redirect_params = { action: 'show', id: @query.id }
+ redirect_params[:project_id] = @project.identifier if @project
+
if request.xhr? # Update via AJAX - return url for redirect
- render plain: url_for(action: 'show', id: @query.id)
+ render plain: url_for(**redirect_params)
else # Redirect to the new record
- redirect_to action: 'show', id: @query.id
+ redirect_to **redirect_params
end
end
diff --git a/modules/reporting_engine/lib/widget/controls/save_as.rb b/modules/reporting_engine/lib/widget/controls/save_as.rb
index 4e2fd3e1884..a95948c462f 100644
--- a/modules/reporting_engine/lib/widget/controls/save_as.rb
+++ b/modules/reporting_engine/lib/widget/controls/save_as.rb
@@ -83,11 +83,14 @@ class Widget::Controls::SaveAs < Widget::Controls
end
def render_popup_buttons
+ save_url_params = { action: 'create', set_filter: '1' }
+ save_url_params[:project_id] = @subject.project.id if @subject.project
+
save = link_to(I18n.t(:button_save),
'#',
id: 'query-icon-save-button',
class: 'button -highlight icon-context icon-save',
- :"data-target" => url_for(action: 'create', set_filter: '1'))
+ :"data-target" => url_for(**save_url_params))
cancel = link_to(I18n.t(:button_cancel),
'#',