remove automatic sort for task planner
All checks were successful
Deploy Sokko G / deploy (push) Successful in 6s
All checks were successful
Deploy Sokko G / deploy (push) Successful in 6s
This commit is contained in:
parent
1d3bdd60f1
commit
3726b2330b
6 changed files with 10 additions and 45 deletions
|
|
@ -105,12 +105,6 @@ function moveCategory(categoryOrder, fromCategory, toCategory, placement = "befo
|
|||
return nextOrder;
|
||||
}
|
||||
|
||||
function sortTasks(tasks, sortMode) {
|
||||
if (sortMode !== "type") return tasks;
|
||||
const order = new Map(TASK_TYPES.map((type, index) => [type, index]));
|
||||
return [...tasks].sort((a, b) => (order.get(a.type) ?? 99) - (order.get(b.type) ?? 99));
|
||||
}
|
||||
|
||||
function getTaskTitle(tasks, taskId) {
|
||||
return tasks.find((task) => task.id === taskId)?.title || "Tâche supprimée";
|
||||
}
|
||||
|
|
@ -137,8 +131,8 @@ function getTaskParentMap(tasks, relations) {
|
|||
return parentMap;
|
||||
}
|
||||
|
||||
function getTasksForParent(tasks, parentMap, parentId, sortMode) {
|
||||
return sortTasks(tasks.filter((task) => (parentMap.get(task.id) || "") === parentId), sortMode);
|
||||
function getTasksForParent(tasks, parentMap, parentId) {
|
||||
return tasks.filter((task) => (parentMap.get(task.id) || "") === parentId);
|
||||
}
|
||||
|
||||
function getTaskCategory(task) {
|
||||
|
|
@ -203,8 +197,8 @@ function isTaskTreeComplete(taskIds, tasks, parentMap) {
|
|||
return treeIds.length > 0 && treeIds.every((taskId) => getTaskById(tasks, taskId)?.checked);
|
||||
}
|
||||
|
||||
function getTaskCategoryGroups(tasks, parentMap, parentId, sortMode, categoryOrder) {
|
||||
const siblings = getTasksForParent(tasks, parentMap, parentId, sortMode);
|
||||
function getTaskCategoryGroups(tasks, parentMap, parentId, categoryOrder) {
|
||||
const siblings = getTasksForParent(tasks, parentMap, parentId);
|
||||
if (parentId) {
|
||||
return {
|
||||
entries: siblings.map((task) => ({ type: "task", task })),
|
||||
|
|
@ -226,8 +220,6 @@ function getTaskCategoryGroups(tasks, parentMap, parentId, sortMode, categoryOrd
|
|||
category,
|
||||
tasks: siblings.filter((task) => getTaskCategoryForParent(task, tasks, parentMap, parentId) === category)
|
||||
})).filter((group) => group.tasks.length);
|
||||
if (sortMode !== "manual") return { entries: [...uncategorized.map((task) => ({ type: "task", task })), ...categoryGroups.map((group) => ({ type: "category", group }))], uncategorized, categories: categoryGroups };
|
||||
|
||||
const renderedCategories = new Set();
|
||||
const entries = siblings.map((task) => {
|
||||
const category = getTaskCategoryForParent(task, tasks, parentMap, parentId);
|
||||
|
|
@ -287,12 +279,11 @@ export function TaskPlannerModule({ toolboxId, moduleId, context, editing }) {
|
|||
getTargetId: (target) => target.dataset.taskId || getCategorySectionId(target.dataset.parentId || "", target.dataset.category || ""),
|
||||
canDropOn: (target, draggingTaskId) => {
|
||||
const draggingTask = data.tasks.find((task) => task.id === draggingTaskId);
|
||||
if (!draggingTask || data.sortMode !== "manual") return false;
|
||||
if (!draggingTask) return false;
|
||||
if (target.classList.contains("task-planner-category-section")) {
|
||||
return !parentMap.get(draggingTaskId) && !getTaskCategory(draggingTask) && !target.dataset.parentId && Boolean(target.dataset.category);
|
||||
}
|
||||
return data.sortMode === "manual"
|
||||
&& target.dataset.parentId === (parentMap.get(draggingTaskId) || "")
|
||||
return target.dataset.parentId === (parentMap.get(draggingTaskId) || "")
|
||||
&& (
|
||||
target.dataset.category === getTaskCategoryDataset(draggingTask, data.tasks, parentMap)
|
||||
|| (!parentMap.get(draggingTaskId) && !getTaskCategory(draggingTask) && Boolean(target.dataset.category))
|
||||
|
|
@ -488,17 +479,6 @@ export function TaskPlannerModule({ toolboxId, moduleId, context, editing }) {
|
|||
<div className="task-planner-module">
|
||||
<div className="task-planner-topbar">
|
||||
<div className="task-planner-global-controls">
|
||||
<button
|
||||
className={`tool-split-scroll-toggle task-planner-sort-toggle ${data.sortMode === "type" ? "active" : ""}`}
|
||||
type="button"
|
||||
onClick={() => save({ ...data, sortMode: data.sortMode === "type" ? "manual" : "type" })}
|
||||
aria-pressed={data.sortMode === "type"}
|
||||
aria-label={textContent.sortModeLabel || "Tri automatique"}
|
||||
title={textContent.sortModeLabel || "Tri automatique"}
|
||||
>
|
||||
<Icon name="sort-time" />
|
||||
<i aria-hidden="true" />
|
||||
</button>
|
||||
<button
|
||||
className={`tool-split-scroll-toggle task-planner-hide-completed-toggle ${data.hideCompleted ? "active" : ""}`}
|
||||
type="button"
|
||||
|
|
@ -624,7 +604,7 @@ function TaskPlannerBranch({
|
|||
onToggleCategoryCollapsed,
|
||||
visited = new Set()
|
||||
}) {
|
||||
const groupedTasks = getTaskCategoryGroups(tasks, parentMap, parentId, data.sortMode, data.categoryOrder);
|
||||
const groupedTasks = getTaskCategoryGroups(tasks, parentMap, parentId, data.categoryOrder);
|
||||
const children = [...groupedTasks.uncategorized, ...groupedTasks.categories.flatMap((group) => group.tasks)].filter((task) => !visited.has(task.id));
|
||||
if (!children.length) return null;
|
||||
const nextVisited = new Set([...visited, ...children.map((task) => task.id)]);
|
||||
|
|
@ -632,11 +612,11 @@ function TaskPlannerBranch({
|
|||
function hasVisibleDescendants(taskId, seen = new Set()) {
|
||||
if (seen.has(taskId)) return false;
|
||||
seen.add(taskId);
|
||||
return getTasksForParent(tasks, parentMap, taskId, data.sortMode).some((child) => !child.checked || hasVisibleDescendants(child.id, seen));
|
||||
return getTasksForParent(tasks, parentMap, taskId).some((child) => !child.checked || hasVisibleDescendants(child.id, seen));
|
||||
}
|
||||
|
||||
function renderTask(task) {
|
||||
const nestedChildren = getTasksForParent(tasks, parentMap, task.id, data.sortMode).filter((child) => !nextVisited.has(child.id));
|
||||
const nestedChildren = getTasksForParent(tasks, parentMap, task.id).filter((child) => !nextVisited.has(child.id));
|
||||
const nestedBranch = nestedChildren.length ? (
|
||||
<TaskPlannerBranch
|
||||
parentId={task.id}
|
||||
|
|
@ -855,9 +835,8 @@ function TaskPlannerItem({
|
|||
className="task-planner-drag-handle"
|
||||
type="button"
|
||||
onPointerDown={(event) => onDragStart(event, task.id)}
|
||||
disabled={data.sortMode !== "manual"}
|
||||
aria-label={`${textContent.reorderTitle || "Déplacer"} ${task.title}`}
|
||||
title={data.sortMode === "manual" ? textContent.reorderTitle || "Déplacer" : textContent.reorderDisabledTitle || "Tri manuel désactivé"}
|
||||
title={textContent.reorderTitle || "Déplacer"}
|
||||
>
|
||||
<Icon name="drag" />
|
||||
</button>
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ const TIMER_TABS = new Set(["stopwatch", "countdown"]);
|
|||
const COUNTDOWN_TYPES = new Set(["duration", "daily_time", "time_pattern", "interval"]);
|
||||
const TIMER_ALERT_MODES = new Set(["off", "visible", "site"]);
|
||||
const TASK_TYPES = new Set(["unique", "daily", "weekly"]);
|
||||
const TASK_SORT_MODES = new Set(["manual", "type"]);
|
||||
const DEFAULT_TASK_PLANNER_WEEKLY_RESET_DAY = 1;
|
||||
const DEFAULT_TASK_PLANNER_RESET_TIME = "00:00";
|
||||
const TOOLBOX_ICON_BASE = "/static/img/toolbox-icons/";
|
||||
|
|
@ -386,7 +385,6 @@ export function normalizeTaskPlannerData(data) {
|
|||
const taskIds = new Set(tasks.map((task) => task.id));
|
||||
const categoryOrder = normalizeTaskPlannerCategoryOrder(data?.categoryOrder, tasks);
|
||||
return {
|
||||
sortMode: TASK_SORT_MODES.has(data?.sortMode) ? data.sortMode : "manual",
|
||||
weeklyResetDay: normalizeWeekDay(data?.weeklyResetDay),
|
||||
resetTime: isClockTimeString(data?.resetTime) ? data.resetTime : DEFAULT_TASK_PLANNER_RESET_TIME,
|
||||
lastResetAt: normalizeTimestamp(data?.lastResetAt),
|
||||
|
|
@ -536,7 +534,6 @@ export function compactModuleDataForStorage(type, value) {
|
|||
if (type === "taskPlanner") {
|
||||
const normalized = normalizeTaskPlannerData(value);
|
||||
const compact = {};
|
||||
if (normalized.sortMode !== "manual") compact.sortMode = normalized.sortMode;
|
||||
if (normalized.weeklyResetDay !== DEFAULT_TASK_PLANNER_WEEKLY_RESET_DAY) compact.weeklyResetDay = normalized.weeklyResetDay;
|
||||
if (normalized.resetTime !== DEFAULT_TASK_PLANNER_RESET_TIME) compact.resetTime = normalized.resetTime;
|
||||
if (normalized.lastResetAt) compact.lastResetAt = normalized.lastResetAt;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue