Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
f0a28b1
retrieve sibling columns
tomycostantino Dec 9, 2025
eb7ef20
touch siblings after create and destroy commits
tomycostantino Dec 9, 2025
b7042cf
create refresh sibling columns turbo stream partial
tomycostantino Dec 9, 2025
b06b813
refresh sibling columns when moving column
tomycostantino Dec 9, 2025
8a7abc3
refresh sibling columns on column creation and deletion
tomycostantino Dec 9, 2025
845d4a1
test left and right position controller updates
tomycostantino Dec 9, 2025
392c368
test board columns controller refreshes sibling columns
tomycostantino Dec 9, 2025
820e8ef
test creating/destroying columns touches siblings
tomycostantino Dec 9, 2025
5d1ce5a
rename from sibling_columns to surroundings
tomycostantino Dec 9, 2025
fc02b66
update refresh logic to target surroundings only
tomycostantino Dec 9, 2025
8e6e761
update views to use refresh_surroundings stream
tomycostantino Dec 9, 2025
1f8c9ae
update tests
tomycostantino Dec 9, 2025
df7e597
Merge branch 'main' into update-columns-on-actions
tomycostantino Dec 11, 2025
fb0b787
rename surroundings to adjacent columns
tomycostantino Dec 11, 2025
52fcca9
remove unnecessary callback
tomycostantino Dec 11, 2025
383c518
rename file from refresh surroundings to refresh adjacent columns
tomycostantino Dec 11, 2025
2e629db
rename to use refresh adjacent columns turbo stream
tomycostantino Dec 11, 2025
51d61b5
update tests
tomycostantino Dec 11, 2025
5ece8f7
replace destroy column turbo stream for redirect_back_or_to
tomycostantino Dec 11, 2025
5eda42f
update columns controller destroy test
tomycostantino Dec 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/boards/columns_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def destroy
@column.destroy

respond_to do |format|
format.turbo_stream
format.html { redirect_back_or_to @board }
format.json { head :no_content }
end
end
Expand Down
4 changes: 4 additions & 0 deletions app/models/column/positioned.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ def rightmost?
right_column.nil?
end

def adjacent_columns
board.columns.where(id: [ left_column&.id, right_column&.id ].compact)
end

private
def set_position
max_position = board.columns.maximum(:position) || 0
Expand Down
1 change: 1 addition & 0 deletions app/views/boards/columns/create.turbo_stream.erb
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
<%= turbo_stream.before("closed-cards", partial: "boards/show/column", method: :morph, locals: { column: @column }) %>
<%= render "columns/refresh_adjacent_columns", column: @column %>
1 change: 0 additions & 1 deletion app/views/boards/columns/destroy.turbo_stream.erb

This file was deleted.

3 changes: 3 additions & 0 deletions app/views/columns/_refresh_adjacent_columns.turbo_stream.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<% column.adjacent_columns.each do |adjacent_column| %>
<%= turbo_stream.replace(dom_id(adjacent_column), partial: "boards/show/column", method: :morph, locals: { column: adjacent_column }) %>
<% end %>
1 change: 1 addition & 0 deletions app/views/columns/left_positions/create.turbo_stream.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<% if @left_column %>
<%= turbo_stream.remove(dom_id(@column)) %>
<%= turbo_stream.before(@left_column, partial: "boards/show/column", locals: { column: @column }) %>
<%= render "columns/refresh_adjacent_columns", column: @column %>
<% end %>
1 change: 1 addition & 0 deletions app/views/columns/right_positions/create.turbo_stream.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<% if @right_column %>
<%= turbo_stream.remove(dom_id(@column)) %>
<%= turbo_stream.after(@right_column, partial: "boards/show/column", locals: { column: @column }) %>
<%= render "columns/refresh_adjacent_columns", column: @column %>
<% end %>
21 changes: 16 additions & 5 deletions test/controllers/boards/columns_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ class Boards::ColumnsControllerTest < ActionDispatch::IntegrationTest
assert_equal "New Column", boards(:writebook).columns.last.name
end

test "create refreshes adjacent columns" do
board = boards(:writebook)

post board_columns_path(board), params: { column: { name: "New Column" } }, as: :turbo_stream

new_column = board.columns.find_by!(name: "New Column")
new_column.adjacent_columns.each do |adjacent_column|
assert_turbo_stream action: :replace, target: dom_id(adjacent_column)
end
end

test "update" do
column = columns(:writebook_in_progress)

Expand All @@ -29,12 +40,12 @@ class Boards::ColumnsControllerTest < ActionDispatch::IntegrationTest
end

test "destroy" do
column = columns(:writebook_on_hold)
column = columns(:writebook_in_progress)
adjacent_columns = column.adjacent_columns.to_a

assert_difference -> { boards(:writebook).columns.count }, -1 do
delete board_column_path(boards(:writebook), column), as: :turbo_stream
assert_response :success
end
delete board_column_path(column.board, column), as: :turbo_stream

assert_redirected_to board_path(column.board)
end

test "index as JSON" do
Expand Down
10 changes: 10 additions & 0 deletions test/controllers/columns/left_positions_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ class Columns::LeftPositionsControllerTest < ActionDispatch::IntegrationTest
assert_equal original_position_a, column_b.reload.position
end

test "move left refreshes adjacent columns" do
column = columns(:writebook_in_progress)

post column_left_position_path(column), as: :turbo_stream

column.reload.adjacent_columns.each do |adjacent_column|
assert_turbo_stream action: :replace, target: dom_id(adjacent_column)
end
end

test "users can only reorder columns in boards they have access to" do
column = columns(:writebook_in_progress)

Expand Down
10 changes: 10 additions & 0 deletions test/controllers/columns/right_positions_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ class Columns::RightPositionsControllerTest < ActionDispatch::IntegrationTest
assert_equal original_position_a, column_b.reload.position
end

test "move right refreshes adjacent columns" do
column = columns(:writebook_in_progress)

post column_right_position_path(column), as: :turbo_stream

column.reload.adjacent_columns.each do |adjacent_column|
assert_turbo_stream action: :replace, target: dom_id(adjacent_column)
end
end

test "users can only reorder columns in boards they have access to" do
column = columns(:writebook_triage)

Expand Down