Add task progress tracking methods documentation and enhance progress update logic
- Introduced a new markdown file detailing task progress tracking methods: manual, weighted, and time-based. - Updated backend logic to include complete ratio calculations for tasks. - Improved socket command for task progress updates, enabling recursive updates for ancestor tasks. - Enhanced frontend components to reflect progress changes based on the selected tracking method, including updates to task display and progress input handling. - Added support for manual progress flag in task model to facilitate accurate progress representation.
This commit is contained in:
@@ -572,14 +572,29 @@ const taskSlice = createSlice({
|
||||
) => {
|
||||
const { taskId, progress, totalTasksCount, completedCount } = action.payload;
|
||||
|
||||
for (const group of state.taskGroups) {
|
||||
const task = group.tasks.find(task => task.id === taskId);
|
||||
if (task) {
|
||||
task.complete_ratio = progress;
|
||||
task.total_tasks_count = totalTasksCount;
|
||||
task.completed_count = completedCount;
|
||||
break;
|
||||
// Helper function to find and update a task at any nesting level
|
||||
const findAndUpdateTask = (tasks: IProjectTask[]) => {
|
||||
for (const task of tasks) {
|
||||
if (task.id === taskId) {
|
||||
task.complete_ratio = progress;
|
||||
task.total_tasks_count = totalTasksCount;
|
||||
task.completed_count = completedCount;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check subtasks if they exist
|
||||
if (task.sub_tasks && task.sub_tasks.length > 0) {
|
||||
const found = findAndUpdateTask(task.sub_tasks);
|
||||
if (found) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
// Try to find and update the task in any task group
|
||||
for (const group of state.taskGroups) {
|
||||
const found = findAndUpdateTask(group.tasks);
|
||||
if (found) break;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -1,20 +1,54 @@
|
||||
import React from 'react';
|
||||
import { Progress, Tooltip } from 'antd';
|
||||
import './task-list-progress-cell.css';
|
||||
import { IProjectTask } from '@/types/project/projectTasksViewModel.types';
|
||||
import { useAppSelector } from '@/hooks/useAppSelector';
|
||||
|
||||
type TaskListProgressCellProps = {
|
||||
task: IProjectTask;
|
||||
};
|
||||
|
||||
const TaskListProgressCell = ({ task }: TaskListProgressCellProps) => {
|
||||
return task.is_sub_task ? null : (
|
||||
<Tooltip title={`${task.completed_count || 0} / ${task.total_tasks_count || 0}`}>
|
||||
const { project } = useAppSelector(state => state.projectReducer);
|
||||
const isManualProgressEnabled = project?.use_manual_progress;
|
||||
const isSubtask = task.is_sub_task;
|
||||
const hasManualProgress = task.manual_progress;
|
||||
|
||||
// Handle different cases:
|
||||
// 1. For subtasks when manual progress is enabled, show the progress
|
||||
// 2. For parent tasks, always show progress
|
||||
// 3. For subtasks when manual progress is not enabled, don't show progress (null)
|
||||
|
||||
if (isSubtask && !isManualProgressEnabled) {
|
||||
return null; // Don't show progress for subtasks when manual progress is disabled
|
||||
}
|
||||
|
||||
// For parent tasks, show completion ratio with task count tooltip
|
||||
if (!isSubtask) {
|
||||
return (
|
||||
<Tooltip title={`${task.completed_count || 0} / ${task.total_tasks_count || 0}`}>
|
||||
<Progress
|
||||
percent={task.complete_ratio || 0}
|
||||
type="circle"
|
||||
size={24}
|
||||
style={{ cursor: 'default' }}
|
||||
strokeWidth={(task.complete_ratio || 0) >= 100 ? 9 : 7}
|
||||
/>
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
|
||||
// For subtasks with manual progress enabled, show the progress
|
||||
return (
|
||||
<Tooltip
|
||||
title={hasManualProgress ? `Manual: ${task.progress_value || 0}%` : `${task.progress || 0}%`}
|
||||
>
|
||||
<Progress
|
||||
percent={task.complete_ratio || 0}
|
||||
percent={hasManualProgress ? (task.progress_value || 0) : (task.progress || 0)}
|
||||
type="circle"
|
||||
size={24}
|
||||
size={22} // Slightly smaller for subtasks
|
||||
style={{ cursor: 'default' }}
|
||||
strokeWidth={(task.complete_ratio || 0) >= 100 ? 9 : 7}
|
||||
strokeWidth={(task.progress || 0) >= 100 ? 9 : 7}
|
||||
/>
|
||||
</Tooltip>
|
||||
);
|
||||
|
||||
@@ -16,6 +16,7 @@ export interface ITaskStatusCategory {
|
||||
}
|
||||
|
||||
export interface IProjectTask {
|
||||
manual_progress: any;
|
||||
due_time?: string;
|
||||
id?: string;
|
||||
name?: string;
|
||||
|
||||
Reference in New Issue
Block a user