From 263bc486ed0f42096d27e630e16d4c5b60baba93 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Wed, 2 Jul 2025 17:50:37 -0400 Subject: [PATCH] Collection entropy config edits render a turbo frame so we don't disturb the rest of the edit page. --- .../collections/entropy_configurations_controller.rb | 2 +- app/views/collections/edit/_auto_close.html.erb | 10 ++++++---- .../entropy_configurations_controller_test.rb | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/controllers/collections/entropy_configurations_controller.rb b/app/controllers/collections/entropy_configurations_controller.rb index c09edcf98..98a2b1b0f 100644 --- a/app/controllers/collections/entropy_configurations_controller.rb +++ b/app/controllers/collections/entropy_configurations_controller.rb @@ -4,7 +4,7 @@ class Collections::EntropyConfigurationsController < ApplicationController def update @collection.entropy_configuration.update!(entropy_configuration_params) - redirect_to edit_collection_path(@collection), notice: "Collection updated" + render turbo_stream: turbo_stream.replace([ @collection, :entropy_configuration ], partial: "collections/edit/auto_close", locals: { collection: @collection }) end private diff --git a/app/views/collections/edit/_auto_close.html.erb b/app/views/collections/edit/_auto_close.html.erb index 825915756..79125016d 100644 --- a/app/views/collections/edit/_auto_close.html.erb +++ b/app/views/collections/edit/_auto_close.html.erb @@ -1,4 +1,6 @@ -
- Do or Die - <%= render "entropy/auto_close", model: collection, url: collection_entropy_configuration_path(collection) %> -
+<%= turbo_frame_tag @collection, :entropy_configuration do %> +
+ Do or Die + <%= render "entropy/auto_close", model: collection, url: collection_entropy_configuration_path(collection) %> +
+<% end %> diff --git a/test/controllers/collections/entropy_configurations_controller_test.rb b/test/controllers/collections/entropy_configurations_controller_test.rb index 0b2ddf060..b96c3b198 100644 --- a/test/controllers/collections/entropy_configurations_controller_test.rb +++ b/test/controllers/collections/entropy_configurations_controller_test.rb @@ -12,6 +12,6 @@ class Collections::EntropyConfigurationsControllerTest < ActionDispatch::Integra assert_equal 1.day, @collection.entropy_configuration.reload.auto_close_period assert_equal 2.days, @collection.entropy_configuration.reload.auto_reconsider_period - assert_redirected_to edit_collection_path(@collection) + assert_turbo_stream action: :replace, target: dom_id(@collection, :entropy_configuration) end end