feat(task-management): add all_labels support and improve label handling

- Introduced all_labels property in task management to provide a complete list of labels for selection logic.
- Updated TasksControllerV2, TaskRow, and LabelsSelector components to utilize all_labels for enhanced label management.
- Improved checkbox handling in LabelsSelector to prevent event propagation and ensure better user interaction.
- Enhanced useTaskSocketHandlers to manage temporary subtasks effectively, preventing duplication during optimistic updates.
This commit is contained in:
chamikaJ
2025-07-07 09:40:56 +05:30
parent 2cf91bddea
commit a6f9046b42
6 changed files with 53 additions and 12 deletions

View File

@@ -43,6 +43,7 @@ import {
selectCurrentGroupingV3,
fetchTasksV3,
addSubtaskToParent,
removeTemporarySubtask,
} from '@/features/task-management/task-management.slice';
import {
updateEnhancedKanbanSubtask,
@@ -153,13 +154,19 @@ export const useTaskSocketHandlers = () => {
const updatedTask: Task = {
...currentTask,
labels:
labels.all_labels?.map(l => ({
labels.labels?.map(l => ({
id: l.id || '',
name: l.name || '',
color: l.color_code || '#1890ff',
end: l.end,
names: l.names,
})) || [],
all_labels:
labels.all_labels?.map(l => ({
id: l.id || '',
name: l.name || '',
color_code: l.color_code || '#1890ff',
})) || [],
updatedAt: new Date().toISOString(),
updated_at: new Date().toISOString(),
};
@@ -675,6 +682,24 @@ export const useTaskSocketHandlers = () => {
parent_task_id: data.parent_task_id,
is_sub_task: true,
};
// Before adding the real subtask, remove any temporary subtasks with the same name
// This prevents duplication from optimistic updates
const parentTask = store.getState().taskManagement.entities[data.parent_task_id];
if (parentTask && parentTask.sub_tasks) {
const temporarySubtasks = parentTask.sub_tasks.filter(
(st: Task) => st.isTemporary && st.name === subtask.title
);
// Remove each temporary subtask
temporarySubtasks.forEach((tempSubtask: Task) => {
dispatch(removeTemporarySubtask({
parentTaskId: data.parent_task_id,
tempId: tempSubtask.id
}));
});
}
dispatch(addSubtaskToParent({ parentId: data.parent_task_id, subtask }));
// Also update enhanced kanban slice for subtask creation