Add planner-aware memos and unified tool configuration panels
All checks were successful
Deploy Sokko G / deploy (push) Successful in 18s
All checks were successful
Deploy Sokko G / deploy (push) Successful in 18s
This commit is contained in:
parent
acd9b2fe11
commit
808610dcf2
53 changed files with 842 additions and 329 deletions
62
website/src/features/toolboxes/modules/memosPlannerUtils.js
Normal file
62
website/src/features/toolboxes/modules/memosPlannerUtils.js
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
// Rôle : résout les liaisons de Mémos vers les planificateurs et produit leurs alertes de reset.
|
||||
import { normalizeTaskPlannerData } from "../storage/modules/taskPlanner.js";
|
||||
import {
|
||||
applyDueResets,
|
||||
getEffectiveTaskCategory,
|
||||
getTaskParentMap,
|
||||
isTaskResetSoon
|
||||
} from "./taskPlannerUtils.js";
|
||||
|
||||
export const ALL_TASK_PLANNERS_LINK = "all";
|
||||
|
||||
export function getTaskPlannerModules(modules) {
|
||||
return (Array.isArray(modules) ? modules : []).filter((module) => module.type === "taskPlanner");
|
||||
}
|
||||
|
||||
export function resolveMemosPlannerLink(plannerLink, modules) {
|
||||
const value = String(plannerLink || "");
|
||||
const planners = getTaskPlannerModules(modules);
|
||||
if (value === ALL_TASK_PLANNERS_LINK) return planners.length ? value : "";
|
||||
return planners.some((planner) => planner.id === value) ? value : "";
|
||||
}
|
||||
|
||||
export function getLinkedTaskPlannerModules(plannerLink, modules) {
|
||||
const planners = getTaskPlannerModules(modules);
|
||||
if (plannerLink === ALL_TASK_PLANNERS_LINK) return planners;
|
||||
return planners.filter((planner) => planner.id === plannerLink);
|
||||
}
|
||||
|
||||
export function getMemosDataAfterPlannerRemoval(data, removedPlannerId, remainingModules) {
|
||||
const remainingPlanners = getTaskPlannerModules(remainingModules);
|
||||
const link = String(data?.plannerLink || "");
|
||||
if (link === removedPlannerId || (link === ALL_TASK_PLANNERS_LINK && !remainingPlanners.length)) {
|
||||
return { ...data, plannerLink: "" };
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
function formatTaskAlert(task, category, template) {
|
||||
return String(template || "Tâche : {category}{title} expire bientôt")
|
||||
.replace("{category}", category ? `${category} ` : "")
|
||||
.replace("{title}", task.title);
|
||||
}
|
||||
|
||||
export function getPlannerTaskTickerItems({
|
||||
plannerLink,
|
||||
modules,
|
||||
getPlannerData,
|
||||
nowMs = Date.now(),
|
||||
alertTemplate
|
||||
}) {
|
||||
return getLinkedTaskPlannerModules(plannerLink, modules).flatMap((planner) => {
|
||||
const data = applyDueResets(normalizeTaskPlannerData(getPlannerData(planner.id)), nowMs);
|
||||
const parentMap = getTaskParentMap(data.tasks, data.relations);
|
||||
return data.tasks
|
||||
.filter((task) => isTaskResetSoon(task, data, nowMs))
|
||||
.map((task) => ({
|
||||
id: `planner:${planner.id}:${task.id}`,
|
||||
kind: "task-warning",
|
||||
text: formatTaskAlert(task, getEffectiveTaskCategory(task, data.tasks, parentMap), alertTemplate)
|
||||
}));
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue