add categories to task planner
All checks were successful
Deploy Sokko G / deploy (push) Successful in 6s

This commit is contained in:
Shinuwa 2026-07-28 09:32:14 +02:00
parent e306bfc5d6
commit 3cd350c7b8
10 changed files with 459 additions and 120 deletions

View file

@ -211,15 +211,18 @@ export function validateSiteContent(site) {
"toolboxes.modules.taskPlanner.showDescriptionTitle",
"toolboxes.modules.taskPlanner.hideDescriptionTitle",
"toolboxes.modules.taskPlanner.taskSettingsTitle",
"toolboxes.modules.taskPlanner.missingDependencyTitle",
"toolboxes.modules.taskPlanner.missingDependencyBadge",
"toolboxes.modules.taskPlanner.missingDependencyNotice",
"toolboxes.modules.taskPlanner.missingPrerequisiteTitle",
"toolboxes.modules.taskPlanner.missingPrerequisiteBadge",
"toolboxes.modules.taskPlanner.missingPrerequisiteNotice",
"toolboxes.modules.taskPlanner.categoryLabel",
"toolboxes.modules.taskPlanner.categoryPlaceholder",
"toolboxes.modules.taskPlanner.categoryReorderTitle",
"toolboxes.modules.taskPlanner.taskWeeklyResetDayLabel",
"toolboxes.modules.taskPlanner.inheritWeeklyResetDay",
"toolboxes.modules.taskPlanner.linksLabel",
"toolboxes.modules.taskPlanner.emptyLinks",
"toolboxes.modules.taskPlanner.addLinkLabel",
"toolboxes.modules.taskPlanner.dependencyCheckboxLabel",
"toolboxes.modules.taskPlanner.prerequisiteCheckboxLabel",
"toolboxes.modules.taskPlanner.removeRelationTitle",
"toolboxes.modules.taskPlanner.emptyTasks",
"toolboxes.modules.imageAnnotation.addImage",

View file

@ -141,7 +141,9 @@ test("toolbox module registry and modules expose expected behavior", async () =>
assert.match(taskPlannerModule, /normalizeTaskPlannerData/);
assert.match(taskPlannerModule, /applyDueResets/);
assert.match(taskPlannerModule, /relations/);
assert.match(taskPlannerModule, /dependency/);
assert.match(taskPlannerModule, /prerequisite/);
assert.match(taskPlannerModule, /categoryOrder/);
assert.match(taskPlannerModule, /categoryLabel/);
assert.match(taskPlannerModule, /task-planner-warning/);
assert.match(taskPlannerModule, /usePointerReorder/);
assert.match(checklistModule, /export function ChecklistModule/);

View file

@ -33,14 +33,15 @@ test("task planner data normalizes invalid settings and relations", () => {
sortMode: "unknown",
weeklyResetDay: 9,
resetTime: "27:80",
categoryOrder: ["Raid", "Missing", "Farm", "Raid"],
tasks: [
{ id: "task1", title: "Daily", type: "daily", checked: true, checkedAt: 1000 },
{ id: "task2", title: "Weekly", type: "weekly", weeklyResetDay: 4 },
{ id: "task3", title: "Invalid type", type: "later" }
{ id: "task1", title: "Daily", type: "daily", checked: true, checkedAt: 1000, category: "Farm" },
{ id: "task2", title: "Weekly", type: "weekly", weeklyResetDay: 4, category: "Raid" },
{ id: "task3", title: "Invalid type", type: "later", category: "Farm" }
],
relations: [
{ id: "link1", fromTaskId: "task1", toTaskId: "task2" },
{ id: "dep1", fromTaskId: "task2", toTaskId: "task1", dependency: true },
{ id: "dep1", fromTaskId: "task3", toTaskId: "task2", prerequisite: true },
{ id: "bad", fromTaskId: "task1", toTaskId: "missing" },
{ id: "self", fromTaskId: "task2", toTaskId: "task2" }
]
@ -49,29 +50,16 @@ 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.deepEqual(normalized.categoryOrder, ["Raid"]);
assert.equal(normalized.tasks[0].category, undefined);
assert.equal(normalized.tasks[1].weeklyResetDay, 4);
assert.equal(normalized.tasks[1].category, "Raid");
assert.equal(normalized.tasks[2].type, "unique");
assert.deepEqual(normalized.relations.map((relation) => relation.id), ["link1", "dep1"]);
assert.equal(normalized.relations[0].dependency, false);
assert.equal(normalized.relations[1].dependency, true);
assert.equal(normalized.relations[0].prerequisite, false);
assert.equal(normalized.relations[1].prerequisite, true);
});
test("task planner accepts temporary split links data as combined relations", () => {
const normalized = normalizeTaskPlannerData({
tasks: [
{ id: "task1", title: "Daily", type: "daily" },
{ id: "task2", title: "Weekly", type: "weekly" }
],
links: [{ id: "link1", fromTaskId: "task1", toTaskId: "task2" }],
dependencies: [{ id: "dep1", fromTaskId: "task2", toTaskId: "task1" }]
});
assert.deepEqual(normalized.relations.map((relation) => relation.toTaskId), ["task2", "task1"]);
assert.equal(normalized.relations[0].dependency, false);
assert.equal(normalized.relations[1].dependency, true);
});
test("task planner storage compacts defaults and export remaps task relations", () => {
const compact = compactModuleDataForStorage("taskPlanner", {
sortMode: "type",
@ -79,18 +67,20 @@ test("task planner storage compacts defaults and export remaps task relations",
resetTime: "00:00",
tasks: [
{ id: "task1", title: "Daily", description: "", type: "daily", checked: false },
{ id: "task2", title: "Weekly", description: "Run", type: "weekly", checked: true, checkedAt: 2000, weeklyResetDay: 5 }
{ id: "task2", title: "Weekly", description: "Run", type: "weekly", checked: true, checkedAt: 2000, weeklyResetDay: 5, category: "Raid" }
],
categoryOrder: ["Raid"],
relations: [
{ id: "link1", fromTaskId: "task1", toTaskId: "task2", dependency: false },
{ id: "dep1", fromTaskId: "task2", toTaskId: "task1", dependency: true }
{ id: "dep1", fromTaskId: "task1", toTaskId: "task2", prerequisite: true }
]
});
assert.equal(compact.sortMode, "type");
assert.equal(compact.weeklyResetDay, undefined);
assert.equal(compact.resetTime, undefined);
assert.deepEqual(compact.categoryOrder, ["Raid"]);
assert.deepEqual(compact.tasks[0], { id: "task1", title: "Daily", type: "daily" });
assert.equal(compact.tasks[1].category, "Raid");
assert.equal(compact.tasks[1].weeklyResetDay, 5);
const exported = createToolboxExportPayload(
@ -101,8 +91,5 @@ test("task planner storage compacts defaults and export remaps task relations",
assert.deepEqual(exportedPlanner.tasks.map((task) => task.id), ["a1", "a2"]);
assert.equal(exportedPlanner.relations[0].fromTaskId, "a1");
assert.equal(exportedPlanner.relations[0].toTaskId, "a2");
assert.equal(exportedPlanner.relations[0].dependency, undefined);
assert.equal(exportedPlanner.relations[1].fromTaskId, "a2");
assert.equal(exportedPlanner.relations[1].toTaskId, "a1");
assert.equal(exportedPlanner.relations[1].dependency, true);
assert.equal(exportedPlanner.relations[0].prerequisite, true);
});