4.3 KiB
Bulk Status Update Implementation
Overview
Implemented the bulk status update action for the TaskBrowser component, allowing users to update the status of multiple selected tasks simultaneously through a context menu.
Implementation Details
Frontend Changes
TaskBrowser.vue
Added the handleBulkStatusUpdate method that:
- Extracts selected task IDs from the selection state
- Shows loading state during the operation by setting
isLoading.value = true - Calls the service method
taskService.bulkUpdateStatus(taskIds, status) - Displays success toast with the count of updated tasks
- Handles errors and displays error toast with appropriate message
- Refreshes task list after successful update by calling
fetchTasks() - Closes context menu and clears selection after completion
Key Features
- Atomic updates: All tasks are updated together or none are updated (handled by backend)
- Loading state: Prevents duplicate operations during processing
- User feedback: Clear success/error messages with task counts
- Automatic refresh: Task list updates to reflect changes
- Clean UI: Context menu closes and selection clears after action
Code Structure
const handleBulkStatusUpdate = async (status: TaskStatus) => {
try {
// Extract selected task IDs
const taskIds = selectedTasks.value.map(task => task.id)
if (taskIds.length === 0) {
return
}
// Show loading state during operation
isLoading.value = true
// Call bulk update service
const result = await taskService.bulkUpdateStatus(taskIds, status)
// Display success toast with count of updated tasks
toast({
title: 'Success',
description: `${result.success_count} ${result.success_count === 1 ? 'task' : 'tasks'} updated`,
})
// Refresh task list after successful update
await fetchTasks()
// Close context menu and clear selection after completion
closeContextMenu()
rowSelection.value = {}
} catch (error) {
// Handle errors and display error toast
console.error('Failed to update task status:', error)
toast({
title: 'Error',
description: 'Failed to update tasks. Please try again.',
variant: 'destructive',
})
} finally {
isLoading.value = false
}
}
Integration
- Connected to
TaskBulkActionsMenuvia@status-selectedevent - Uses existing
taskService.bulkUpdateStatusmethod (already implemented in task 2) - Leverages existing selection state from
rowSelectionref - Uses existing toast notification system
Requirements Satisfied
✅ Requirement 4.2: Update all selected tasks to chosen status
✅ Requirement 4.3: Display success notification with count
✅ Requirement 4.4: Display error notification on failure
✅ Requirement 4.5: Refresh task list after update
✅ Requirement 6.1: Close context menu after action
✅ Requirement 6.3: Clear selections after action
Testing
Manual Testing
A test HTML file was created at frontend/test-bulk-status-update.html that allows:
- Login as admin
- Fetch tasks from a project
- Select multiple tasks by clicking
- Update status of selected tasks
- Verify the update was successful
Backend Testing
Existing test file at backend/test_bulk_actions.py verifies:
- Bulk status updates work correctly
- Atomicity is maintained (all or nothing)
- Error handling for invalid task IDs
- Permission checks
User Flow
- User selects multiple tasks using checkboxes
- User right-clicks on a selected task
- Context menu appears with "Set Status" option
- User hovers over "Set Status" to see status submenu
- User clicks desired status (e.g., "In Progress")
- Loading state activates
- Backend updates all tasks atomically
- Success toast appears: "X tasks updated"
- Task list refreshes to show new statuses
- Context menu closes and selection clears
Error Handling
- No tasks selected: Method returns early without action
- Network failure: Error toast displayed, original state maintained
- Partial failure: Backend handles atomically (all or nothing)
- Permission denied: Error toast with appropriate message
- Loading state: Prevents duplicate operations
Next Steps
Task 10 will implement the bulk assignment action using a similar pattern.