mirror of
https://github.com/opf/openproject.git
synced 2026-06-13 19:20:00 +00:00
Navigate back to the original page after updating an attribute help text so that context is kept when triggered from within a dialog
This commit is contained in:
@@ -59,7 +59,9 @@ class AttributeHelpTextsController < ApplicationController
|
||||
@attribute_help_text = AttributeHelpText.new type: @attribute_scope
|
||||
end
|
||||
|
||||
def edit; end
|
||||
def edit
|
||||
@back_url = params[:back_url] || request.referer
|
||||
end
|
||||
|
||||
def create # rubocop:disable Metrics/AbcSize
|
||||
call = ::AttributeHelpTexts::CreateService
|
||||
@@ -83,7 +85,7 @@ class AttributeHelpTextsController < ApplicationController
|
||||
|
||||
if call.success?
|
||||
flash[:notice] = t(:notice_successful_update)
|
||||
redirect_to attribute_help_texts_path(tab: @attribute_help_text.attribute_scope)
|
||||
redirect_back_or_default(attribute_help_texts_path(tab: @attribute_help_text.attribute_scope))
|
||||
else
|
||||
flash.now[:error] = call.message || I18n.t("notice_internal_server_error")
|
||||
render action: :edit, status: :unprocessable_entity
|
||||
|
||||
@@ -43,15 +43,14 @@ See COPYRIGHT and LICENSE files for more details.
|
||||
%>
|
||||
|
||||
<div class="op-admin-settings-form-wrapper">
|
||||
<%=
|
||||
primer_form_with(
|
||||
model: @attribute_help_text,
|
||||
scope: :attribute_help_text,
|
||||
url: { action: :update },
|
||||
method: :patch,
|
||||
data: { turbo: false } # reload page to update previews
|
||||
) do |f|
|
||||
render AttributeHelpTexts::Form.new(f)
|
||||
end
|
||||
%>
|
||||
<%= primer_form_with(
|
||||
model: @attribute_help_text,
|
||||
scope: :attribute_help_text,
|
||||
url: { action: :update },
|
||||
method: :patch,
|
||||
data: { turbo: false } # reload page to update previews
|
||||
) do |f| %>
|
||||
<%= back_url_hidden_field_tag %>
|
||||
<%= render AttributeHelpTexts::Form.new(f) %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user