Correct Dialog Close Button (#85)

* correct dialog#close -> DS--dialog#close

* additional ds-- add

* stop reload on close

* Added option for reload_on_close var

* Fix test to allow query param in redirect URL
This commit is contained in:
ByteBard
2025-08-08 09:05:03 +10:00
committed by GitHub
parent f6dde1a098
commit b7d9c89471
5 changed files with 6 additions and 6 deletions

View File

@@ -25,7 +25,7 @@ class RulesController < ApplicationController
@rule = Current.family.rules.build(rule_params)
if @rule.save
redirect_to confirm_rule_path(@rule)
redirect_to confirm_rule_path(@rule, reload_on_close: true)
else
render :new, status: :unprocessable_entity
end

View File

@@ -16,7 +16,7 @@
<span class="text-primary"><%= title %></span>
</div>
<%= icon("x", as_button: true, size: "lg", data: { action: "dialog#close" }) %>
<%= icon("x", as_button: true, size: "lg", data: { action: "DS--dialog#close" }) %>
</div>
<div class="p-2 text-subdued">
@@ -45,7 +45,7 @@
</div>
</div>
<div class="flex items-center space-x-2">
<button data-action="dialog#close">Close</button>
<button data-action="DS--dialog#close">Close</button>
<kbd class="bg-alpha-black-50 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.1)] p-1 rounded-md flex w-8 h-5 shrink-0 grow-0 items-center justify-center text-xs">ESC</kbd>
</div>
</div>

View File

@@ -1,4 +1,4 @@
<%= render DS::Dialog.new(reload_on_close: true) do |dialog| %>
<%= render DS::Dialog.new(reload_on_close: params[:reload_on_close].present?) do |dialog| %>
<%
title = if @rule.name.present?
"Confirm changes to \"#{@rule.name}\""

View File

@@ -21,7 +21,7 @@
</div>
<div class="flex justify-end gap-2 mt-auto">
<%= render DS::Button.new(text: "Cancel", variant: "ghost", data: { action: "click->dialog#close" }) %>
<%= render DS::Button.new(text: "Cancel", variant: "ghost", data: { action: "click->DS--dialog#close" }) %>
<%= render DS::Button.new(text: "Save", data: { bulk_select_scope_param: "bulk_update", action: "bulk-select#submitBulkRequest" }) %>
</div>
<% end %>

View File

@@ -71,7 +71,7 @@ class RulesControllerTest < ActionDispatch::IntegrationTest
assert_equal "set_transaction_category", rule.actions.first.action_type
assert_equal categories(:food_and_drink).id, rule.actions.first.value
assert_redirected_to confirm_rule_url(rule)
assert_redirected_to confirm_rule_url(rule, reload_on_close: true)
end
test "can update rule" do