ProjectEdit
Feature
Feature that displays the project editor allowing users to edit the project settings.
This demo shows the project edit feature, click "Edit project" button to start editing:
// Project contains all the data and is responsible for correct scheduling const project = new ProjectModel({ name : 'Writing documentation', startDate : new Date(2017, 0, 1), calendar : 'default', calendars : [{ id : 'default', name : 'Default calendar', intervals : [{ id : 1, recurrentStartDate : 'on Sat', recurrentEndDate : 'on Mon', isWorking : false }] }], tasks : [ { 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' } ] } ], dependencies : [ { fromTask : 2, toTask : 3 } ] }); const gantt = new Gantt({ appendTo : targetElement, flex : '1 0 100%', height : 200, project, // Gantt needs project to get schedule data from startDate : new Date(2016, 11, 31), endDate : new Date(2017, 0, 11), features : { // enable project editing UI projectEdit : true }, tbar : [ { text : 'Edit project', icon : 'fa fa-edit', onAction() { gantt.editProject(); } } ], columns : [ { type : 'name', 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.
This example shows a custom Project Editor configuration. The built-in "Description" tab is hidden, the "General" tab is renamed to "Common" and "Custom" field is appended to it. Click "Edit project" button to start editing::
const project = new ProjectModel({ name : 'Documenting', startDate : new Date(2017, 0, 1), calendar : 'default', custom : 'Custom field value', calendars : [{ id : 'default', name : 'Default calendar', intervals : [{ id : 1, recurrentStartDate : 'on Sat', recurrentEndDate : 'on Mon', isWorking : false }] }], tasks : [ { id : 1, name : 'Write docs', expanded : true, custom : 'Parent custom field value', children : [ // 'custom' field is auto exposed to Task model, then its name is used in TaskEditor to get/set values { id : 2, name : 'Proof-read docs', startDate : '2017-01-02', endDate : '2017-01-05', custom : 'Proof-read custom value' }, { id : 3, name : 'Release docs', startDate : '2017-01-09', endDate : '2017-01-10', custom : 'Release custom value' } ] } ], dependencies : [ { id : 1, fromTask : 2, toTask : 3 } ] }); const gantt = new Gantt({ appendTo : targetElement, flex : '1 0 100%', height : 200, project, // Gantt needs project to get schedule data from startDate : new Date(2016, 11, 31), endDate : new Date(2017, 0, 11), columns : [ { type : 'name', field : 'name', text : 'Name' } ], tbar : [ { text : 'Edit project', icon : 'fa fa-edit', onAction() { gantt.editProject(); } } ], features : { projectEdit : { items : { generalTab : { // Change title of General tab title : 'Common', items : { // Add a new field newCustomField : { type : 'textfield', weight : 710, label : 'Custom (New Field)', name : 'custom' // Name of the field matches data field name, so value is loaded/saved automatically } } }, // Remove Description tab descriptionTab : false }, editorConfig : { // Custom height of the Project Editor height : '40em' } } // eo projectEdit } // eo features }); Expand to see Default tabs and fields
The project editor contains tabs by default. Each tab is a container with built in widgets.
| Tab ref | Type | Text | Weight | Description |
|---|---|---|---|---|
generalTab |
ProjectEditorGeneralTab | General | 100 | Shows basic configuration: name, start/end dates, schedule form |
descriptionTab |
ProjectEditorDescriptionTab | Description | 200 | Shows a text area to add a description to the edited project |
advancedTab |
ProjectEditorAdvancedTab | Advanced | 300 | Shows advanced options: number of hours per day, days per week and days per month |
General tab
General tab contains widgets for basic configurations
| Field ref | Type | Weight | Description |
|---|---|---|---|
nameField |
TextField | 100 | Project name field |
startDateField |
StartDateField | 200 | Project start date field |
endDateField |
EndDateField | 300 | Project end date field |
calendarField |
CalendarField | 400 | Project calendar field |
scheduleFromField |
RadioGroup | 500 | Project scheduling direction field |
readOnlyField |
Checkbox | 600 | Project readOnly field |
Advanced tab
A tab showing the advanced options for a project.
| Field ref | Type | Weight | Description |
|---|---|---|---|
hoursPerDayField |
NumberField | 100 | Project hours per day field |
daysPerWeekField |
NumberField | 200 | Project days per week field |
daysPerMonthField |
NumberField | 300 | Project days per month field |
Description tab
Notes tab contains a text area to show notes
A tab showing the description for a project.
| Field ref | Type | Weight | Description |
|---|---|---|---|
descriptionField |
TextField | 100 | A textarea field, to set a description to the project |
Removing a built-in item
To remove a built-in tab or widget, specify its ref as false in the items config:
const gantt = new Gantt({
features : {
projectEdit : {
items : {
generalTab : {
items : {
// Remove the "Calendar" field in the "General" tab
calendarField : false
}
},
// Remove all tabs except the "General" tab
descriptionTab : false,
advancedTab : false
}
}
}
})
The built-in buttons are:
| Widget ref | Type | Weight | Description |
|---|---|---|---|
saveButton |
Button | 100 | Save event button on the bbar |
cancelButton |
Button | 300 | Cancel event editing button on the bbar |
Bottom buttons may be hidden using bbar config passed to editorConfig:
const gantt = new Gantt({
features : {
projectEdit : {
editorConfig : {
bbar : {
items : {
cancelButton : 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 gantt = new Gantt({
features : {
projectEdit : {
items : {
generalTab : {
// Rename "General" tab
title : 'Main',
items : {
// Rename "Calendar" field
calendarField : {
label : 'Work time'
}
}
}
}
}
}
})
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 project record:
const gantt = new Gantt({
features : {
projectEdit : {
items : {
generalTab : {
items : {
// Add new field to the last position
newGeneralField : {
type : 'textfield',
weight : 710,
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',
// provide weight less than General tab has to make sure this tab goes first
weight : 90,
items : {
newTabField : {
type : 'textfield',
weight : 710,
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 project "name" field.
name : 'name'
}
}
}
}
}
}
})
Manipulating ProjectEditor items at run time
To change input items depending upon the project being edited, use a beforeProjectEditShow 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 : {
projectEdit : true
},
listeners : {
beforeProjectEditShow({ projectRecord, editor }) {
// if editing a project having non empty startDate value.
if (projectRecord.startDate) {
// do not allow editing the project start date
editor.widgetMap.startDate.disabled = true;
}
}
}
});
This feature is disabled by default
Configs
Configs are options you supply in a configuration object when creating an instance of this class-
Class to use as the editor.
-
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. Set to `` or null to disable editing.
-
Internal listeners, that cannot be removed by the user.
-
The widget which this plugin is to attach to.
Has a corresponding runtime client property.
-
Set to
falseto disable localization of this object. -
What action should be taken when you click outside the editor,
cancelorsave -
When field in task editor is changed, project model normally will trigger
hasChangesevent. If you use this event to handle project changes excessive events might be a problem. Set this flag to true to only trigger singlehasChangesevent 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.
Properties
Properties are getters/setters or publicly accessible variables on this class-
Identifies an object as an instance of Delayable class, or subclass thereof.
-
Identifies an object as an instance of Events class, or subclass thereof.
-
Identifies an object as an instance of Localizable class, or subclass thereof.
-
Identifies an object as an instance of ProjectEdit class, or subclass thereof.
-
Identifies an object as an instance of TaskEditStm class, or subclass thereof.
-
A class property getter for the default values of internal properties for this class.
-
An empty array that can be used as a default value.
-
An empty object that can be used as a default value.
-
Identifies an object as an instance of InstancePlugin class, or subclass thereof.
-
Identifies an object as an instance of ProjectEdit class, or subclass thereof.
-
Identifies an object as an instance of TaskEditBase class, or subclass thereof.
-
Returns a copy of the full configuration which was used to configure this object.
-
This property is set to
truebefore theconstructorreturns. -
This property is set to
trueon entry to the destroy method. It remains on the objects after returning fromdestroy(). If isDestroyed istrue, this property will also betrue, so there is no need to test for both (for example,comp.isDestroying || comp.isDestroyed). -
The Widget which was passed into the constructor, which is the Widget we are providing extra services for.
Has a corresponding client config.
-
Get the global LocaleHelper
-
Get the global LocaleManager
-
Returns true if the editor is currently active
Functions
Functions are methods available for calling on the class-
This optional class method is called when a class is mixed in using the mixin() method.
-
Registers this class type with its Factory
-
Internal function used to hook destroy() calls when using thisObj
-
Internal function used restore hooked destroy() calls when using thisObj
-
Auto detaches listeners registered from start, if set as detachable
-
Internal function used to run a callback function after an event is triggered
-
Removes all listeners registered to this object by the application.
-
This will merge a feature's (subclass of InstancePlugin) keyMap with it's client's keyMap.