Just use plain checkboxes
- Style WIP
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -4,18 +4,22 @@
|
||||
<span>Assign</span>
|
||||
</button>
|
||||
|
||||
<dialog class="combox-popup panel align-center gap-half fill-white shadow" data-dialog-target="dialog">
|
||||
<%= 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 %>
|
||||
<dialog class="combox-popup panel flex-column align-start gap-half fill-white shadow" style="--panel-border-radius: 1em;" data-dialog-target="dialog">
|
||||
<strong>Assign this to…</strong>
|
||||
|
||||
<form method="dialog">
|
||||
<button class="btn txt-small" title="Close (esc)">
|
||||
<%= image_tag "remove.svg", aria: { hidden: true }, size: 24 %>
|
||||
<span class="for-screen-reader">Close</span>
|
||||
</button>
|
||||
</form>
|
||||
<%= 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| %>
|
||||
<div class="btn full-width borderless justify-start" style="--btn-border-radius: 0.3em;">
|
||||
<%= 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) %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</dialog>
|
||||
</div>
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
<div class="flex gap-half justify-space-between align-center" style="--btn-icon-size: 1rem">
|
||||
<%= user.name %>
|
||||
|
||||
<% if bubble.assigned_to?(user) %>
|
||||
<%= image_tag "check.svg", aria: { hidden: "true" } %>
|
||||
<% end %>
|
||||
</div>
|
||||
Reference in New Issue
Block a user