From 31f9855a3ccf94b97aa40270d48ec87da6c30a85 Mon Sep 17 00:00:00 2001 From: Julien Froidefond Date: Fri, 21 Nov 2025 10:40:21 +0100 Subject: [PATCH] feat(TaskManagement): implement centralized readonly field logic for task synchronization - Added functionality to determine readonly fields based on task source (Jira, TFS) and status. - Updated EditTaskForm and TaskBasicFields components to utilize readonly fields for better user experience. - Introduced buildSyncUpdateData function to manage field preservation during synchronization. - Enhanced tests for readonly field logic to ensure correct behavior across different scenarios. --- src/components/forms/EditTaskForm.tsx | 2 + src/components/forms/task/TaskBasicFields.tsx | 117 ++++++-- src/lib/types.ts | 1 + src/services/integrations/jira/jira.ts | 106 +++++--- src/services/integrations/tfs/tfs.ts | 84 +++++- .../__tests__/readonly-fields.test.ts | 255 ++++++++++++++++++ .../task-management/readonly-fields.ts | 163 +++++++++++ src/services/task-management/tasks.ts | 8 + 8 files changed, 669 insertions(+), 67 deletions(-) create mode 100644 src/services/task-management/__tests__/readonly-fields.test.ts create mode 100644 src/services/task-management/readonly-fields.ts diff --git a/src/components/forms/EditTaskForm.tsx b/src/components/forms/EditTaskForm.tsx index 52506b9..acfd2fd 100644 --- a/src/components/forms/EditTaskForm.tsx +++ b/src/components/forms/EditTaskForm.tsx @@ -143,6 +143,8 @@ export function EditTaskForm({ } errors={errors} loading={loading} + readonlyFields={task.readonlyFields || []} + source={task.source} /> diff --git a/src/components/forms/task/TaskBasicFields.tsx b/src/components/forms/task/TaskBasicFields.tsx index c7e1aad..18fd5ed 100644 --- a/src/components/forms/task/TaskBasicFields.tsx +++ b/src/components/forms/task/TaskBasicFields.tsx @@ -19,6 +19,8 @@ interface TaskBasicFieldsProps { onDueDateChange: (date?: Date) => void; errors: Record; loading: boolean; + readonlyFields?: string[]; + source?: string; // Source de la tâche pour déterminer le message (jira, tfs, etc.) } export function TaskBasicFields({ @@ -34,31 +36,71 @@ export function TaskBasicFields({ onDueDateChange, errors, loading, + readonlyFields = [], + source, }: TaskBasicFieldsProps) { + const isTitleReadonly = readonlyFields.includes('title'); + const isDescriptionReadonly = readonlyFields.includes('description'); + const isStatusReadonly = readonlyFields.includes('status'); + const isPriorityReadonly = readonlyFields.includes('priority'); + const isDueDateReadonly = readonlyFields.includes('dueDate'); + + // Déterminer le message selon la source + const getSyncMessage = (field: string) => { + if (source === 'jira') { + return field === 'title' || field === 'description' || field === 'dueDate' + ? '(synchronisé par Jira)' + : '(sync)'; + } else if (source === 'tfs') { + return field === 'title' || field === 'description' || field === 'dueDate' + ? '(synchronisé par TFS)' + : '(sync)'; + } + return '(sync)'; + }; + return ( <> {/* Titre */} - onTitleChange(e.target.value)} - placeholder="Titre de la tâche..." - error={errors.title} - disabled={loading} - /> +
+
+ + {isTitleReadonly && ( + + {getSyncMessage('title')} + + )} +
+ onTitleChange(e.target.value)} + placeholder="Titre de la tâche..." + error={errors.title} + disabled={loading || isTitleReadonly} + /> +
{/* Description */}
- +
+ + {isDescriptionReadonly && ( + + {getSyncMessage('description')} + + )} +