Restore add card button in the timeline

It will add to the first selected collection, or to the
first one in the menu if no collection selected
This commit is contained in:
Jorge Manrubia
2025-09-09 17:41:07 +02:00
parent 20009d51ae
commit 8ea2d7346b
3 changed files with 7 additions and 2 deletions
+5
View File
@@ -83,6 +83,11 @@ class User::Filtering
end
end
def single_collection_or_first
# Default to the first selected or, when no selection, to the first one
filter.collections.first || collections.first
end
def cache_key
ActiveSupport::Cache.expand_cache_key([ user, filter, expanded? ], "user-filtering")
end
+1 -1
View File
@@ -5,7 +5,7 @@
<% content_for :header do %>
<%= render "filters/menu", user_filtering: @user_filtering %>
<%= render "filters/menu/add_card_button", user_filtering: @user_filtering %>
<%= render "events/index/add_card_button", user_filtering: @user_filtering %>
<h1 class="header__title overflow-ellipsis">
<div class="overflow-ellipsis">
@@ -1,5 +1,5 @@
<div class="header__actions header__actions--start">
<% if collection = user_filtering.single_collection %>
<% if collection = user_filtering.single_collection_or_first %>
<%= button_to collection_cards_path(collection), method: :post, class: "btn btn--link btn--circle-mobile" do %>
<%= icon_tag "add" %>
<span>Add a card</span>