TaskModel
Represents a single task on your TaskBoard, usually added to a TaskStore.
Customizing Task fields
The TaskModel has a few predefined fields as seen under Fields below. If you want to add new fields or change existing fields, you can do that by subclassing this class:
class MyTask extends TaskModel {
static get fields() {
return [
// Add a new field
{ name: 'myField', type : 'number', defaultValue : 0 }
];
}
...
}
// Instances of your class now has getters / setters defined for your field
const task = new MyTask();
console.log(task.myField); // => 0
If you want to use other names for any predefined field in your data, you can reconfigure them as seen below:
class MyTask extends TaskModel {
static get fields() {
return [
// Remap status -> state
{ name: 'status', dataSource : 'state' }
];
}
...
}
Configuring the Project to use a custom task model
Here's how you configure the Project to use a certain Model class:
const taskBoard = new TaskBoard({
// Configure the project to use our custom task model and to load data remotely
project : {
taskModelClass : MyTask,
autoLoad : true
transport : {
load : {
url : 'data/data.json'
}
}
}
});
Read-only tasks
A task can be flagged as read-only using the readOnly field. This protects it from being edited in the UI, but has no effect on the data layer.
Please refer to Model for additional details.
Fields
Fields belong to a Model class and define the Model data structure-
Set to
trueto make the task render as a small bar in the UI. Toggling this state via UI is done through the CollapseItem. -
Task description, by default shown in tasks body.
-
Task priority, can be used for sorting, or to link a task to a swimlane on the TaskBoard.
-
Task status, for example for linking a task to a column on the TaskBoard.
Properties
Properties are getters/setters or publicly accessible variables on this class-
Identifies an object as an instance of TaskModel class, or subclass thereof.
-
Identifies an object as an instance of TaskModel class, or subclass thereof.