feat(enhanced-kanban): add updateEnhancedKanbanTaskStatus action for task status management
- Introduced a new action to update task status within the enhanced Kanban feature, allowing for dynamic task movement between groups based on status changes. - Updated the task drawer status dropdown to utilize the new action for improved task management experience.
This commit is contained in:
@@ -13,6 +13,7 @@ import { ITaskStatus } from '@/types/tasks/taskStatus.types';
|
||||
import { checkTaskDependencyStatus } from '@/utils/check-task-dependency-status';
|
||||
import { Select } from 'antd';
|
||||
import { useMemo } from 'react';
|
||||
import { updateEnhancedKanbanTaskStatus } from '@/features/enhanced-kanban/enhanced-kanban.slice';
|
||||
|
||||
interface TaskDrawerStatusDropdownProps {
|
||||
statuses: ITaskStatus[];
|
||||
@@ -52,7 +53,7 @@ const TaskDrawerStatusDropdown = ({ statuses, task, teamId }: TaskDrawerStatusDr
|
||||
dispatch(updateTaskStatus(data));
|
||||
}
|
||||
if (tab === 'board') {
|
||||
dispatch(updateBoardTaskStatus(data));
|
||||
dispatch(updateEnhancedKanbanTaskStatus(data));
|
||||
}
|
||||
if (data.parent_task) getTaskProgress(data.parent_task);
|
||||
}
|
||||
|
||||
@@ -495,6 +495,42 @@ const enhancedKanbanSlice = createSlice({
|
||||
});
|
||||
},
|
||||
|
||||
// Enhanced Kanban external status update (for use in task drawer dropdown)
|
||||
updateEnhancedKanbanTaskStatus: (state, action: PayloadAction<ITaskListStatusChangeResponse>) => {
|
||||
const { id: task_id, status_id } = action.payload;
|
||||
let oldGroupId: string | null = null;
|
||||
let foundTask: IProjectTask | null = null;
|
||||
// Find the task and its group
|
||||
for (const group of state.taskGroups) {
|
||||
const task = group.tasks.find(t => t.id === task_id);
|
||||
if (task) {
|
||||
foundTask = task;
|
||||
oldGroupId = group.id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!foundTask) return;
|
||||
// If grouped by status and the group changes, move the task
|
||||
if (state.groupBy === IGroupBy.STATUS && oldGroupId && oldGroupId !== status_id) {
|
||||
// Remove from old group
|
||||
const oldGroup = state.taskGroups.find(g => g.id === oldGroupId);
|
||||
if (oldGroup) {
|
||||
oldGroup.tasks = oldGroup.tasks.filter(t => t.id !== task_id);
|
||||
}
|
||||
// Add to new group at the top
|
||||
const newGroup = state.taskGroups.find(g => g.id === status_id);
|
||||
if (newGroup) {
|
||||
foundTask.status_id = status_id;
|
||||
newGroup.tasks.unshift(foundTask);
|
||||
}
|
||||
} else {
|
||||
// Just update the status_id
|
||||
foundTask.status_id = status_id;
|
||||
}
|
||||
// Update cache
|
||||
state.taskCache[task_id] = foundTask;
|
||||
},
|
||||
|
||||
updateTaskPriority: (state, action: PayloadAction<ITaskListPriorityChangeResponse>) => {
|
||||
const { id: task_id, priority_id } = action.payload;
|
||||
|
||||
@@ -700,6 +736,7 @@ export const {
|
||||
reorderTasks,
|
||||
reorderGroups,
|
||||
addTaskToGroup,
|
||||
updateEnhancedKanbanTaskStatus,
|
||||
} = enhancedKanbanSlice.actions;
|
||||
|
||||
export default enhancedKanbanSlice.reducer;
|
||||
Reference in New Issue
Block a user