diff --git a/app/controllers/assignments/toggles_controller.rb b/app/controllers/assignments/toggles_controller.rb index bcf1616be..a2285b35e 100644 --- a/app/controllers/assignments/toggles_controller.rb +++ b/app/controllers/assignments/toggles_controller.rb @@ -2,12 +2,23 @@ class Assignments::TogglesController < ApplicationController include BubbleScoped, BucketScoped def create - @bubble.toggle_assignment assignee + new_assignee_ids = Array(params[:assignee_id]) + current_assignees = @bubble.assignees + + current_assignees.each do |assignee| + @bubble.toggle_assignment(assignee) unless new_assignee_ids.include?(assignee.id.to_s) + end + + new_assignee_ids.each do |id| + assignee = @bucket.users.active.find(id) + @bubble.toggle_assignment(assignee) unless current_assignees.include?(assignee) + end + redirect_to @bubble end private def assignee - @bucket.users.active.find params.expect(:assignee_id) + @bucket.users.active.find params[:assignee_id] end end diff --git a/app/views/bubbles/sidebar/_assignment.html.erb b/app/views/bubbles/sidebar/_assignment.html.erb index 215f0821f..59ce8d217 100644 --- a/app/views/bubbles/sidebar/_assignment.html.erb +++ b/app/views/bubbles/sidebar/_assignment.html.erb @@ -4,18 +4,22 @@ Assign - - <%= form_with url: bucket_bubble_assignment_toggles_path(bubble.bucket, bubble), data: { controller: "form" } do |form| %> - <%= form.combobox :assignee_id, users, required: true, - render_in: { partial: "bubbles/users/listbox_option", as: :user, locals: { bubble: bubble } }, - data: { controller: "autofocus", action: "hw-combobox:selection->form#submit" } %> - <% end %> + + Assign this to… -
- -
+ <%= form_with url: bucket_bubble_assignment_toggles_path(bubble.bucket, bubble), class: "flex flex-column gap-half full-width", data: { controller: "form" } do |form| %> + <% users.each do |user| %> +
+ <%= 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) %> +
+ <% end %> + <% end %>
diff --git a/app/views/bubbles/users/_listbox_option.html.erb b/app/views/bubbles/users/_listbox_option.html.erb deleted file mode 100644 index ec304a714..000000000 --- a/app/views/bubbles/users/_listbox_option.html.erb +++ /dev/null @@ -1,7 +0,0 @@ -
- <%= user.name %> - - <% if bubble.assigned_to?(user) %> - <%= image_tag "check.svg", aria: { hidden: "true" } %> - <% end %> -