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: rename "checkboxValue" to "isCompleted"
Adorian Doran35ec4171ffa5
diff --git a/apps/client/src/services/task_states.ts b/apps/client/src/services/task_states.tsindex c9cc5cdf14..f4306ce5f8 100644--- a/apps/client/src/services/task_states.ts+++ b/apps/client/src/services/task_states.ts@@ -50,7 +50,7 @@ export async function getTaskStateDefinitions(): Promise<TaskStateDef[]> {name: note.getLabelValue("stateName") ?? "",title: note.title,markdownSymbol: note.getLabelValue("markdownSymbol") ?? "",- checkboxValue: note.getLabelValue("checkboxValue") === "true",+ isCompleted: note.getLabelValue("isCompleted") === "true",color: note.getLabelValue("color") ?? "",icon: note.getLabelValue("iconClass") ?? "",archived: note.isArchiveddiff --git a/packages/ckeditor5/src/plugins/todo_list_multistate/todo_list_multistate_editing.ts b/packages/ckeditor5/src/plugins/todo_list_multistate/todo_list_multistate_editing.tsindex f140095ed1..c5228492cb 100644--- a/packages/ckeditor5/src/plugins/todo_list_multistate/todo_list_multistate_editing.ts+++ b/packages/ckeditor5/src/plugins/todo_list_multistate/todo_list_multistate_editing.ts@@ -117,7 +117,7 @@ export default class TodoListMultistateEditing extends Plugin {let changed = false;- // A customizable state forces the checkbox to its `checkboxValue`.+ // A customizable state forces the checkbox to its `isCompleted`.for (const el of stateChanged) {const stateName = el.getAttribute(TASK_STATE_ATTRIBUTE);const state = typeof stateName === "string" ? stateByName.get(stateName) : undefined;@@ -125,8 +125,8 @@ export default class TodoListMultistateEditing extends Plugin {// State cleared — the command already set the native checkbox.continue;}- if (!!el.getAttribute(TODO_LIST_CHECKED_ATTRIBUTE) !== state.checkboxValue) {- writer.setAttribute(TODO_LIST_CHECKED_ATTRIBUTE, state.checkboxValue, el);+ if (!!el.getAttribute(TODO_LIST_CHECKED_ATTRIBUTE) !== state.isCompleted) {+ writer.setAttribute(TODO_LIST_CHECKED_ATTRIBUTE, state.isCompleted, el);changed = true;}}diff --git a/packages/commons/src/lib/task_states.spec.ts b/packages/commons/src/lib/task_states.spec.tsindex c27a9fdde3..f4c1a58838 100644--- a/packages/commons/src/lib/task_states.spec.ts+++ b/packages/commons/src/lib/task_states.spec.ts@@ -8,7 +8,7 @@ function customState(overrides: Partial<TaskStateDef>): TaskStateDef {name: "doing",title: "Doing",markdownSymbol: "/",- checkboxValue: false,+ isCompleted: false,color: "",icon: "bx bx-loader",...overridesdiff --git a/packages/commons/src/lib/task_states.ts b/packages/commons/src/lib/task_states.tsindex 75448f525d..ece0c569b6 100644--- a/packages/commons/src/lib/task_states.ts+++ b/packages/commons/src/lib/task_states.ts@@ -15,8 +15,8 @@ export interface TaskStateDef {title: string;/** Single-character markdown marker, e.g. `/` for `- [/]`. */markdownSymbol: string;- /** Whether the checkbox renders as checked while in this state. */- checkboxValue: boolean;+ /** Indicates whether the task is completed in this state. */+ isCompleted: boolean;/** CSS color associated with the state, e.g. `#e6a23c`. */color: string;/** Icon class, e.g. `bx bx-loader`. */@@ -44,12 +44,12 @@ export function isAnchorState(name: string): boolean {/** The built-in unchecked anchor state. */export const NONE_TASK_STATE: TaskStateDef = {- id: NONE_STATE_ID, name: NONE_STATE_NAME, title: "None", markdownSymbol: " ", checkboxValue: false, color: "", icon: "bx bx-checkbox"+ id: NONE_STATE_ID, name: NONE_STATE_NAME, title: "None", markdownSymbol: " ", isCompleted: false, color: "", icon: "bx bx-checkbox"};/** The built-in checked anchor state. */export const DONE_TASK_STATE: TaskStateDef = {- id: DONE_STATE_ID, name: DONE_STATE_NAME, title: "Done", markdownSymbol: "x", checkboxValue: true, color: "#4de64d", icon: "bx bx-check"+ id: DONE_STATE_ID, name: DONE_STATE_NAME, title: "Done", markdownSymbol: "x", isCompleted: true, color: "#4de64d", icon: "bx bx-check"};/**@@ -57,9 +57,9 @@ export const DONE_TASK_STATE: TaskStateDef = {* installation.*/export const DEFAULT_CUSTOM_TASK_STATES: TaskStateDef[] = [- {id: "_taskStateDoing", name: "doing", title: "Doing", markdownSymbol: "/", checkboxValue: false, color: "#e6a23c", icon: "bx bx-loader"},- {id: "_taskStateMaybe", name: "maybe", title: "Maybe", markdownSymbol: "?", checkboxValue: false, color: "#4d4de6", icon: "bx bx-question-mark"},- {id: "_taskStateCancelled", name: "cancelled", title: "Cancelled", markdownSymbol: "-", checkboxValue: false, color: "#e64d4d", icon: "bx bx-block"}+ {id: "_taskStateDoing", name: "doing", title: "Doing", markdownSymbol: "/", isCompleted: false, color: "#e6a23c", icon: "bx bx-loader"},+ {id: "_taskStateMaybe", name: "maybe", title: "Maybe", markdownSymbol: "?", isCompleted: false, color: "#4d4de6", icon: "bx bx-question-mark"},+ {id: "_taskStateCancelled", name: "cancelled", title: "Cancelled", markdownSymbol: "-", isCompleted: false, color: "#e64d4d", icon: "bx bx-block"}];/**diff --git a/packages/trilium-core/src/services/hidden_subtree.ts b/packages/trilium-core/src/services/hidden_subtree.tsindex 892b279613..5423c28c69 100644--- a/packages/trilium-core/src/services/hidden_subtree.ts+++ b/packages/trilium-core/src/services/hidden_subtree.ts@@ -94,7 +94,7 @@ function buildHiddenSubtreeDefinition(helpSubtree: HiddenSubtreeItem[]): HiddenSattributes: [{ 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:checkboxValue", value: "promoted,single,bool" },+ { type: "label", name: "child:label:isCompleted", value: "promoted,single,bool" },{ type: "label", name: "child:label:color", value: "promoted,single,text" }],// Non-customizable anchor states — recreated if missing; they onlydiff --git a/packages/trilium-core/src/services/task_states.ts b/packages/trilium-core/src/services/task_states.tsindex 50fa2fb685..19064a55e8 100644--- a/packages/trilium-core/src/services/task_states.ts+++ b/packages/trilium-core/src/services/task_states.ts@@ -32,7 +32,7 @@ export function getTaskStates(): TaskStateDef[] {name: note.getLabelValue("stateName") ?? "",title: note.title,markdownSymbol: note.getLabelValue("markdownSymbol") ?? "",- checkboxValue: note.getLabelValue("checkboxValue") === "true",+ isCompleted: note.getLabelValue("isCompleted") === "true",color: note.getLabelValue("color") ?? "",icon: note.getLabelValue("iconClass") ?? "",archived: note.isArchived@@ -62,7 +62,7 @@ export function createTaskStateNote(state: TaskStateDef, options: {noteId?: striiconClass: state.icon,stateName: state.name,markdownSymbol: state.markdownSymbol,- checkboxValue: String(state.checkboxValue),+ isCompleted: String(state.isCompleted),color: state.color};