ProjectModelMixin

Configs

13

Common

useRawDataProjectModelCommon

Advanced

Configuration options to provide to the STM manager

shouldSyncDataOnLoadProjectModelCommon
timeZoneProjectModelTimeZoneMixin

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.

includeLegacyDataPropertiesProjectModelCommon

Models & Stores

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

Inline data

jsonProjectModelCommon
toJSONResultFormatProjectModelCommon

Properties

12

Advanced

State tracking manager instance the project relies on

shouldSyncDataOnLoadProjectModelCommon
timeZoneProjectModelTimeZoneMixin

Class hierarchy

isProjectModelMixin: Boolean= truereadonly
Identifies an object as an instance of ProjectModelMixin class, or subclass thereof.
isProjectModelMixin: Boolean= truereadonlystatic
Identifies an object as an instance of ProjectModelMixin class, or subclass thereof.
isProjectModelCommonProjectModelCommon
isProjectModelTimeZoneMixinProjectModelTimeZoneMixin

Models & Stores

The store holding the resource time ranges information.

See also ResourceTimeRangeModel

The store holding the time ranges information.

See also TimeSpan

Inline data

inlineDataProjectModelCommon
jsonProjectModelCommon

Legacy inline data

includeLegacyDataPropertiesProjectModelCommon

Functions

3

Common

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' }
    ]
});

The 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.

ParameterTypeDescription
dataPackageObject

A data package as described above

toJSONProjectModelCommon

Events

1

Fired 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 }) => {

});
ParameterTypeDescription
sourceProjectModel

This project

storeStore

Affected store

actionremove | removeAll | add | clearchanges | filter | update | dataset | replace

Name of action which triggered the change. May be one of:

  • 'remove'
  • 'removeAll'
  • 'add'
  • 'clearchanges'
  • 'filter'
  • 'update'
  • 'dataset'
  • 'replace'
recordModel

Changed record, for actions that affects exactly one record ('update')

recordsModel[]

Changed records, passed for all actions except 'removeAll'

changesObject

Passed for the 'update' action, info on which record fields changed

Event handlers

1

Called 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 }) {

    }
});
ParameterTypeDescription
sourceProjectModel

This project

storeStore

Affected store

actionremove | removeAll | add | clearchanges | filter | update | dataset | replace

Name of action which triggered the change. May be one of:

  • 'remove'
  • 'removeAll'
  • 'add'
  • 'clearchanges'
  • 'filter'
  • 'update'
  • 'dataset'
  • 'replace'
recordModel

Changed record, for actions that affects exactly one record ('update')

recordsModel[]

Changed records, passed for all actions except 'removeAll'

changesObject

Passed for the 'update' action, info on which record fields changed