ToDo is a complex widget created with Webix Jet, the MV* framework for Webix Library. It is a ready-to-use application that needs minimal configuration and has an API for redefining the logic of inner modules.
You need to study the source code to customize views and models.
ToDo is built as a Jet App and wrapped in a Webix view, so you can initialize it in either way.
The interface of ToDo is split into parts (views). Each view is a class that extends the JetView class and has its own handlers for setting the configuration and logic.
The sources for interface parts (Jet Views) are located in the sources/views folder.
views
active.js
add.js
...
windows
context.js
Go to the Class Map page to see the list of all Jet views in ToDo and where they are in the interface.
ToDo models contain the logic for loading and storing data, uploading avatars, working with templates etc. They are defined as Jet Services.
The sources for models (Jet Services) are located in the sources/models folder.
models
Backend.js
Helpers.js
Local.js
Operations.js
You can get services using getService() method:
$$('todo').getService('helpers');
When you customize a view, you can:
Check the Class Map to find which view renders the part you want to modify.
To start, create your own view class and inherit it from one of the default views or from todo.views.JetView:
class MyToolbar extends todo.views["toolbar"] {
config() {
//get JSON object with configuration
const ui = super.config();
... //some changes depending on a particular view
return ui;
}
init() {
// call default logic
super.init();
// custom logic below
this.doSomething();
}
doSomething() {
// do something on init
}
}
Then replace the default view via the override map:
webix.ui({
view: "todo",
data: base_data,
users: users,
projects: projects,
override: new Map([[todo.views["toolbar"], MyToolbar]])
})
We do not recommend removing any component from the interface as the inner logic might still try accessing it. Instead, hide the components.
class CustomToolbar extends todo.views["toolbar"] {
init(view) {
// default logic
super.init();
// hide a button
view.queryView('button').hide();
}
}
Within a Jet view, you can access component instances in two ways.
Use the $$(id) method of JetView for an inner component that has the localId setting:
init() {
// default logic
super.init();
// get instance of the component with "list" localId
const list = this.$$("list");
}
Use queryView if localId is not defined:
init(view) {
// default logic
super.init();
// get instance of the button
const button = view.queryView("button");
}
You can find out whether the app is currently compact from any view or service method:
const compact = this.getParam('compact', true);
You can get state properties from any view or service method:
const state = this.app.getState();
// or
const state = this.getParam('state');
By customizing Jet services, you can add and call your own methods. You can also override any existing method, but you should do it with caution.
The steps are the same as for customizing a view:
class MyBackend extends todo.services.Backend {
getModules() {
// client-side data
return webix.promise.resolve(modules);
}
}
override map.webix.ui({
view: "todo",
url: 'https://docs.webix.com/todo-backend/',
override: new Map([[todo.services.Backend, MyBackend]]),
});
ToDo is flexible. However, keep in mind the following:
Code for Edge Chromium must use a different syntax.