From 3726b2330b5ed3011f2dea5cdab7636bf296cded Mon Sep 17 00:00:00 2001 From: Shinuwa Date: Wed, 29 Jul 2026 08:45:17 +0200 Subject: [PATCH] remove automatic sort for task planner --- docs/STORAGE_SCHEMA.md | 3 -- tests/helpers/data-validation.mjs | 2 - tests/toolbox-modules.test.mjs | 4 -- website/public/data/site.json | 2 - .../toolboxes/modules/TaskPlannerModule.jsx | 41 +++++-------------- .../toolboxes/storage/toolboxStorage.js | 3 -- 6 files changed, 10 insertions(+), 45 deletions(-) diff --git a/docs/STORAGE_SCHEMA.md b/docs/STORAGE_SCHEMA.md index 1178649..83a5261 100644 --- a/docs/STORAGE_SCHEMA.md +++ b/docs/STORAGE_SCHEMA.md @@ -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`. diff --git a/tests/helpers/data-validation.mjs b/tests/helpers/data-validation.mjs index 702f7dd..bd002c7 100644 --- a/tests/helpers/data-validation.mjs +++ b/tests/helpers/data-validation.mjs @@ -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", diff --git a/tests/toolbox-modules.test.mjs b/tests/toolbox-modules.test.mjs index ee542d1..001facf 100644 --- a/tests/toolbox-modules.test.mjs +++ b/tests/toolbox-modules.test.mjs @@ -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); diff --git a/website/public/data/site.json b/website/public/data/site.json index b876b60..82a2558 100644 --- a/website/public/data/site.json +++ b/website/public/data/site.json @@ -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", diff --git a/website/src/features/toolboxes/modules/TaskPlannerModule.jsx b/website/src/features/toolboxes/modules/TaskPlannerModule.jsx index c25a0e4..be0cec9 100644 --- a/website/src/features/toolboxes/modules/TaskPlannerModule.jsx +++ b/website/src/features/toolboxes/modules/TaskPlannerModule.jsx @@ -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 }) {
-