// Rôle : regroupe les panneaux secondaires d'une tâche du task planner.
import { Icon } from "../../../components/Icon.jsx";
import { InlineNotice } from "../../../components/AppOverlays.jsx";
import { Tooltip } from "../../../components/Tooltip.jsx";
import { useInlineEdit } from "../../../hooks/useInlineEdit.js";
import { TaskPlannerQuantityTarget } from "./TaskPlannerQuantity.jsx";
import {
WEEK_DAYS,
getEffectiveTaskCategory,
getTaskById,
getTaskTitle
} from "./taskPlannerUtils.js";
export function MissingPrerequisitesTooltip({ missingPrerequisites, tasks, textContent }) {
return (
{textContent.missingPrerequisiteTitle || "Pré requis non effectué"}
{missingPrerequisites.map((relation) => (
{getTaskTitle(tasks, relation.toTaskId)}
))}
)}
position="top-start"
>
{textContent.missingPrerequisiteBadge || "Pré requis"}
);
}
export function TaskPlannerItemDetails({
task,
tasks,
data,
parentMap,
parentId,
textContent,
descriptionOpen,
settingsOpen,
noticeMessage,
relations,
relationTargets,
onUpdateTask,
onAddLinkTarget,
onRemoveLinkTarget,
onSetPrerequisite,
onSetTaskCategory
}) {
return (
<>
{descriptionOpen && (
)}
{settingsOpen && (
)}
>
);
}
function TaskDescriptionPanel({ task, tasks, parentMap, parentId, textContent, onUpdateTask, onSetTaskCategory }) {
const parentTask = parentId ? getTaskById(tasks, parentId) : null;
const inheritedCategory = parentTask ? getEffectiveTaskCategory(parentTask, tasks, parentMap) : "";
const categoryValue = parentTask ? inheritedCategory : task.category || "";
const categoryEditable = !parentTask;
const categoryEdit = useInlineEdit({
value: categoryValue,
onCommit: (category) => {
if (categoryEditable) onSetTaskCategory(task.id, category);
}
});
const descriptionEdit = useInlineEdit({
value: task.description,
onCommit: (description) => onUpdateTask(task.id, (current) => ({ ...current, description })),
commitOnEnter: false
});
return (
);
}
function TaskResetSettings({ task, data, textContent, onUpdateTask }) {
if (task.type === "daily") {
const hasOverride = Boolean(task.dailyResetTime);
return (
);
}
if (task.type === "weekly") {
return (
);
}
return (
{textContent.taskResetLabel || "Réinitialisation"}
{textContent.noTaskResetLabel || "Aucun reset"}
);
}
function LinksEditor({ label, relations, task, tasks, parentMap, relationTargets, emptyLabel, addLabel, removeLabel, prerequisiteLabel, onAddLinkTarget, onRemoveLinkTarget, onSetPrerequisite }) {
const descendantIds = new Set();
function collectDescendants(taskId) {
tasks.filter((item) => parentMap.get(item.id) === taskId).forEach((child) => {
descendantIds.add(child.id);
collectDescendants(child.id);
});
}
collectDescendants(task.id);
const availableTargets = relationTargets.filter((target) => !descendantIds.has(target.id));
return (
{label}
{relations.length ? relations.map((relation) => (
{getTaskTitle(tasks, relation.toTaskId)}
)) :
{emptyLabel}}
);
}