Merge pull request #317 from basecamp/flavorjones-assignee-card-cache
Assignee dropdown no longer subject to the card fragment cache
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
class Assignments::TogglesController < ApplicationController
|
||||
include BubbleScoped, BucketScoped
|
||||
|
||||
def new
|
||||
render partial: "bubbles/sidebar/assignment", locals: { bubble: @bubble }
|
||||
end
|
||||
|
||||
def create
|
||||
new_assignee_ids = Array(params[:assignee_id])
|
||||
current_assignees = @bubble.assignees
|
||||
@@ -14,7 +18,15 @@ class Assignments::TogglesController < ApplicationController
|
||||
@bubble.toggle_assignment(assignee) unless current_assignees.include?(assignee)
|
||||
end
|
||||
|
||||
redirect_to @bubble
|
||||
@bubble.assignees.reload
|
||||
|
||||
respond_to do |format|
|
||||
format.turbo_stream do
|
||||
render turbo_stream: turbo_stream.replace([ @bubble, :assignees ],
|
||||
partial: "bubbles/assignees",
|
||||
locals: { bubble: @bubble })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
<%= turbo_frame_tag bubble, :assignees do %>
|
||||
<div class="flex">
|
||||
<% bubble.assignees.each do |assignee| %>
|
||||
<%= avatar_tag assignee, loading: :lazy, class: "avatar" %>
|
||||
<% end %>
|
||||
|
||||
<div class="position-relative" data-controller="dialog" data-action="keydown.esc->dialog#close click@document->dialog#closeOnClickOutside">
|
||||
<button class="btn card__hide-on-index <%= bubble.creating? || bubble.drafted? ? "fill-highlight" : "fill-transparent" %>" data-action="click->dialog#open:stop">
|
||||
<%= image_tag "add.svg", aria: { hidden: true }, size: 24 %>
|
||||
<span class="for-screen-reader">Assign</span>
|
||||
</button>
|
||||
|
||||
<%= turbo_frame_tag bubble, :assignment, src: new_bucket_bubble_assignment_toggle_path(bubble.bucket, bubble) %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -6,12 +6,7 @@
|
||||
|
||||
<div class="card__assignees flex flex-column align-center">
|
||||
<span class="txt-uppercase">Assigned</span>
|
||||
<div class="flex">
|
||||
<% bubble.assignees.each do |assignee| %>
|
||||
<%= avatar_tag assignee, loading: :lazy, class: "avatar" %>
|
||||
<% end %>
|
||||
|
||||
<%= render "bubbles/sidebar/assignment", bubble: bubble, users: bubble.bucket.users.active %>
|
||||
</div>
|
||||
<%= render "bubbles/assignees", bubble: bubble %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,26 +1,23 @@
|
||||
<div class="position-relative" data-controller="dialog" data-action="keydown.esc->dialog#close click@document->dialog#closeOnClickOutside">
|
||||
<button class="btn card__hide-on-index <%= bubble.creating? || bubble.drafted? ? "fill-highlight" : "fill-transparent" %>" data-action="click->dialog#open:stop">
|
||||
<%= image_tag "add.svg", aria: { hidden: true }, size: 24 %>
|
||||
<span class="for-screen-reader">Assign</span>
|
||||
</button>
|
||||
<% cache [bubble, bubble.bucket] do %>
|
||||
<%= turbo_frame_tag bubble, :assignment do %>
|
||||
<dialog class="popup panel flex-column align-start gap-half fill-white shadow" data-dialog-target="dialog">
|
||||
<strong class="popup__title margin-block-start-half pad-inline-half txt-nowrap">Assign this to…</strong>
|
||||
|
||||
<dialog class="popup panel flex-column align-start gap-half fill-white shadow" data-dialog-target="dialog">
|
||||
<strong class="popup__title margin-block-start-half pad-inline-half txt-nowrap">Assign this to…</strong>
|
||||
<%= form_with url: bucket_bubble_assignment_toggles_path(bubble.bucket, bubble), class: "flex flex-column full-width popup__list", data: { controller: "form" } do |form| %>
|
||||
<% bubble.bucket.users.active.sort_by(&:name).each do |user| %>
|
||||
<div class="btn popup__item">
|
||||
<%= form.check_box "assignee_id[]", {
|
||||
checked: bubble.assigned_to?(user),
|
||||
data: { action: "change->form#submit" },
|
||||
id: dom_id(user, :assign),
|
||||
include_hidden: false,
|
||||
}, user.id %>
|
||||
|
||||
<%= form_with url: bucket_bubble_assignment_toggles_path(bubble.bucket, bubble), class: "flex flex-column full-width popup__list", data: { controller: "form" } do |form| %>
|
||||
<% users.sort_by(&:name).each do |user| %>
|
||||
<div class="btn popup__item">
|
||||
<%= form.check_box "assignee_id[]", {
|
||||
checked: bubble.assigned_to?(user),
|
||||
data: { action: "change->form#submit" },
|
||||
id: dom_id(user, :assign),
|
||||
include_hidden: false,
|
||||
}, user.id %>
|
||||
|
||||
<%= form.label "assignee_id[]", user.name, for: dom_id(user, :assign), class: "overflow-ellipsis" %>
|
||||
<%= image_tag "check.svg", aria: { hidden: true }, size: 18, class: "checked flex-item-justify-end" %>
|
||||
</div>
|
||||
<%= form.label "assignee_id[]", user.name, for: dom_id(user, :assign), class: "overflow-ellipsis" %>
|
||||
<%= image_tag "check.svg", aria: { hidden: true }, size: 18, class: "checked flex-item-justify-end" %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</dialog>
|
||||
</div>
|
||||
</dialog>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
@@ -5,15 +5,21 @@ class Assignments::TogglesControllerTest < ActionDispatch::IntegrationTest
|
||||
sign_in_as :kevin
|
||||
end
|
||||
|
||||
test "new" do
|
||||
get new_bucket_bubble_assignment_toggle_url(buckets(:writebook), bubbles(:logo))
|
||||
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "create" do
|
||||
assert_changes "bubbles(:logo).assigned_to?(users(:david))", from: false, to: true do
|
||||
post bucket_bubble_assignment_toggles_url(buckets(:writebook), bubbles(:logo)), params: { assignee_id: users(:david).id }
|
||||
post bucket_bubble_assignment_toggles_url(buckets(:writebook), bubbles(:logo)), params: { assignee_id: users(:david).id }, as: :turbo_stream
|
||||
end
|
||||
assert_redirected_to bubbles(:logo)
|
||||
assert_response :success
|
||||
|
||||
assert_changes "bubbles(:logo).assigned_to?(users(:david))", from: true, to: false do
|
||||
post bucket_bubble_assignment_toggles_url(buckets(:writebook), bubbles(:logo)), params: { assignee_id: users(:kevin).id }
|
||||
post bucket_bubble_assignment_toggles_url(buckets(:writebook), bubbles(:logo)), params: { assignee_id: users(:kevin).id }, as: :turbo_stream
|
||||
end
|
||||
assert_redirected_to bubbles(:logo)
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user