ProjectModelMixin
Configs
13
Configs
13Common
Advanced
Configuration options to provide to the STM manager
Legacy inline data
The initial data, to fill the resourceTimeRangeStore with. Should be an array of ResourceTimeRangeModel or it's configuration objects.
The initial data, to fill the timeRangeStore with. Should be an array of TimeSpan or its configuration objects.
Models & Stores
A ResourceTimeRangeStore instance or a config object.
The constructor to create a resource time range store instance with. Should be a class subclassing the ResourceTimeRangeStore
A Store instance or a config object.
The constructor to create a time range store instance with. Should be a class subclassing the TimeRangeStore
Properties
12
Properties
12Advanced
State tracking manager instance the project relies on
Class hierarchy
Models & Stores
The store holding the resource time ranges information.
See also ResourceTimeRangeModel
Legacy inline data
Functions
3
Functions
3Common
Project changes (CRUD operations to records in its stores) are automatically committed on a buffer to the underlying graph based calculation engine. The engine performs it calculations async.
By calling this function, the commit happens right away. And by awaiting it you are sure that project calculations are finished and that references between records are up to date.
The returned promise is resolved with an object. If that object has rejectedWith set, there has been a conflict and the calculation failed.
// Move an event in time
eventStore.first.shift(1);
// Trigger calculations directly and wait for them to finish
const result = await project.commitAsync();
if (result.rejectedWith) {
// there was a conflict during the scheduling
}
Inline data
Accepts a "data package" consisting of data for the projects stores, which is then loaded into the stores.
The package can hold data for EventStore, AssignmentStore, ResourceStore, DependencyStore,
TimeRangeStore and ResourceTimeRangeStore. It uses the same format as when creating a project with inline
data:
await project.loadInlineData({
events : [
{ id : 1, name : 'Proof-read docs', startDate : '2017-01-02', endDate : '2017-01-09' },
{ id : 2, name : 'Release docs', startDate : '2017-01-09', endDate : '2017-01-10' }
],
resources : [
{ id : 1, name : 'Arcady' },
{ id : 2, name : 'Don' }
],
dependencies : [
{ fromEvent : 1, toEvent : 2 }
],
assignments : [
{ 'event' : 1, 'resource' : 1 },
{ 'event' : 2, 'resource' : 2 }
],
resourceTimeRanges : [
{ id : 1, name : 'Resource range', resourceId : 1, startDate : '2017-01-08', endDate : '2017-01-10' }
],
timeRanges : [
{ id : 1, startDate : '2017-01-26', name : 'Cool line' }
]
});
xxData properties are deprecated and will be removed in the future. Use xx instead. For
example eventsData is deprecated, use events instead. For now, both naming schemes are included in
the data object
After populating the stores it commits the project, starting its calculations. By awaiting loadInlineData() you
can be sure that project calculations are finished.
| Parameter | Type | Description |
|---|---|---|
dataPackage | Object | A data package as described above |
Events
1
Events
1Fired when data in any of the projects stores changes.
Basically a relayed version of each stores own change event, decorated with which store it originates from. See the store change event documentation for more information.
// Adding a listener using the "on" method
projectModelMixin.on('change', ({ source, store, action, record, records, changes }) => {
});| Parameter | Type | Description |
|---|---|---|
source | ProjectModel | This project |
store | Store | Affected store |
action | remove | removeAll | add | clearchanges | filter | update | dataset | replace | Name of action which triggered the change. May be one of:
|
record | Model | Changed record, for actions that affects exactly one record ( |
records | Model[] | Changed records, passed for all actions except |
changes | Object | Passed for the |
Event handlers
1
Event handlers
1Called when data in any of the projects stores changes.
Basically a relayed version of each stores own change event, decorated with which store it originates from. See the store change event documentation for more information.
new ProjectModelMixin({
onChange({ source, store, action, record, records, changes }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | ProjectModel | This project |
store | Store | Affected store |
action | remove | removeAll | add | clearchanges | filter | update | dataset | replace | Name of action which triggered the change. May be one of:
|
record | Model | Changed record, for actions that affects exactly one record ( |
records | Model[] | Changed records, passed for all actions except |
changes | Object | Passed for the |