remove automatic sort for task planner
All checks were successful
Deploy Sokko G / deploy (push) Successful in 6s

This commit is contained in:
Shinuwa 2026-07-29 08:45:17 +02:00
parent 1d3bdd60f1
commit 3726b2330b
6 changed files with 10 additions and 45 deletions

View file

@ -265,7 +265,6 @@ Type : `taskPlanner`
```json
{
"sortMode": "manual",
"weeklyResetDay": 1,
"resetTime": "00:00",
"lastResetAt": 1760000000000,
@ -308,7 +307,6 @@ Type : `taskPlanner`
Notes :
- `type` vaut `unique`, `daily` ou `weekly`.
- `sortMode` vaut `manual` ou `type`. Le tri par type affiche quotidiennes, hebdo, puis uniques.
- `weeklyResetDay` suit les jours JavaScript : `0` dimanche, `1` lundi, ..., `6` samedi.
- `resetTime` est global à l'outil et vaut `HH:MM`.
- `hideCompleted` masque les tâches effectuées à l'affichage, ainsi que les catégories dont toutes les tâches sont effectuées.
@ -325,7 +323,6 @@ Notes :
Stockage compact :
- `sortMode` est omis si la valeur vaut `manual`.
- `weeklyResetDay` global est omis si la valeur vaut `1`.
- `resetTime` est omis si la valeur vaut `00:00`.
- `lastResetAt` est omis si la valeur vaut `0`.

View file

@ -191,7 +191,6 @@ export function validateSiteContent(site) {
"toolboxes.modules.timer.deleteTitle",
"toolboxes.modules.taskPlanner.settingsTitle",
"toolboxes.modules.taskPlanner.settingsButtonLabel",
"toolboxes.modules.taskPlanner.sortModeLabel",
"toolboxes.modules.taskPlanner.hideCompletedTitle",
"toolboxes.modules.taskPlanner.globalWeeklyResetDayLabel",
"toolboxes.modules.taskPlanner.resetTimeLabel",
@ -207,7 +206,6 @@ export function validateSiteContent(site) {
"toolboxes.modules.taskPlanner.weeklyType",
"toolboxes.modules.taskPlanner.addButton",
"toolboxes.modules.taskPlanner.reorderTitle",
"toolboxes.modules.taskPlanner.reorderDisabledTitle",
"toolboxes.modules.taskPlanner.checkTitle",
"toolboxes.modules.taskPlanner.uncheckTitle",
"toolboxes.modules.taskPlanner.deleteTitle",

View file

@ -30,7 +30,6 @@ test("time pattern recurrence uses configured frequency instead of next remainin
test("task planner data normalizes invalid settings and relations", () => {
const normalized = normalizeTaskPlannerData({
sortMode: "unknown",
weeklyResetDay: 9,
resetTime: "27:80",
hideCompleted: true,
@ -49,7 +48,6 @@ test("task planner data normalizes invalid settings and relations", () => {
]
});
assert.equal(normalized.sortMode, "manual");
assert.equal(normalized.weeklyResetDay, 1);
assert.equal(normalized.resetTime, "00:00");
assert.equal(normalized.hideCompleted, true);
@ -66,7 +64,6 @@ test("task planner data normalizes invalid settings and relations", () => {
test("task planner storage compacts defaults and export remaps task relations", () => {
const compact = compactModuleDataForStorage("taskPlanner", {
sortMode: "type",
weeklyResetDay: 1,
resetTime: "00:00",
hideCompleted: true,
@ -81,7 +78,6 @@ test("task planner storage compacts defaults and export remaps task relations",
]
});
assert.equal(compact.sortMode, "type");
assert.equal(compact.weeklyResetDay, undefined);
assert.equal(compact.resetTime, undefined);
assert.equal(compact.hideCompleted, true);

View file

@ -325,7 +325,6 @@
"taskPlanner": {
"settingsTitle": "Réglages du planificateur",
"settingsButtonLabel": "Paramètres des réinitialisations",
"sortModeLabel": "Tri automatique par type",
"hideCompletedTitle": "Masquer les tâches effectuées",
"globalWeeklyResetDayLabel": "Reset hebdo",
"resetTimeLabel": "Heure de reset",
@ -341,7 +340,6 @@
"weeklyType": "Hebdomadaire",
"addButton": "Ajouter",
"reorderTitle": "Déplacer",
"reorderDisabledTitle": "Tri manuel désactivé",
"checkTitle": "Marquer effectué",
"uncheckTitle": "Marquer non effectué",
"deleteTitle": "Supprimer",

View file

@ -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>

View file

@ -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;