TaskEdit
Feature that displays a Task editor, allowing users to edit task data. The Task editor is a popup containing tabs with fields for editing task data.
This demo shows the task edit feature, double-click child task bar to start editing:
//<code-header>
fiddle.title = 'Task edit';
//</code-header>
const schedulerPro = new SchedulerPro({
appendTo : targetElement,
flex : '1 0 100%',
// Project contains all the data and is responsible for correct scheduling
project : {
events : [
{
id : 1,
name : 'Write docs',
expanded : true,
children : [
{ id : 2, name : 'Proof-read docs', startDate : '2017-01-02', endDate : '2017-01-05' },
{ id : 3, name : 'Release docs', startDate : '2017-01-09', endDate : '2017-01-10' }
]
}
],
resources : [
{ id : 1, name : 'Albert' },
{ id : 2, name : 'Bill' }
],
assignments : [
{ event : 2, resource : 1 },
{ event : 3, resource : 2 }
]
},
startDate : new Date(2016, 11, 31),
endDate : new Date(2017, 0, 11),
height : 250,
columns : [
{ field : 'name', text : 'Name' }
]
});Customizing tabs and their widgets
To customize tabs you can:
- Reconfigure built-in tabs by providing override configs in the items config.
- Remove existing tabs or add your own in the items config.
- Advanced: Reconfigure the whole editor widget using editorConfig or replace the whole editor using editorClass.
To add extra items to a tab you need to specify items for the tab container.
This demo shows adding of custom widgets to the task editor, double-click child task bar to start editing:
//<code-header>
fiddle.title = 'Task edit extra items';
//</code-header>
const schedulerPro = new SchedulerPro({
appendTo : targetElement,
flex : '1 0 100%',
// Project contains all the data and is responsible for correct scheduling
project : {
events : [
{
id : 1,
name : 'Write docs',
expanded : true,
children : [
{
id : 2,
name : 'Proof-read docs',
startDate : '2017-01-02',
endDate : '2017-01-05',
effort : 0
},
{ id : 3, name : 'Release docs', startDate : '2017-01-09', endDate : '2017-01-10', effort : 0 }
]
}
],
resources : [
{ id : 1, name : 'Albert' },
{ id : 2, name : 'Bill' }
],
assignments : [
{ event : 2, resource : 1 },
{ event : 3, resource : 2 }
]
},
startDate : new Date(2016, 11, 31),
endDate : new Date(2017, 0, 11),
height : 250,
features : {
taskEdit : {
items : {
// add some UI-elements to "General" tab
generalTab : {
items : {
customDivider : {
html : '',
weight : 610,
flex : '1 0 100%'
},
// text input field
milestoneField : {
type : 'text',
weight : 611,
readOnly : true,
editable : false,
label : 'My field',
name : 'milestone',
flex : '1 0 50%'
},
// a button
customButton : {
type : 'button',
weight : 612,
text : 'Button',
flex : '1 0 50%'
}
}
},
// hide "Notes" tab
notesTab : false
}
}
},
columns : [
{ field : 'name', text : 'Name' }
]
});Expand to see Default tabs and fields
The Task editor contains tabs by default. Each tab contains built-in widgets: text fields, grids, etc.
| Tab ref | Type | Text | Weight | Description |
|---|---|---|---|---|
generalTab |
SchedulerGeneralTab | General | 100 | Basic fields: name, resources, start/end dates, duration, percent done |
predecessorsTab |
PredecessorsTab | Predecessors | 200 | Shows a grid with incoming dependencies |
successorsTab |
SuccessorsTab | Successors | 300 | Shows a grid with outgoing dependencies |
advancedTab |
SchedulerAdvancedTab | Advanced | 500 | Shows advanced configuration: constraints and manual scheduling mode |
notesTab |
NotesTab | Notes | 600 | Shows a text area to add notes to the selected task |
General tab
General tab contains fields for basic configurations
| Field ref | Type | Text | Weight | Description |
|---|---|---|---|---|
nameField |
TextField | Name | 100 | Task name |
resourcesField |
Combo | Resources | 200 | Shows a list of available resources for this task |
startDateField |
DateTimeField | Start | 300 | Shows when the task begins |
endDateField |
DateTimeField | Finish | 400 | Shows when the task ends |
durationField |
DurationField | Duration | 500 | Shows how long the task is |
percentDoneField |
NumberField | % Complete | 600 | Shows what part of task is done already in percentage |
colorField ¹ |
EventColorField | Color ¹ | 700 | Choose background color for the task bar |
¹ Set the showTaskColorPickers config to true to enable this field
Predecessors tab
Predecessors tab contains a grid with incoming dependencies and controls to remove/add dependencies
| Widget ref | Type | Weight | Description |
|---|---|---|---|
grid |
Grid | 100 | Shows predecessors task name, dependency type and lag |
toolbar |
Toolbar | 200 | Shows control buttons |
>add |
Button | 210 | Adds a new predecessor. Then select a task from the list in the name column editor |
>remove |
Button | 220 | Removes selected incoming dependency |
- >
- first level of submenu
Successors tab
Successors tab contains a grid with outgoing dependencies and controls to remove/add dependencies
| Widget ref | Type | Weight | Description |
|---|---|---|---|
grid |
Grid | 100 | Shows successors task name, dependency type and lag |
toolbar |
Toolbar | 200 | Shows control buttons |
>add |
Button | 210 | Adds a new successor. Then select a task from the list in the name column editor |
>remove |
Button | 220 | Removes selected outgoing dependency |
- >
- first level of submenu
Advanced tab
Advanced tab contains additional task scheduling options
| Field ref | Type | Weight | Description |
|---|---|---|---|
calendarField |
CalendarField | 100 | List of available calendars for this task. Shown when calendars are downloaded |
constraintTypeField |
ConstraintTypePicker | 200 | Shows a list of available constraints for this task |
constraintDateField |
DateField | 300 | Shows a date for the selected constraint type |
manuallyScheduledField |
Checkbox | 400 | If checked, the task is not considered in scheduling |
inactiveField |
Checkbox | 500 | Allows inactivating the task so it won't take part in the scheduling process. |
ignoreResourceCalendarField |
Checkbox | 600 | If checked the event ignores the assigned resource calendars when scheduling |
Notes tab
Notes tab contains a text area to show notes
| Field ref | Type | Weight | Description |
|---|---|---|---|
noteField |
TextAreaField | 100 | Shows a text area to add text notes to the task |
The built-in buttons are:
| Widget ref | Type | Weight | Description |
|---|---|---|---|
saveButton |
Button | 100 | Save event button on the bbar |
deleteButton |
Button | 200 | Delete event button on the bbar |
cancelButton |
Button | 300 | Cancel event editing button on the bbar |
Removing a built-in item or toolbar button
To remove a built-in toolbar button, tab or field, specify its ref as false in the items config:
const scheduler = new SchedulerPro({
features : {
taskEdit : {
items : {
generalTab : {
items : {
// Remove "Duration" and "% Complete" fields in the "General" tab
durationField : false,
percentDoneField : false
}
},
// Remove all tabs except the "General" tab
notesTab : false,
predecessorsTab : false,
successorsTab : false,
advancedTab : false
},
editorConfig : {
bbar : {
// Remove delete button
items : {
deleteButton : false
}
}
}
}
}
})
Customizing a built-in item
To customize a built-in tab or field, use its ref as the key in the items config and specify the configs you want
to change (they will be merged with the tabs or fields default configs correspondingly):
const scheduler = new SchedulerPro({
features : {
taskEdit : {
items : {
generalTab : {
// Rename "General" tab
title : 'Main',
items : {
// Rename "% Complete" field
percentDoneField : {
label : 'Status'
}
}
}
}
}
}
})
Adding a custom item
To add a custom tab or field, add an entry to the items config. When you add a field,
the name property links the input field to a field in the loaded task record:
const scheduler = new SchedulerPro({
features : {
taskEdit : {
items : {
generalTab : {
items : {
// Add new field to the last position
newGeneralField : {
type : 'textfield',
weight : 610,
label : 'New field in General Tab',
// Name of the field matches data field name, so value is loaded/saved automatically
name : 'custom'
}
}
},
// Add a custom tab to the first position
newTab : {
// Tab is a FormTab by default
title : 'New tab',
weight : 90,
items : {
newTabField : {
type : 'textfield',
weight : 10,
label : 'New field in New Tab',
// Name of the field matches data field name, so value is loaded/saved automatically.
// In this case it is equal to the Task "name" field.
name : 'name'
}
}
}
}
}
}
})
Manipulating TaskEditor items at run time
To change input items depending upon the task being edited, use a beforeTaskEditShow listener to access the editor instance.
The available widgets are described here.
The editor exposes all its descendant widgets in its widgetMap.
const gantt = new Gantt({
features : {
taskEdit : true
},
listeners : {
// When editing a parent task, the user may not edit the duration.
// When editing a leaf level task she may edit the duration.
beforeTaskEditShow({ taskRecord, editor }) {
if (taskRecord.isParent) {
editor.widgetMap.duration.disabled = true;
}
else {
editor.widgetMap.duration.disabled = false;
}
}
}
});
To turn off the Task Editor just simple disable the feature.
const scheduler = new SchedulerPro({
features : {
taskEdit : false
}
})
By default predecessors and successors in successorsTab and predecessorsTab are displayed using task id and a name.
The id part is configurable, any task field may be used instead (for example wbsCode or sequence number)
by Gantt dependencyIdField property, to set it globally, or using
taskEdit config dependencyIdField to set format only for taskEditor.
const gantt = new Gantt({
dependencyIdField: 'wbsCode', // for global format
project,
columns : [
{ type : 'name', width : 250 }
],
features : {
taskEdit : {
editorConfig : {
dependencyIdField : 'wbsCode' // set only for taskEditor
}
}
}
});
For more info on customizing the Task Editor, please see Guides/Customization/Customize task editor
Editing nested events
Note that when editing nested events the resource field, the successors tab and the predecessors tab are hidden automatically.
This feature is disabled by default in SchedulerPro and disabled in ResourceHistogram.
For info on enabling it, see GridFeatures.
Configs
20
Configs
20Editor
Class to use as the editor. By default it picks editor class depending on the project type.
It can be either SchedulerTaskEditor or
GanttTaskEditor.
By specifying your own editorClass you override this.
True to save and close this panel if ENTER is pressed in one of the input fields inside the panel.
The event that shall trigger showing the editor. Defaults to eventdblclick, set to `` or null to
disable editing of existing events.
Editor widgets
True to show a confirmation dialog before deleting the event
Other
What action should be taken when you click outside the editor, cancel or save
A configuration object applied to the internal TaskEditor. Useful to for example change the title of the editor or to set its dimensions in code:
features : {
taskEdit : {
editorConfig : {
title : 'My title',
height : 300
}
}
}
NOTE: The easiest approach to affect editor contents is to use the items config.
A configuration object used to customize the contents of the task editor. Supply a config object or boolean per tab (listed below) to either affects its contents or toggle it on/off.
Supplied config objects will be merged with the tabs predefined configs.
To remove existing items, set corresponding keys to null.
Built-in tab names are:
generalTabpredecessorsTabsuccessorsTabadvancedTabnotesTab
features : {
taskEdit : {
items : {
// Custom settings and additional items for the general tab
generalTab : {
title : 'Common',
items : {
durationField : false,
myCustomField : {
type : 'text',
name : 'color'
}
}
},
// Hide the advanced tab
advancedTab : null
}
}
}
Please see the taskeditor demo for a customized editor in action.
How much of a long task bar which is clipped by scrolling must be brought into view to facilitate editing.
In a Gantt, or a horizontal Scheduler, this will bring 100 pixels of width into view.
In a vertical Scheduler, this will bring 100 pixels of height into view.
Set to false to not scroll event into view when invoking edit action (e.g. if event is only partially visible)
When field in task editor is changed, project model normally will trigger hasChanges event. If you use
this event to handle project changes excessive events might be a problem. Set this flag to true to only
trigger single hasChanges event after task changes are applied.
The week start day used in all date fields of the feature editor form by default. 0 means Sunday, 6 means Saturday. Defaults to the locale's week start day.
Misc
Properties
23
Properties
23Common
Class hierarchy
Editor
The editor widget used for editing task details. Provides an interface to modify task properties within the Scheduler.
Other
Returns true if the editor is currently active
How much of a long task bar which is clipped by scrolling must be brought into view to facilitate editing.
In a Gantt, or a horizontal Scheduler, this will bring 100 pixels of width into view.
In a vertical Scheduler, this will bring 100 pixels of height into view.
Functions
32
Functions
32Other
Call this method to close task editor reverting changes.
A promise which is resolved when the task editor is closed and changes are reverted.
Shows a scheduler task editor or gantt task editor
to edit the passed task. This function is exposed on the Scheduler Pro instance and can be called as scheduler.editTask().
| Parameter | Type | Description |
|---|---|---|
taskRecord | EventModel | function | Task to edit or a function returning a task to edit, the function will be executed within an STM transaction which will be canceled in case user presses Cancel button or closes editor w/o hitting Save. |
resourceRecord | ResourceModel | The Resource record for the event. This parameter is required if the event is newly created for a resource and has not been assigned, or when using multi assignment. |
element | HTMLElement | Element to anchor editor to (defaults to events element) |
Promise which resolves after the editor is shown
Call this method to close task editor saving changes.
A promise which is resolved when the task editor is closed and changes are saved.
Configuration
Events
Misc
Events
15
Events
15Fires on the owning Scheduler or Gantt widget instance after an event record is saved
// Adding a listener using the "on" method
taskEdit.on('afterEventSave', ({ source, eventRecord, editor }) => {
});| Parameter | Type | Description |
|---|---|---|
source | SchedulerPro | The Scheduler Pro instance |
eventRecord | EventModel | The event record about to be saved |
editor | TaskEditorBase | The editor widget |
Fires on the owning Scheduler or Gantt widget instance after task editing is finished by applying changes, cancelling them or deleting the task record.
// Adding a listener using the "on" method
taskEdit.on('afterTaskEdit', ({ source, taskRecord, editor }) => {
});| Parameter | Type | Description |
|---|---|---|
source | SchedulerPro | The Scheduler Pro instance |
taskRecord | EventModel | Task record used in the task editor |
editor | TaskEditorBase | The editor widget |
Fires on the owning Scheduler or Gantt widget instance after a task is saved
// Adding a listener using the "on" method
taskEdit.on('afterTaskSave', ({ source, taskRecord, editor }) => {
});| Parameter | Type | Description |
|---|---|---|
source | SchedulerPro | The Scheduler Pro instance |
taskRecord | EventModel | The task about to be saved |
editor | TaskEditorBase | The editor widget |
Fires on the owning Scheduler or Gantt widget before an event record is deleted, return false to prevent it.
Allows async flows by awaiting async listeners. For example:
new SchedulerPro({
listeners : {
async beforeEventDelete() {
await someAsyncConditionLikeAskingForConfirmation();
}
}
});
// Adding a listener using the "on" method
taskEdit.on('beforeEventDelete', ({ source, eventRecord, editor }) => {
});| Parameter | Type | Description |
|---|---|---|
source | SchedulerPro | The Scheduler Pro instance. |
eventRecord | EventModel | The event record about to be deleted |
editor | TaskEditorBase | The editor widget |
Fires on the owning Scheduler or Gantt widget instance before an event record is saved, return false to prevent it.
Allows async flows by awaiting async listeners. For example:
new SchedulerPro({
listeners : {
async beforeEventSave() {
await someAsyncConditionLikeAskingForConfirmation();
}
}
});
// Adding a listener using the "on" method
taskEdit.on('beforeEventSave', ({ source, eventRecord, editor }) => {
});| Parameter | Type | Description |
|---|---|---|
source | SchedulerPro | The Scheduler Pro instance |
eventRecord | EventModel | The event record about to be saved |
editor | TaskEditorBase | The editor widget |
Fires on the owning Scheduler or Gantt widget before a task is deleted, return false to prevent it.
Allows async flows by awaiting async listeners. For example:
new SchedulerPro({
listeners : {
async beforeTaskDelete() {
await someAsyncConditionLikeAskingForConfirmation();
}
}
});
// Adding a listener using the "on" method
taskEdit.on('beforeTaskDelete', ({ source, taskRecord, editor }) => {
});| Parameter | Type | Description |
|---|---|---|
source | SchedulerPro | The Scheduler Pro instance. |
taskRecord | EventModel | The record about to be deleted |
editor | TaskEditorBase | The editor widget |
Fires on the owning Scheduler or Gantt widget instance before a task is displayed in the editor.
This may be listened to in order to take over the task editing flow. Returning false
stops the default editing UI from being shown.
Allows async flows by awaiting async listeners. For example:
new SchedulerPro({
listeners : {
async beforeTaskEdit() {
await asyncCheckOfRightsOnBackend();
}
}
});
// Adding a listener using the "on" method
taskEdit.on('beforeTaskEdit', ({ source, taskEdit, taskRecord, taskElement }) => {
});| Parameter | Type | Description |
|---|---|---|
source | SchedulerPro | The Scheduler Pro instance |
taskEdit | TaskEdit | The taskEdit feature |
taskRecord | EventModel | The task about to be shown in the editor. |
taskElement | HTMLElement | The element which represents the task |
Fires on the owning Scheduler or Gantt widget when the editor for an event is available but before it is shown. Allows manipulating fields etc.
// Adding a listener using the "on" method
taskEdit.on('beforeTaskEditShow', ({ source, taskEdit, taskRecord, eventElement, editor }) => {
});| Parameter | Type | Description |
|---|---|---|
source | SchedulerPro | The SchedulerPro instance |
taskEdit | TaskEdit | The taskEdit feature |
taskRecord | EventModel | The task about to be shown in the editor. |
eventElement | HTMLElement | The element which represents the task |
editor | TaskEditorBase | The editor |
Fires on the owning Scheduler or Gantt widget instance before a task is saved, return false to prevent it.
Allows async flows by awaiting async listeners. For example:
new SchedulerPro({
listeners : {
async beforeTaskSave() {
await someAsyncConditionLikeAskingForConfirmation();
}
}
});
// Adding a listener using the "on" method
taskEdit.on('beforeTaskSave', ({ source, taskRecord, editor }) => {
});| Parameter | Type | Description |
|---|---|---|
source | SchedulerPro | The Scheduler Pro instance |
taskRecord | EventModel | The task about to be saved |
editor | TaskEditorBase | The editor widget |
Fires on the owning Scheduler or Gantt widget when the editor for an event is canceled.
// Adding a listener using the "on" method
taskEdit.on('taskEditCanceled', ({ source, taskRecord, editor }) => {
});| Parameter | Type | Description |
|---|---|---|
source | SchedulerPro | The Scheduler Pro instance |
taskRecord | EventModel | the task about the shown in the editor |
editor | TaskEditorBase | The editor |
Event handlers
15
Event handlers
15Called on the owning Scheduler or Gantt widget instance after an event record is saved
new TaskEdit({
onAfterEventSave({ source, eventRecord, editor }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | SchedulerPro | The Scheduler Pro instance |
eventRecord | EventModel | The event record about to be saved |
editor | TaskEditorBase | The editor widget |
Called on the owning Scheduler or Gantt widget instance after task editing is finished by applying changes, cancelling them or deleting the task record.
new TaskEdit({
onAfterTaskEdit({ source, taskRecord, editor }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | SchedulerPro | The Scheduler Pro instance |
taskRecord | EventModel | Task record used in the task editor |
editor | TaskEditorBase | The editor widget |
Called on the owning Scheduler or Gantt widget instance after a task is saved
new TaskEdit({
onAfterTaskSave({ source, taskRecord, editor }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | SchedulerPro | The Scheduler Pro instance |
taskRecord | EventModel | The task about to be saved |
editor | TaskEditorBase | The editor widget |
Called on the owning Scheduler or Gantt widget before an event record is deleted, return false to prevent it.
Allows async flows by awaiting async listeners. For example:
new SchedulerPro({
listeners : {
async beforeEventDelete() {
await someAsyncConditionLikeAskingForConfirmation();
}
}
});
new TaskEdit({
onBeforeEventDelete({ source, eventRecord, editor }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | SchedulerPro | The Scheduler Pro instance. |
eventRecord | EventModel | The event record about to be deleted |
editor | TaskEditorBase | The editor widget |
Called on the owning Scheduler or Gantt widget instance before an event record is saved, return false to prevent it.
Allows async flows by awaiting async listeners. For example:
new SchedulerPro({
listeners : {
async beforeEventSave() {
await someAsyncConditionLikeAskingForConfirmation();
}
}
});
new TaskEdit({
onBeforeEventSave({ source, eventRecord, editor }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | SchedulerPro | The Scheduler Pro instance |
eventRecord | EventModel | The event record about to be saved |
editor | TaskEditorBase | The editor widget |
Called on the owning Scheduler or Gantt widget before a task is deleted, return false to prevent it.
Allows async flows by awaiting async listeners. For example:
new SchedulerPro({
listeners : {
async beforeTaskDelete() {
await someAsyncConditionLikeAskingForConfirmation();
}
}
});
new TaskEdit({
onBeforeTaskDelete({ source, taskRecord, editor }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | SchedulerPro | The Scheduler Pro instance. |
taskRecord | EventModel | The record about to be deleted |
editor | TaskEditorBase | The editor widget |
Called on the owning Scheduler or Gantt widget instance before a task is displayed in the editor.
This may be listened to in order to take over the task editing flow. Returning false
stops the default editing UI from being shown.
Allows async flows by awaiting async listeners. For example:
new SchedulerPro({
listeners : {
async beforeTaskEdit() {
await asyncCheckOfRightsOnBackend();
}
}
});
new TaskEdit({
onBeforeTaskEdit({ source, taskEdit, taskRecord, taskElement }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | SchedulerPro | The Scheduler Pro instance |
taskEdit | TaskEdit | The taskEdit feature |
taskRecord | EventModel | The task about to be shown in the editor. |
taskElement | HTMLElement | The element which represents the task |
Called on the owning Scheduler or Gantt widget when the editor for an event is available but before it is shown. Allows manipulating fields etc.
new TaskEdit({
onBeforeTaskEditShow({ source, taskEdit, taskRecord, eventElement, editor }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | SchedulerPro | The SchedulerPro instance |
taskEdit | TaskEdit | The taskEdit feature |
taskRecord | EventModel | The task about to be shown in the editor. |
eventElement | HTMLElement | The element which represents the task |
editor | TaskEditorBase | The editor |
Called on the owning Scheduler or Gantt widget instance before a task is saved, return false to prevent it.
Allows async flows by awaiting async listeners. For example:
new SchedulerPro({
listeners : {
async beforeTaskSave() {
await someAsyncConditionLikeAskingForConfirmation();
}
}
});
new TaskEdit({
onBeforeTaskSave({ source, taskRecord, editor }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | SchedulerPro | The Scheduler Pro instance |
taskRecord | EventModel | The task about to be saved |
editor | TaskEditorBase | The editor widget |
Called on the owning Scheduler or Gantt widget when the editor for an event is canceled.
new TaskEdit({
onTaskEditCanceled({ source, taskRecord, editor }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | SchedulerPro | The Scheduler Pro instance |
taskRecord | EventModel | the task about the shown in the editor |
editor | TaskEditorBase | The editor |