AssignmentModel
This model represents a single assignment of a resource to an event in the scheduler, usually added to a AssignmentStore.
It is a subclass of the Model class. Please refer to the documentation for that class to become familiar with the base interface of this class.
Fields and references
An Assignment has the following fields:
id- The id of the assignmentresourceId- The id of the resource assigned (optionally replaced withresourcefor load)eventId- The id of the event to which the resource is assigned (optionally replaced witheventfor load)
The data source for these fields can be customized by subclassing this class:
class MyAssignment extends AssignmentModel {
static get fields() {
return [
{ name : 'resourceId', dataSource : 'linkedResource' }
];
}
}
After load and project normalization, these references are accessible (assuming their respective stores are loaded):
event- The linked event recordresource- The linked resource record
Async resolving of references
As described above, an assignment links an event to a resource. It holds references to an event record and a resource record. These references are populated async, using the calculation engine of the project that the assignment via its store is a part of. Because of this asyncness, references cannot be used immediately after modifications:
assignment.resourceId = 2;
// assignment.resource is not yet available
To make sure references are updated, wait for calculations to finish:
assignment.resourceId = 2;
await assignment.project.commitAsync();
// assignment.resource is available
As an alternative, you can also use setAsync() to trigger calculations directly after the change:
await assignment.setAsync({ resourceId : 2});
// assignment.resource is available
Properties
66
Properties
66Class hierarchy
Other
Convenience property to get the name of the associated event.
Returns true if the Assignment can be persisted (e.g. task and resource are not 'phantoms').
Note that when using single assignments, assignments are not persisted.
Convenience property to get the name of the associated resource.
Editing
JSON
Parent & children
Functions
56
Functions
56Editing
Set value for the specified field(s), triggering engine calculations immediately. See Model#set() for arguments.
assignment.set('resourceId', 2);
// assignment.resource is not yet resolved
await assignment.setAsync('resourceId', 2);
// assignment.resource is resolved
| Parameter | Type | Description |
|---|---|---|
field | String | Object | The field to set value for, or an object with multiple values to set in one call |
value | * | Value to set |
silent | Boolean | Set to |
Other
Returns the resource associated with this assignment.
Instance of resource
Returns a textual representation of this assignment (e.g. Mike 50%).
Configuration
Events
JSON
Parent & children
Typedefs
1
Typedefs
1Fields
2
Fields
2Id for event to assign. Can be used as an alternative to eventId, but please note that after
load it will be populated with the actual event and not its id. This field is not persistable.
Id for resource to assign to. Can be used as an alternative to resourceId, but please note that after
load it will be populated with the actual resource and not its id. This field is not persistable.