From 18f43482e0423e7fd89619da1c714de828b02a0b Mon Sep 17 00:00:00 2001 From: William Petit Date: Thu, 31 Aug 2023 20:33:59 -0600 Subject: [PATCH] feat: remove auto updating of likely/pessimistic values --- client/src/hooks/use-project-reducer.ts | 8 - client/src/routes/project/tasks-table.tsx | 342 +++++++++++----------- 2 files changed, 175 insertions(+), 175 deletions(-) diff --git a/client/src/hooks/use-project-reducer.ts b/client/src/hooks/use-project-reducer.ts index 7fdc6e3..7d9ec39 100644 --- a/client/src/hooks/use-project-reducer.ts +++ b/client/src/hooks/use-project-reducer.ts @@ -124,14 +124,6 @@ export function handleUpdateTaskEstimation(project: Project, action: UpdateTaskE [action.confidence]: action.value }; - if (estimations.likely < estimations.optimistic) { - estimations.likely = estimations.optimistic; - } - - if (estimations.pessimistic < estimations.likely) { - estimations.pessimistic = estimations.likely; - } - return { ...project, tasks: { diff --git a/client/src/routes/project/tasks-table.tsx b/client/src/routes/project/tasks-table.tsx index ba770c2..4a100e4 100644 --- a/client/src/routes/project/tasks-table.tsx +++ b/client/src/routes/project/tasks-table.tsx @@ -8,192 +8,200 @@ import { defaults, getTimeUnit } from "../../models/params"; import ProjectTimeUnit from "../../components/project-time-unit"; export interface TaskTableProps { - project: Project - onTaskAdd: (task: Task) => void - onTaskRemove: (taskId: TaskID) => void - onEstimationChange: (taskId: TaskID, confidence: EstimationConfidence, value: number) => void - onTaskLabelUpdate: (taskId: TaskID, label: string) => void + project: Project + onTaskAdd: (task: Task) => void + onTaskRemove: (taskId: TaskID) => void + onEstimationChange: (taskId: TaskID, confidence: EstimationConfidence, value: number) => void + onTaskLabelUpdate: (taskId: TaskID, label: string) => void } export type EstimationTotals = { [confidence in EstimationConfidence]: number } const TaskTable: FunctionComponent = ({ project, onTaskAdd, onEstimationChange, onTaskRemove, onTaskLabelUpdate }) => { - - const defaultTaskCategory = Object.keys(project.params.taskCategories)[0]; - const [ task, setTask ] = useState(newTask("", defaultTaskCategory)); - const [ totals, setTotals ] = useState({ - [EstimationConfidence.Optimistic]: 0, - [EstimationConfidence.Likely]: 0, - [EstimationConfidence.Pessimistic]: 0, - } as EstimationTotals); - const isPrint = usePrintMediaQuery(); + const defaultTaskCategory = Object.keys(project.params.taskCategories)[0]; + const [task, setTask] = useState(newTask("", defaultTaskCategory)); + const [totals, setTotals] = useState({ + [EstimationConfidence.Optimistic]: 0, + [EstimationConfidence.Likely]: 0, + [EstimationConfidence.Pessimistic]: 0, + } as EstimationTotals); - useEffect(() => { - let optimistic = 0; - let likely = 0; - let pessimistic = 0; + const isPrint = usePrintMediaQuery(); - Object.values(project.tasks).forEach(t => { - optimistic += t.estimations.optimistic; - likely += t.estimations.likely; - pessimistic += t.estimations.pessimistic; - }); + useEffect(() => { + let optimistic = 0; + let likely = 0; + let pessimistic = 0; - setTotals({ optimistic, likely, pessimistic }); - }, [project.tasks]); + Object.values(project.tasks).forEach(t => { + optimistic += t.estimations.optimistic; + likely += t.estimations.likely; + pessimistic += t.estimations.pessimistic; + }); - const onNewTaskLabelChange = (evt: ChangeEvent) => { - const value = (evt.currentTarget as HTMLInputElement).value; - setTask({...task, label: value}); - }; + setTotals({ optimistic, likely, pessimistic }); + }, [project.tasks]); - const onNewTaskCategoryChange = (evt: ChangeEvent) => { - const value = (evt.currentTarget as HTMLInputElement).value; - setTask({...task, category: value}); - }; + const onNewTaskLabelChange = (evt: ChangeEvent) => { + const value = (evt.currentTarget as HTMLInputElement).value; + setTask({ ...task, label: value }); + }; - const onTaskLabelChange = (taskId: TaskID, value: string) => { - onTaskLabelUpdate(taskId, value); - }; + const onNewTaskCategoryChange = (evt: ChangeEvent) => { + const value = (evt.currentTarget as HTMLInputElement).value; + setTask({ ...task, category: value }); + }; - const onAddTaskClick = (evt: MouseEvent) => { - onTaskAdd(task); - setTask(newTask("", defaultTaskCategory)); - }; + const onTaskLabelChange = (taskId: TaskID, value: string) => { + onTaskLabelUpdate(taskId, value); + }; - const onTaskRemoveClick = (taskId: TaskID, evt: MouseEvent) => { - onTaskRemove(taskId); - }; + const onAddTaskClick = (evt: MouseEvent) => { + onTaskAdd(task); + setTask(newTask("", defaultTaskCategory)); + }; - const withEstimationChange = (confidence: EstimationConfidence, taskID: TaskID, evt: ChangeEvent) => { - const textValue = (evt.currentTarget as HTMLInputElement).value; - const value = parseFloat(textValue); - onEstimationChange(taskID, confidence, value); - }; + const onTaskRemoveClick = (taskId: TaskID, evt: MouseEvent) => { + onTaskRemove(taskId); + }; - const onOptimisticChange = withEstimationChange.bind(null, EstimationConfidence.Optimistic); - const onLikelyChange = withEstimationChange.bind(null, EstimationConfidence.Likely); - const onPessimisticChange = withEstimationChange.bind(null, EstimationConfidence.Pessimistic); + const withEstimationChange = (confidence: EstimationConfidence, taskID: TaskID, evt: ChangeEvent) => { + const textValue = (evt.currentTarget as HTMLInputElement).value; + const value = parseFloat(textValue); + onEstimationChange(taskID, confidence, value); + }; - return ( -
- - - - - - - - - - - - - - - + const onOptimisticChange = withEstimationChange.bind(null, EstimationConfidence.Optimistic); + const onLikelyChange = withEstimationChange.bind(null, EstimationConfidence.Likely); + const onPessimisticChange = withEstimationChange.bind(null, EstimationConfidence.Pessimistic); + + return ( +
+
TâcheCatégorieEstimation (en )
OptimisteProbablePessimiste
+ + + + + + + + + + + + + + + { + Object.values(project.tasks).map(t => { + const category = project.params.taskCategories[t.category]; + const categoryLabel = category ? category.label : '???'; + return ( + + + + + - - - - - - - - ) + isPrint ? + {t.estimations.optimistic} : + + } + + + + + ) + }) + } + { + Object.keys(project.tasks).length === 0 ? + + + + : + null + } + + + + + - - - : - null - } - - - - - - - - - - - - - - -
TâcheCatégorieEstimation (en )
OptimisteProbablePessimiste
+ + + ({value})} + onChange={onTaskLabelChange.bind(null, t.id)} + value={t.label} /> + {categoryLabel} { - Object.values(project.tasks).map(t => { - const category = project.params.taskCategories[t.category]; - const categoryLabel = category ? category.label : '???'; - return ( -
- - - ({value})} - onChange={onTaskLabelChange.bind(null, t.id)} - value={t.label} /> - { categoryLabel } - { - isPrint ? - {t.estimations.optimistic} : - - } - - { - isPrint ? - {t.estimations.likely} : - - } - - { - isPrint ? - {t.estimations.pessimistic} : - - } -
+ { + isPrint ? + {t.estimations.likely} : + + } + + { + isPrint ? + {t.estimations.pessimistic} : + + } +
Aucune tâche pour l'instant.
+
+

+ +

+

+ +

Aucune tâche pour l'instant.
-
-

- -

-

- - - -

-

- - Ajouter - -

-
-
Total
{totals.optimistic} {totals.likely} {totals.pessimistic}
-
- ); + } + + +

+

+ + Ajouter + +

+ + + Total + + + + {totals.optimistic} + {totals.likely} + {totals.pessimistic} + + + + + ); }; export default TaskTable;