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:
Henriette Darge
2026-04-24 09:10:41 +02:00
parent f579df8b4b
commit 44060d87c0
2 changed files with 14 additions and 13 deletions
@@ -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
+10 -11
View File
@@ -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>