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
|
|
@ -265,7 +265,6 @@ Type : `taskPlanner`
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"sortMode": "manual",
|
|
||||||
"weeklyResetDay": 1,
|
"weeklyResetDay": 1,
|
||||||
"resetTime": "00:00",
|
"resetTime": "00:00",
|
||||||
"lastResetAt": 1760000000000,
|
"lastResetAt": 1760000000000,
|
||||||
|
|
@ -308,7 +307,6 @@ Type : `taskPlanner`
|
||||||
Notes :
|
Notes :
|
||||||
|
|
||||||
- `type` vaut `unique`, `daily` ou `weekly`.
|
- `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.
|
- `weeklyResetDay` suit les jours JavaScript : `0` dimanche, `1` lundi, ..., `6` samedi.
|
||||||
- `resetTime` est global à l'outil et vaut `HH:MM`.
|
- `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.
|
- `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 :
|
Stockage compact :
|
||||||
|
|
||||||
- `sortMode` est omis si la valeur vaut `manual`.
|
|
||||||
- `weeklyResetDay` global est omis si la valeur vaut `1`.
|
- `weeklyResetDay` global est omis si la valeur vaut `1`.
|
||||||
- `resetTime` est omis si la valeur vaut `00:00`.
|
- `resetTime` est omis si la valeur vaut `00:00`.
|
||||||
- `lastResetAt` est omis si la valeur vaut `0`.
|
- `lastResetAt` est omis si la valeur vaut `0`.
|
||||||
|
|
|
||||||
|
|
@ -191,7 +191,6 @@ export function validateSiteContent(site) {
|
||||||
"toolboxes.modules.timer.deleteTitle",
|
"toolboxes.modules.timer.deleteTitle",
|
||||||
"toolboxes.modules.taskPlanner.settingsTitle",
|
"toolboxes.modules.taskPlanner.settingsTitle",
|
||||||
"toolboxes.modules.taskPlanner.settingsButtonLabel",
|
"toolboxes.modules.taskPlanner.settingsButtonLabel",
|
||||||
"toolboxes.modules.taskPlanner.sortModeLabel",
|
|
||||||
"toolboxes.modules.taskPlanner.hideCompletedTitle",
|
"toolboxes.modules.taskPlanner.hideCompletedTitle",
|
||||||
"toolboxes.modules.taskPlanner.globalWeeklyResetDayLabel",
|
"toolboxes.modules.taskPlanner.globalWeeklyResetDayLabel",
|
||||||
"toolboxes.modules.taskPlanner.resetTimeLabel",
|
"toolboxes.modules.taskPlanner.resetTimeLabel",
|
||||||
|
|
@ -207,7 +206,6 @@ export function validateSiteContent(site) {
|
||||||
"toolboxes.modules.taskPlanner.weeklyType",
|
"toolboxes.modules.taskPlanner.weeklyType",
|
||||||
"toolboxes.modules.taskPlanner.addButton",
|
"toolboxes.modules.taskPlanner.addButton",
|
||||||
"toolboxes.modules.taskPlanner.reorderTitle",
|
"toolboxes.modules.taskPlanner.reorderTitle",
|
||||||
"toolboxes.modules.taskPlanner.reorderDisabledTitle",
|
|
||||||
"toolboxes.modules.taskPlanner.checkTitle",
|
"toolboxes.modules.taskPlanner.checkTitle",
|
||||||
"toolboxes.modules.taskPlanner.uncheckTitle",
|
"toolboxes.modules.taskPlanner.uncheckTitle",
|
||||||
"toolboxes.modules.taskPlanner.deleteTitle",
|
"toolboxes.modules.taskPlanner.deleteTitle",
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,6 @@ test("time pattern recurrence uses configured frequency instead of next remainin
|
||||||
|
|
||||||
test("task planner data normalizes invalid settings and relations", () => {
|
test("task planner data normalizes invalid settings and relations", () => {
|
||||||
const normalized = normalizeTaskPlannerData({
|
const normalized = normalizeTaskPlannerData({
|
||||||
sortMode: "unknown",
|
|
||||||
weeklyResetDay: 9,
|
weeklyResetDay: 9,
|
||||||
resetTime: "27:80",
|
resetTime: "27:80",
|
||||||
hideCompleted: true,
|
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.weeklyResetDay, 1);
|
||||||
assert.equal(normalized.resetTime, "00:00");
|
assert.equal(normalized.resetTime, "00:00");
|
||||||
assert.equal(normalized.hideCompleted, true);
|
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", () => {
|
test("task planner storage compacts defaults and export remaps task relations", () => {
|
||||||
const compact = compactModuleDataForStorage("taskPlanner", {
|
const compact = compactModuleDataForStorage("taskPlanner", {
|
||||||
sortMode: "type",
|
|
||||||
weeklyResetDay: 1,
|
weeklyResetDay: 1,
|
||||||
resetTime: "00:00",
|
resetTime: "00:00",
|
||||||
hideCompleted: true,
|
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.weeklyResetDay, undefined);
|
||||||
assert.equal(compact.resetTime, undefined);
|
assert.equal(compact.resetTime, undefined);
|
||||||
assert.equal(compact.hideCompleted, true);
|
assert.equal(compact.hideCompleted, true);
|
||||||
|
|
|
||||||
|
|
@ -325,7 +325,6 @@
|
||||||
"taskPlanner": {
|
"taskPlanner": {
|
||||||
"settingsTitle": "Réglages du planificateur",
|
"settingsTitle": "Réglages du planificateur",
|
||||||
"settingsButtonLabel": "Paramètres des réinitialisations",
|
"settingsButtonLabel": "Paramètres des réinitialisations",
|
||||||
"sortModeLabel": "Tri automatique par type",
|
|
||||||
"hideCompletedTitle": "Masquer les tâches effectuées",
|
"hideCompletedTitle": "Masquer les tâches effectuées",
|
||||||
"globalWeeklyResetDayLabel": "Reset hebdo",
|
"globalWeeklyResetDayLabel": "Reset hebdo",
|
||||||
"resetTimeLabel": "Heure de reset",
|
"resetTimeLabel": "Heure de reset",
|
||||||
|
|
@ -341,7 +340,6 @@
|
||||||
"weeklyType": "Hebdomadaire",
|
"weeklyType": "Hebdomadaire",
|
||||||
"addButton": "Ajouter",
|
"addButton": "Ajouter",
|
||||||
"reorderTitle": "Déplacer",
|
"reorderTitle": "Déplacer",
|
||||||
"reorderDisabledTitle": "Tri manuel désactivé",
|
|
||||||
"checkTitle": "Marquer effectué",
|
"checkTitle": "Marquer effectué",
|
||||||
"uncheckTitle": "Marquer non effectué",
|
"uncheckTitle": "Marquer non effectué",
|
||||||
"deleteTitle": "Supprimer",
|
"deleteTitle": "Supprimer",
|
||||||
|
|
|
||||||
|
|
@ -105,12 +105,6 @@ function moveCategory(categoryOrder, fromCategory, toCategory, placement = "befo
|
||||||
return nextOrder;
|
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) {
|
function getTaskTitle(tasks, taskId) {
|
||||||
return tasks.find((task) => task.id === taskId)?.title || "Tâche supprimée";
|
return tasks.find((task) => task.id === taskId)?.title || "Tâche supprimée";
|
||||||
}
|
}
|
||||||
|
|
@ -137,8 +131,8 @@ function getTaskParentMap(tasks, relations) {
|
||||||
return parentMap;
|
return parentMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTasksForParent(tasks, parentMap, parentId, sortMode) {
|
function getTasksForParent(tasks, parentMap, parentId) {
|
||||||
return sortTasks(tasks.filter((task) => (parentMap.get(task.id) || "") === parentId), sortMode);
|
return tasks.filter((task) => (parentMap.get(task.id) || "") === parentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTaskCategory(task) {
|
function getTaskCategory(task) {
|
||||||
|
|
@ -203,8 +197,8 @@ function isTaskTreeComplete(taskIds, tasks, parentMap) {
|
||||||
return treeIds.length > 0 && treeIds.every((taskId) => getTaskById(tasks, taskId)?.checked);
|
return treeIds.length > 0 && treeIds.every((taskId) => getTaskById(tasks, taskId)?.checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTaskCategoryGroups(tasks, parentMap, parentId, sortMode, categoryOrder) {
|
function getTaskCategoryGroups(tasks, parentMap, parentId, categoryOrder) {
|
||||||
const siblings = getTasksForParent(tasks, parentMap, parentId, sortMode);
|
const siblings = getTasksForParent(tasks, parentMap, parentId);
|
||||||
if (parentId) {
|
if (parentId) {
|
||||||
return {
|
return {
|
||||||
entries: siblings.map((task) => ({ type: "task", task })),
|
entries: siblings.map((task) => ({ type: "task", task })),
|
||||||
|
|
@ -226,8 +220,6 @@ function getTaskCategoryGroups(tasks, parentMap, parentId, sortMode, categoryOrd
|
||||||
category,
|
category,
|
||||||
tasks: siblings.filter((task) => getTaskCategoryForParent(task, tasks, parentMap, parentId) === category)
|
tasks: siblings.filter((task) => getTaskCategoryForParent(task, tasks, parentMap, parentId) === category)
|
||||||
})).filter((group) => group.tasks.length);
|
})).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 renderedCategories = new Set();
|
||||||
const entries = siblings.map((task) => {
|
const entries = siblings.map((task) => {
|
||||||
const category = getTaskCategoryForParent(task, tasks, parentMap, parentId);
|
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 || ""),
|
getTargetId: (target) => target.dataset.taskId || getCategorySectionId(target.dataset.parentId || "", target.dataset.category || ""),
|
||||||
canDropOn: (target, draggingTaskId) => {
|
canDropOn: (target, draggingTaskId) => {
|
||||||
const draggingTask = data.tasks.find((task) => task.id === 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")) {
|
if (target.classList.contains("task-planner-category-section")) {
|
||||||
return !parentMap.get(draggingTaskId) && !getTaskCategory(draggingTask) && !target.dataset.parentId && Boolean(target.dataset.category);
|
return !parentMap.get(draggingTaskId) && !getTaskCategory(draggingTask) && !target.dataset.parentId && Boolean(target.dataset.category);
|
||||||
}
|
}
|
||||||
return data.sortMode === "manual"
|
return target.dataset.parentId === (parentMap.get(draggingTaskId) || "")
|
||||||
&& target.dataset.parentId === (parentMap.get(draggingTaskId) || "")
|
|
||||||
&& (
|
&& (
|
||||||
target.dataset.category === getTaskCategoryDataset(draggingTask, data.tasks, parentMap)
|
target.dataset.category === getTaskCategoryDataset(draggingTask, data.tasks, parentMap)
|
||||||
|| (!parentMap.get(draggingTaskId) && !getTaskCategory(draggingTask) && Boolean(target.dataset.category))
|
|| (!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-module">
|
||||||
<div className="task-planner-topbar">
|
<div className="task-planner-topbar">
|
||||||
<div className="task-planner-global-controls">
|
<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
|
<button
|
||||||
className={`tool-split-scroll-toggle task-planner-hide-completed-toggle ${data.hideCompleted ? "active" : ""}`}
|
className={`tool-split-scroll-toggle task-planner-hide-completed-toggle ${data.hideCompleted ? "active" : ""}`}
|
||||||
type="button"
|
type="button"
|
||||||
|
|
@ -624,7 +604,7 @@ function TaskPlannerBranch({
|
||||||
onToggleCategoryCollapsed,
|
onToggleCategoryCollapsed,
|
||||||
visited = new Set()
|
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));
|
const children = [...groupedTasks.uncategorized, ...groupedTasks.categories.flatMap((group) => group.tasks)].filter((task) => !visited.has(task.id));
|
||||||
if (!children.length) return null;
|
if (!children.length) return null;
|
||||||
const nextVisited = new Set([...visited, ...children.map((task) => task.id)]);
|
const nextVisited = new Set([...visited, ...children.map((task) => task.id)]);
|
||||||
|
|
@ -632,11 +612,11 @@ function TaskPlannerBranch({
|
||||||
function hasVisibleDescendants(taskId, seen = new Set()) {
|
function hasVisibleDescendants(taskId, seen = new Set()) {
|
||||||
if (seen.has(taskId)) return false;
|
if (seen.has(taskId)) return false;
|
||||||
seen.add(taskId);
|
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) {
|
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 ? (
|
const nestedBranch = nestedChildren.length ? (
|
||||||
<TaskPlannerBranch
|
<TaskPlannerBranch
|
||||||
parentId={task.id}
|
parentId={task.id}
|
||||||
|
|
@ -855,9 +835,8 @@ function TaskPlannerItem({
|
||||||
className="task-planner-drag-handle"
|
className="task-planner-drag-handle"
|
||||||
type="button"
|
type="button"
|
||||||
onPointerDown={(event) => onDragStart(event, task.id)}
|
onPointerDown={(event) => onDragStart(event, task.id)}
|
||||||
disabled={data.sortMode !== "manual"}
|
|
||||||
aria-label={`${textContent.reorderTitle || "Déplacer"} ${task.title}`}
|
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" />
|
<Icon name="drag" />
|
||||||
</button>
|
</button>
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ const TIMER_TABS = new Set(["stopwatch", "countdown"]);
|
||||||
const COUNTDOWN_TYPES = new Set(["duration", "daily_time", "time_pattern", "interval"]);
|
const COUNTDOWN_TYPES = new Set(["duration", "daily_time", "time_pattern", "interval"]);
|
||||||
const TIMER_ALERT_MODES = new Set(["off", "visible", "site"]);
|
const TIMER_ALERT_MODES = new Set(["off", "visible", "site"]);
|
||||||
const TASK_TYPES = new Set(["unique", "daily", "weekly"]);
|
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_WEEKLY_RESET_DAY = 1;
|
||||||
const DEFAULT_TASK_PLANNER_RESET_TIME = "00:00";
|
const DEFAULT_TASK_PLANNER_RESET_TIME = "00:00";
|
||||||
const TOOLBOX_ICON_BASE = "/static/img/toolbox-icons/";
|
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 taskIds = new Set(tasks.map((task) => task.id));
|
||||||
const categoryOrder = normalizeTaskPlannerCategoryOrder(data?.categoryOrder, tasks);
|
const categoryOrder = normalizeTaskPlannerCategoryOrder(data?.categoryOrder, tasks);
|
||||||
return {
|
return {
|
||||||
sortMode: TASK_SORT_MODES.has(data?.sortMode) ? data.sortMode : "manual",
|
|
||||||
weeklyResetDay: normalizeWeekDay(data?.weeklyResetDay),
|
weeklyResetDay: normalizeWeekDay(data?.weeklyResetDay),
|
||||||
resetTime: isClockTimeString(data?.resetTime) ? data.resetTime : DEFAULT_TASK_PLANNER_RESET_TIME,
|
resetTime: isClockTimeString(data?.resetTime) ? data.resetTime : DEFAULT_TASK_PLANNER_RESET_TIME,
|
||||||
lastResetAt: normalizeTimestamp(data?.lastResetAt),
|
lastResetAt: normalizeTimestamp(data?.lastResetAt),
|
||||||
|
|
@ -536,7 +534,6 @@ export function compactModuleDataForStorage(type, value) {
|
||||||
if (type === "taskPlanner") {
|
if (type === "taskPlanner") {
|
||||||
const normalized = normalizeTaskPlannerData(value);
|
const normalized = normalizeTaskPlannerData(value);
|
||||||
const compact = {};
|
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.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.resetTime !== DEFAULT_TASK_PLANNER_RESET_TIME) compact.resetTime = normalized.resetTime;
|
||||||
if (normalized.lastResetAt) compact.lastResetAt = normalized.lastResetAt;
|
if (normalized.lastResetAt) compact.lastResetAt = normalized.lastResetAt;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue