indentTask()
Description
Demotes the nesting level of the task to one lower level, depending on the nearby task
Usage
indentTask({
id: string | number
}): void;
Parameters
id
- (required) the id of a task
Example
Example 1. Demoting the nesting level of one task
const { ToDo, Toolbar } = todo;
const list = new ToDo("#root", {
tasks: [
{ id: "1", text: "Task 1 #tag1" },
{ id: "1.1", text: "Task 1.1", parent: "1" },
{ id: "1.1.1", text: "Task 1.1.1", parent: "1.1" },
{ id: "1.2", text: "Task 1.2", parent: "1" },
]
});
const toolbar = new Toolbar("#toolbar", {
api: list.api,
});
// demote the nesting level of the task
list.indentTask({
id: "1.2",
});
console.log(list.getParentIds({ id: "1.2" })); // ['1.1', '1']
Example 2. Demoting the nesting level of multiple tasks
const list = new ToDo("#root", {
tasks: [
{ id: "1", text: "Task 1" },
{ id: "1.1", text: "Task 1.1"},
{ id: "1.1.1", text: "Task 1.1.1", parent: "1.1" },
{ id: "1.2", text: "Task 1.2", parent: "1" },
{ id: "2", text: "Task 2" },
{ id: "2.1", text: "Task 2.1", parent: "2" },
{ id: "2.1.1", text: "Task 2.1.1", parent: "2.1" },
{ id: "2.2", text: "Task 2.2" },
],
selected: ["1.1", "2.2"],
});
// demote the nesting level of selected tasks
list.eachSelected(id => {
list.indentTask({ id });
}, true);
Related articles: