Add a Group action to the floating selection toolbar when multiple items are selected #206
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_whiteboard#206
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
When the user selects two or more items, the floating selection toolbar should expose a Group action so creating a group is a one-click operation, like the existing Ungroup action shown when a group is selected. Today, grouping is only reachable via the right-click context menu or the Ctrl+G shortcut, which is inconsistent with the toolbar's role as the primary in-canvas action surface.
Scope
In the floating selection toolbar, when the current selection contains 2 or more selectable items, add a Group button:
WhiteboardPromptModal.open) pre-filled withGroup, then on confirm callsWhiteboardGroups.createGroup(capturedNodes, name)with the SAME selection snapshot used by Ctrl+G and the context-menu action — so changing the selection between click and confirm does not affect the resulting group.Acceptance Criteria
Group, same captured nodes).WhiteboardPromptModalis reused.Notes
The selection toolbar lives in
crates/hero_whiteboard_admin/static/web/js/whiteboard/selection_toolbar.js. The existing Ungroup action and the toolbar's button helpers are good references. The Group + modal flow already exists incontextmenu.jsandshortcuts.js; the toolbar should mirror that exact flow so the three entry points stay consistent. Frontend assets are embedded via rust-embed; rebuild required for visibility.Implementation Spec for Issue #206
Objective
Add a Group label button to the floating selection toolbar that appears whenever the current selection contains 2 or more items (and is not all comments). Clicking it opens the themed
WhiteboardPromptModalfor a group name and then callsWhiteboardGroups.createGroup(capturedNodes, name)against a snapshot taken at click time. Mirrors the existing Ungroup button atselection_toolbar.js:1605and exposes the Ctrl+G shortcut as a discoverable toolbar action.Requirements
cachedNodes.length >= 2.allCommentsis true (mirror existing guard at line ~228).cachedNodes.slice()BEFORE opening the modal (selection may change between click and confirm).WhiteboardPromptModal.open({ title: 'Group Selected', label: 'Group name', defaultValue: 'Group', confirmLabel: 'Create', cancelLabel: 'Cancel' }).null(cancel) → no-op; elseWhiteboardGroups.createGroup(capturedNodes, name || 'Group').Group (Ctrl+G)._buildLabelBtnto match the visual style of the existing Ungroup button._showPropsGroup(false)hides it for multi-select).Files to Modify/Create
crates/hero_whiteboard_admin/static/web/js/whiteboard/selection_toolbar.js— single-file change.Implementation Plan
Step 1: Add
_renderMultiSelectionhelperFiles:
selection_toolbar.js_renderForNode. Appends a_buildLabelBtn('Group', 'Group (Ctrl+G)', clickHandler)topropsEl. The handler capturesvar capturedNodes = cachedNodes.slice();, opensWhiteboardPromptModal.open({...}), then on resolve callsWhiteboardGroups.createGroup(capturedNodes, name || 'Group')(skip onnull). Defensive guards ontypeof WhiteboardPromptModal/WhiteboardGroups.Dependencies: none
Step 2: Update the multi-select branch in
update(nodes)Files:
selection_toolbar.jselse { cachedNode = null; _showPropsGroup(false); }branch (around line 250-253) with:_clearProps()already ran above;_updateDivider()runs below and detects viapropsEl.children.length > 0. No other change needed.Dependencies: Step 1
Step 3: Build & embed
cargo build --release -p hero_whiteboard_admin. No new files added;assets.rsdoes not need touching.Acceptance Criteria
allCommentsguard).Group (Ctrl+G).Group.WhiteboardGroups.createGrouppath).Notes
WhiteboardPromptModal(from #205) is loaded beforeselection_toolbar.jsinboard.html; even if load order varied, the click handler references it lazily at user-interaction time, mirroring howWhiteboardGroupsis referenced from the Ungroup handler._buildLabelBtn(label, title, onClick)creates a.wb-pt-btnbutton; matches the Ungroup pattern visually.createGroupaccepts any nodes; the issue does not require preventing nested groups.Implementation Summary
Added a Group label button to the floating selection toolbar's multi-select branch.
Changes
crates/hero_whiteboard_admin/static/web/js/whiteboard/selection_toolbar.js:_renderMultiSelection()helper that appends aGroup (Ctrl+G)button via the existing_buildLabelBtnhelper, capturescachedNodes.slice()at click time, opens the themedWhiteboardPromptModal, and on confirm callsWhiteboardGroups.createGroup(capturedNodes, name || 'Group').update(nodes)now renders this helper and shows the props panel whencachedNodes.length >= 2and the selection is not all comments; otherwise it still hides the panel as before.Behavior
Group (Ctrl+G); clicking opens the modal pre-filled withGroup; Enter confirms, Escape/Cancel/backdrop cancels.WhiteboardGroups.createGroupcode path).Test results
cargo test --workspace --lib: compiled cleanly, no failures (change is JS-only; regression guard).node --checkonselection_toolbar.js: OK; control-byte count = 0./js/whiteboard/selection_toolbar.js.