Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
custom task states: add aliases, rename stateName label to stateId
Adorian Doran56ad70f2f8a0
diff --git a/apps/client/src/services/task_states.ts b/apps/client/src/services/task_states.tsindex 1d2fa7b42d..6e4b5b8c7a 100644--- a/apps/client/src/services/task_states.ts+++ b/apps/client/src/services/task_states.ts@@ -54,7 +54,7 @@ export async function getTaskStateDefinitions(): Promise<TaskStateDef[]> {}return {id: note.noteId,- name: note.getLabelValue("stateName") ?? "",+ name: note.getLabelValue("stateId") ?? "",title: note.title,markdownSymbol: note.getLabelValue("markdownSymbol") ?? "",isCompleted: note.getLabelValue("isCompleted") === "true",diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex 3a806e6910..9752bfb9c3 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -2663,9 +2663,9 @@"unknown-task-state": "Undefined custom task state","task-state-dropped": "Dropped custom task state definition \"{{title}}\" ({{id}}) due to: {{reason}}","validation-errors": {- "undefined-name": "undefined stateName",- "invalid-name": "invalid stateName",- "duplicate-name": "duplicate stateName",+ "undefined-name": "undefined identifier",+ "invalid-name": "invalid identifier",+ "duplicate-name": "duplicate identifier","missing-title": "missing title","missing-icon": "missing icon","invalid-symbol": "the markdown symbol should be one character, excepting \"[\", \" \", \"X\", and \"]\"",diff --git a/apps/server/src/assets/translations/en/server.json b/apps/server/src/assets/translations/en/server.jsonindex f3d74bcb39..a089663ee0 100644--- a/apps/server/src/assets/translations/en/server.json+++ b/apps/server/src/assets/translations/en/server.json@@ -284,6 +284,11 @@"task-state-done": "Done","task-state-maybe": "Maybe","task-state-cancelled": "Cancelled",+ "task-state-attr-state-id": "Identifier (required)",+ "task-state-attr-markdown-symbol": "Markdown symbol",+ "task-state-attr-is-completed": "Counts as completed",+ "task-state-attr-color": "Color",+ "task-state-attr-is-hidden": "Hidden from list","backend-log-title": "Backend Log","custom-dictionary-title": "Custom Dictionary","user-hidden-title": "User Hidden",diff --git a/packages/commons/src/lib/task_states.ts b/packages/commons/src/lib/task_states.tsindex ce6ec7af52..e9e043ae26 100644--- a/packages/commons/src/lib/task_states.ts+++ b/packages/commons/src/lib/task_states.ts@@ -9,7 +9,7 @@export interface TaskStateDef {/** The state note's id (used in validation messages; absent on hardcoded fallbacks). */id?: string;- /** The `stateName` label value — used verbatim as the `data-trilium-task-state` attribute. */+ /** The `stateId` label value — used verbatim as the `data-trilium-task-state` attribute. */name: string;/** Human-readable display name (the state note's title). */title: string;@@ -101,7 +101,7 @@ export interface TaskStateValidationResult {errors: TaskStateValidationError[];}-/** `stateName` is embedded in HTML attributes, CSS selectors and JSON — keep it strictly safe. */+/** The `stateId` is embedded in HTML attributes, CSS selectors and JSON — keep it strictly safe. */const VALID_STATE_NAME_PATTERN = /^[A-Za-z0-9_-]+$/;/** Symbols reserved by the markdown task-list syntax `- [ ]` / `- [x]`. */const FORBIDDEN_MARKDOWN_SYMBOLS = new Set(["[", "]", " ", "x", "X"]);diff --git a/packages/trilium-core/src/services/hidden_subtree.ts b/packages/trilium-core/src/services/hidden_subtree.tsindex bad2e5d7a5..d7aa408fd8 100644--- a/packages/trilium-core/src/services/hidden_subtree.ts+++ b/packages/trilium-core/src/services/hidden_subtree.ts@@ -92,11 +92,11 @@ function buildHiddenSubtreeDefinition(helpSubtree: HiddenSubtreeItem[]): HiddenSicon: "bx-list-check",isExpanded: true,attributes: [- { type: "label", name: "child:label:stateName", value: "promoted,single,text" },- { type: "label", name: "child:label:markdownSymbol", value: "promoted,single,text" },- { type: "label", name: "child:label:isCompleted", value: "promoted,single,boolean" },- { type: "label", name: "child:label:color", value: "promoted,single,color" },- { type: "label", name: "child:label:isHidden", value: "promoted,single,boolean" }+ { type: "label", name: "child:label:stateId", value: `promoted,single,text,alias=${t("hidden-subtree.task-state-attr-state-id")}` },+ { type: "label", name: "child:label:markdownSymbol", value: `promoted,single,text,alias=${t("hidden-subtree.task-state-attr-markdown-symbol")}` },+ { type: "label", name: "child:label:isCompleted", value: `promoted,single,boolean,alias=${t("hidden-subtree.task-state-attr-is-completed")}` },+ { type: "label", name: "child:label:color", value: `promoted,single,color,alias=${t("hidden-subtree.task-state-attr-color")}` },+ { type: "label", name: "child:label:isHidden", value: `promoted,single,boolean,alias=${t("hidden-subtree.task-state-attr-is-hidden")}` }],// Non-customizable anchor states — recreated if missing; they only// determine where `none`/`done` sit in the toolbar/cycling order.diff --git a/packages/trilium-core/src/services/task_states.ts b/packages/trilium-core/src/services/task_states.tsindex d2900e1919..16b77cc054 100644--- a/packages/trilium-core/src/services/task_states.ts+++ b/packages/trilium-core/src/services/task_states.ts@@ -35,7 +35,7 @@ export function getTaskStates(): TaskStateDef[] {}return {id: note.noteId,- name: note.getLabelValue("stateName") ?? "",+ name: note.getLabelValue("stateId") ?? "",title: note.title,markdownSymbol: note.getLabelValue("markdownSymbol") ?? "",isCompleted: note.getLabelValue("isCompleted") === "true",@@ -67,7 +67,7 @@ export function createTaskStateNote(state: TaskStateDef, options: {noteId?: striconst labels: Record<string, string> = {iconClass: state.icon,- stateName: state.name,+ stateId: state.name,markdownSymbol: state.markdownSymbol,isCompleted: String(state.isCompleted),color: state.color