refactor(task-details-form): enhance progress input handling and improve assignee rendering
- Added `InlineMember` type import for better type management. - Enhanced the `Avatars` component to handle multiple sources for assignee names, improving flexibility in data handling.
This commit is contained in:
@@ -30,6 +30,7 @@ import TaskDrawerProgress from './details/task-drawer-progress/task-drawer-progr
|
|||||||
import { useAppSelector } from '@/hooks/useAppSelector';
|
import { useAppSelector } from '@/hooks/useAppSelector';
|
||||||
import logger from '@/utils/errorLogger';
|
import logger from '@/utils/errorLogger';
|
||||||
import TaskDrawerRecurringConfig from './details/task-drawer-recurring-config/task-drawer-recurring-config';
|
import TaskDrawerRecurringConfig from './details/task-drawer-recurring-config/task-drawer-recurring-config';
|
||||||
|
import { InlineMember } from '@/types/teamMembers/inlineMember.types';
|
||||||
|
|
||||||
interface TaskDetailsFormProps {
|
interface TaskDetailsFormProps {
|
||||||
taskFormViewModel?: ITaskFormViewModel | null;
|
taskFormViewModel?: ITaskFormViewModel | null;
|
||||||
@@ -46,9 +47,6 @@ const ConditionalProgressInput = ({ task, form }: ConditionalProgressInputProps)
|
|||||||
const hasSubTasks = task?.sub_tasks_count > 0;
|
const hasSubTasks = task?.sub_tasks_count > 0;
|
||||||
const isSubTask = !!task?.parent_task_id;
|
const isSubTask = !!task?.parent_task_id;
|
||||||
|
|
||||||
// Add more aggressive logging and checks
|
|
||||||
logger.debug(`Task ${task.id} status: hasSubTasks=${hasSubTasks}, isSubTask=${isSubTask}, modes: time=${project?.use_time_progress}, manual=${project?.use_manual_progress}, weighted=${project?.use_weighted_progress}`);
|
|
||||||
|
|
||||||
// STRICT RULE: Never show progress input for parent tasks with subtasks
|
// STRICT RULE: Never show progress input for parent tasks with subtasks
|
||||||
// This is the most important check and must be done first
|
// This is the most important check and must be done first
|
||||||
if (hasSubTasks) {
|
if (hasSubTasks) {
|
||||||
@@ -59,13 +57,19 @@ const ConditionalProgressInput = ({ task, form }: ConditionalProgressInputProps)
|
|||||||
// Only for tasks without subtasks, determine which input to show based on project mode
|
// Only for tasks without subtasks, determine which input to show based on project mode
|
||||||
if (project?.use_time_progress) {
|
if (project?.use_time_progress) {
|
||||||
// In time-based mode, show progress input ONLY for tasks without subtasks
|
// In time-based mode, show progress input ONLY for tasks without subtasks
|
||||||
return <TaskDrawerProgress task={{...task, sub_tasks_count: hasSubTasks ? 1 : 0}} form={form} />;
|
return (
|
||||||
|
<TaskDrawerProgress task={{ ...task, sub_tasks_count: hasSubTasks ? 1 : 0 }} form={form} />
|
||||||
|
);
|
||||||
} else if (project?.use_manual_progress) {
|
} else if (project?.use_manual_progress) {
|
||||||
// In manual mode, show progress input ONLY for tasks without subtasks
|
// In manual mode, show progress input ONLY for tasks without subtasks
|
||||||
return <TaskDrawerProgress task={{...task, sub_tasks_count: hasSubTasks ? 1 : 0}} form={form} />;
|
return (
|
||||||
|
<TaskDrawerProgress task={{ ...task, sub_tasks_count: hasSubTasks ? 1 : 0 }} form={form} />
|
||||||
|
);
|
||||||
} else if (project?.use_weighted_progress && isSubTask) {
|
} else if (project?.use_weighted_progress && isSubTask) {
|
||||||
// In weighted mode, show weight input for subtasks
|
// In weighted mode, show weight input for subtasks
|
||||||
return <TaskDrawerProgress task={{...task, sub_tasks_count: hasSubTasks ? 1 : 0}} form={form} />;
|
return (
|
||||||
|
<TaskDrawerProgress task={{ ...task, sub_tasks_count: hasSubTasks ? 1 : 0 }} form={form} />
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@@ -148,7 +152,13 @@ const TaskDetailsForm = ({ taskFormViewModel = null }: TaskDetailsFormProps) =>
|
|||||||
|
|
||||||
<Form.Item name="assignees" label={t('taskInfoTab.details.assignees')}>
|
<Form.Item name="assignees" label={t('taskInfoTab.details.assignees')}>
|
||||||
<Flex gap={4} align="center">
|
<Flex gap={4} align="center">
|
||||||
<Avatars members={taskFormViewModel?.task?.assignee_names || []} />
|
<Avatars
|
||||||
|
members={
|
||||||
|
taskFormViewModel?.task?.assignee_names ||
|
||||||
|
(taskFormViewModel?.task?.names as unknown as InlineMember[]) ||
|
||||||
|
[]
|
||||||
|
}
|
||||||
|
/>
|
||||||
<TaskDrawerAssigneeSelector
|
<TaskDrawerAssigneeSelector
|
||||||
task={(taskFormViewModel?.task as ITaskViewModel) || null}
|
task={(taskFormViewModel?.task as ITaskViewModel) || null}
|
||||||
/>
|
/>
|
||||||
@@ -160,10 +170,7 @@ const TaskDetailsForm = ({ taskFormViewModel = null }: TaskDetailsFormProps) =>
|
|||||||
<TaskDrawerEstimation t={t} task={taskFormViewModel?.task as ITaskViewModel} form={form} />
|
<TaskDrawerEstimation t={t} task={taskFormViewModel?.task as ITaskViewModel} form={form} />
|
||||||
|
|
||||||
{taskFormViewModel?.task && (
|
{taskFormViewModel?.task && (
|
||||||
<ConditionalProgressInput
|
<ConditionalProgressInput task={taskFormViewModel?.task as ITaskViewModel} form={form} />
|
||||||
task={taskFormViewModel?.task as ITaskViewModel}
|
|
||||||
form={form}
|
|
||||||
/>
|
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<Form.Item name="priority" label={t('taskInfoTab.details.priority')}>
|
<Form.Item name="priority" label={t('taskInfoTab.details.priority')}>
|
||||||
|
|||||||
Reference in New Issue
Block a user