Merge pull request #1239 from basecamp/faster-bell
Higher fidelity for watching/unwatching cards
This commit is contained in:
@@ -3,11 +3,9 @@ class Cards::WatchesController < ApplicationController
|
||||
|
||||
def create
|
||||
@card.watch_by Current.user
|
||||
redirect_back_or_to @card
|
||||
end
|
||||
|
||||
def destroy
|
||||
@card.unwatch_by Current.user
|
||||
redirect_back_or_to @card
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,19 +3,7 @@
|
||||
<%= render partial: "cards/comments/comment", collection: card.comments.chronologically, cached: true %>
|
||||
<%= render "cards/comments/new", card: card %>
|
||||
|
||||
<div class="comments__subscribers flex flex-column margin-block-start txt-align-start full-width">
|
||||
<strong class="txt-uppercase">Subscribers</strong>
|
||||
|
||||
<p class="margin-none-block-start margin-block-end-half">
|
||||
<%= pluralize(@card.watchers.without(User.system).count, "person") %> will be notified when someone comments on this.
|
||||
</p>
|
||||
|
||||
<div class="flex align-center flex-wrap gap-half max-width txt-normal">
|
||||
<% @card.watchers.without(User.system).alphabetically.each do |watcher| %>
|
||||
<%= avatar_tag watcher %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<%= render "cards/comments/watchers", card: card %>
|
||||
<% end %>
|
||||
|
||||
<footer class="delete-card txt-align-center full-width flex flex-column margin-block-start-double">
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
<div id="<%= dom_id(card, :comment_watchers) %>" class="comments__subscribers flex flex-column margin-block-start txt-align-start full-width">
|
||||
<strong class="txt-uppercase">Subscribers</strong>
|
||||
|
||||
<p class="margin-none-block-start margin-block-end-half">
|
||||
<%= pluralize(card.watchers.without(User.system).count, "person") %> will be notified when someone comments on this.
|
||||
</p>
|
||||
|
||||
<div class="flex align-center flex-wrap gap-half max-width txt-normal">
|
||||
<% card.watchers.without(User.system).alphabetically.each do |watcher| %>
|
||||
<%= avatar_tag watcher %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,7 @@
|
||||
<%= turbo_stream.replace dom_id(card, :watch_button) do %>
|
||||
<%= render "cards/watches/watch_button", card: card %>
|
||||
<% end %>
|
||||
|
||||
<%= turbo_stream.replace dom_id(card, :comment_watchers) do %>
|
||||
<%= render "cards/comments/watchers", card: card %>
|
||||
<% end %>
|
||||
@@ -0,0 +1,13 @@
|
||||
<div id="<%= dom_id(card, :watch_button) %>">
|
||||
<% if card.watched_by? Current.user %>
|
||||
<%= button_to card_watch_path(card), method: :delete, class: "btn btn--reversed", data: { controller: "tooltip" } do %>
|
||||
<%= icon_tag "bell" %>
|
||||
<span class="for-screen-reader">Stop watching</span>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= button_to card_watch_path(card), class: "btn", data: { controller: "tooltip" } do %>
|
||||
<%= icon_tag "bell-off" %>
|
||||
<span class="for-screen-reader">Watch this</span>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
@@ -0,0 +1 @@
|
||||
<%= render "cards/watches/refresh", card: @card %>
|
||||
@@ -0,0 +1 @@
|
||||
<%= render "cards/watches/refresh", card: @card %>
|
||||
@@ -1,13 +1,3 @@
|
||||
<%= turbo_frame_tag dom_id(@card, :watch) do %>
|
||||
<% if @card.watched_by? Current.user %>
|
||||
<%= button_to card_watch_path(@card), method: :delete, class: "btn btn--reversed", data: { controller: "tooltip" } do %>
|
||||
<%= icon_tag "bell" %>
|
||||
<span class="for-screen-reader">Stop watching</span>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= button_to card_watch_path(@card), class: "btn", data: { controller: "tooltip" } do %>
|
||||
<%= icon_tag "bell-off" %>
|
||||
<span class="for-screen-reader">Watch this</span>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<%= render "cards/watches/watch_button", card: @card %>
|
||||
<% end %>
|
||||
|
||||
@@ -11,8 +11,6 @@ class Cards::WatchesControllerTest < ActionDispatch::IntegrationTest
|
||||
assert_changes -> { cards(:logo).watched_by?(users(:kevin)) }, from: false, to: true do
|
||||
post card_watch_path(cards(:logo))
|
||||
end
|
||||
|
||||
assert_redirected_to cards(:logo)
|
||||
end
|
||||
|
||||
test "destroy" do
|
||||
@@ -21,7 +19,5 @@ class Cards::WatchesControllerTest < ActionDispatch::IntegrationTest
|
||||
assert_changes -> { cards(:logo).watched_by?(users(:kevin)) }, from: true, to: false do
|
||||
delete card_watch_path(cards(:logo))
|
||||
end
|
||||
|
||||
assert_redirected_to cards(:logo)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user