Skip to main content

assignUser()

Description

Assigns a user to the specified task

Usage

assignUser({
id: string | number,
userId: string | number
}): void;

Parameters

  • id - (required) the id of the task
  • userId - (required) the id of the user to be assigned to the task

Example

const { ToDo, Toolbar } = todo;

// create To do list
const list = new ToDo("#root", {
tasks: [
{ id: "1", text: "Task 1" },
{ 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" },
],
users: [
{ "id": "user_1", "label": "John" },
{ "id": "user_2", "label": "Kate" },
]
});

const toolbar = new Toolbar("#toolbar", {
api: list.api,
});

// assign a user to the task
list.assignUser({
id: "1.1",
userId: "user_2"
});

Related article: Task users