From 34e5b14b583bc80d7184e58ccfe279c8f7e991c6 Mon Sep 17 00:00:00 2001 From: Jason Zimdars Date: Thu, 11 Sep 2025 18:05:34 -0500 Subject: [PATCH] Move the watchers list into the turbo frame Passes around a param to opt-out of rendering the watchers on the notification settings screen --- app/helpers/accesses_helper.rb | 43 +++++++++++++++---- .../cards/index/_add_card_button.html.erb | 9 +--- .../collections/involvements/update.html.erb | 2 +- .../settings/_collection.html.erb | 2 +- 4 files changed, 39 insertions(+), 17 deletions(-) diff --git a/app/helpers/accesses_helper.rb b/app/helpers/accesses_helper.rb index 97809ab55..78324f3e0 100644 --- a/app/helpers/accesses_helper.rb +++ b/app/helpers/accesses_helper.rb @@ -15,17 +15,44 @@ module AccessesHelper cached: ->(user) { [ user, selected ] } end - def access_involvement_advance_button(collection, user) + def access_involvement_advance_button(collection, user, show_watchers: true) access = collection.access_for(user) + involvement_label_id = dom_id(collection, :involvement_label) turbo_frame_tag dom_id(collection, :involvement_button) do - button_to collection_involvement_path(collection), method: :put, - aria: { labelledby: dom_id(collection, :involvement_label) }, - class: "btn", - params: { involvement: next_involvement(access.involvement) } do - icon_tag("notification-bell-#{access.involvement.dasherize}") + - tag.span(involvement_access_label(collection, access.involvement), class: "txt-nowrap txt-uppercase", id: dom_id(collection, :involvement_label)) - end + concat collection_watchers_list(collection) if show_watchers + concat involvement_button(collection, access, involvement_label_id, show_watchers) + end + end + + def involvement_button(collection, access, involvement_label_id, show_watchers) + button_to( + collection_involvement_path(collection), + method: :put, + aria: { labelledby: involvement_label_id }, + class: "btn", + params: { show_watchers: show_watchers, involvement: next_involvement(access.involvement) } + ) do + safe_join([ + icon_tag("notification-bell-#{access.involvement.dasherize}"), + tag.span( + involvement_access_label(collection, access.involvement), + class: "txt-nowrap txt-uppercase", + id: involvement_label_id + ) + ]) + end + end + + def collection_watchers_list(collection) + tag.div(class: "flex flex-wrap gap-half justify-center") do + safe_join( + collection.users + .without(User.system) + .where(accesses: { involvement: :watching }) + .distinct + .map { |watcher| avatar_tag(watcher) } + ) end end diff --git a/app/views/cards/index/_add_card_button.html.erb b/app/views/cards/index/_add_card_button.html.erb index 3a821cbd7..3f44b47fb 100644 --- a/app/views/cards/index/_add_card_button.html.erb +++ b/app/views/cards/index/_add_card_button.html.erb @@ -8,13 +8,8 @@ <% end %> diff --git a/app/views/collections/involvements/update.html.erb b/app/views/collections/involvements/update.html.erb index b72570962..28c5cfe0e 100644 --- a/app/views/collections/involvements/update.html.erb +++ b/app/views/collections/involvements/update.html.erb @@ -1 +1 @@ -<%= access_involvement_advance_button(@collection, Current.user) %> +<%= access_involvement_advance_button(@collection, Current.user, show_watchers: params[:show_watchers] == 'true') %> diff --git a/app/views/notifications/settings/_collection.html.erb b/app/views/notifications/settings/_collection.html.erb index a9d421e05..08aec6409 100644 --- a/app/views/notifications/settings/_collection.html.erb +++ b/app/views/notifications/settings/_collection.html.erb @@ -7,7 +7,7 @@ <% end %>