ToDo widget expects a backend server to fetch tasks, projects and users. You can provide a link to it by the url setting:
webix.ui({
view: "todo",
url:"https://docs.webix.com/todo-backend/"
});
ToDo will load and save data using the next URLs:
Sample backend for ToDo is available for downloading.
If you do not have a backend server, you can customize the methods of the Backend service and provide client-side data as a promise.
Backend service is a server-side model that contains methods for sending requests. They are called by the Operations service when data needs to be loaded or saved.
Check out the full list of methods below.
To change data requests, get and process the responses you can:
class MyBackend extends todo.services.Backend {
// define and override methods here
}
webix.ui({
view: "todo",
url:"http://localhost:3200/",
override: new Map([[todo.services.Backend, MyBackend]]),
});
You can send AJAX requests to your server by using the needed URLs, e.g.:
Adding a task
class MyBackend extends todo.services.Backend {
addTask(task) {
return webix.ajax.post("//localhost:3200/tasks", task)
.then(res => res.json());
}
}
Below you can find descriptions of the following methods:
Is used to get all available tasks.
Returns: a promise.
Request:
GET http://localhost:3000/tasks
Response:
The server returns an array of tasks:
[
{
id: 1,
text: "Learn about Webix",
checked: true,
assigned: ["user_1", "user_2", "user_3", "user_4"],
project: "First project",
parent: 0,
},
// other tasks
]
Is used to get all tasks from a specific project.
Parameters:
Returns: a promise.
Request:
GET http://localhost:3000/tasks/projects/${id}
Response:
The server returns an array of tasks for a specific project:
[
{
id: 6,
text: "Data Presentation",
checked: true,
project: "ui",
parent: 0,
},
// other tasks
]
Adds a new task to the server.
Parameters:
Returns: a promise that resolves with an object containing the ID of the new event.
Request:
POST http://localhost:3000/tasks
Raw JSON
{
"project": 7,
"parent": 0,
"after": 12 // (previous element id)
}
Response:
The server returns an object containing the ID of the new task:
{id: 5}
Updates a specified task.
Parameters:
Returns: a promise.
Request:
PUT http://localhost:3000/tasks/${id}
Raw JSON (obj with new fields)
{
“id”: 6,
“text”: "Data Presentation",
“checked”: true,
“project”: "ui",
“parent”: 0
}
Response:
The server returns an object containing empty ID:
{ “id”: 0 }
Removes a specified task.
Parameters:
Returns: a promise.
Request:
DELETE http://localhost:3000/tasks/${id}
Response:
The server returns an object containing empty ID:
{ “id”: 0 }
Is called to move a task to a different project.
Parameters:
Returns: a promise.
Request:
PUT http://localhost:3000/move/${id}
Response:
The server returns an object containing empty ID:
{ “id”: 0 }
Is called to indent a task.
Parameters:
Returns: a promise.
Request:
PUT http://localhost:3000/indent/${id}
Raw JSON:
{
“parent”: 5
}
Response:
The server returns an object containing empty ID:
{ “id”: 0 }
Is called to indent a task.
Parameters:
Returns: a promise.
Request:
PUT http://localhost:3000/unindent/${id}
Raw JSON:
{
“parent”: 4
}
Response:
The server returns an object containing empty ID:
{ “id”: 0 }
Is called to clone a task.
Parameters:
Returns: a promise.
Request:
POST http://localhost:3000/clone
Raw JSON
{
“after”: 1,
“parent”: 2,
“project”: 1,
“batch”: [
{
“id”: “task1”,
“text”: "Learn about Webix",
“checked”: true,
“assigned”: ["user_1", "user_2", "user_3", "user_4"],
“project”: "First project",
“parent”: 0,
},
// other tasks
]
}
Response: an array containing the server IDs of the cloned tasks.
Is used to get all available projects.
Request:
GET http://localhost:3000/projects
Returns: an array of projects.
Response:
The server returns an array of projects:
[
{ id: "ui",
value: "UI Widgets"
},
// other projects
]
Adds a new project.
Parameters:
Returns: a promise that resolves with a project ID object.
Request:
POST http://localhost:3000/projects
Raw JSON:
{
“value”: “project name”
}
Response: The server returns a project ID object:
{"id":14}
Deletes a specified project.
Parameters:
Returns: a promise.
Request:
DELETE http://localhost:3000/projects/${id}
Response:
The server returns an object containing empty ID:
{ “id”: 0 }
Updates a specified project.
Parameters:
Returns: a promise.
Request:
PUT http://localhost:3000/projects/${id}
Raw JSON:
{
“value”: “new project name”
}
Response:
The server returns an object containing empty ID:
{ “id”: 0 }
Is used to get all users.
Request:
GET http://localhost:3000/users
Returns: an array of users.
Response:
The server returns an array of users:
[
{
id: "user_1",
value: "Don Smith",
path: "../common/img/user_1.jpg"
},
// other users
]
Back to top