redirect to project context upon saving

pull/8721/head
ulferts 4 years ago
parent e834dff26e
commit 86746cff17
No known key found for this signature in database
GPG Key ID: A205708DE1284017
  1. 8
      modules/reporting_engine/lib/report/controller.rb
  2. 5
      modules/reporting_engine/lib/widget/controls/save_as.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

@ -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),
'#',

Loading…
Cancel
Save