AssignmentModel
This class represent a single assignment of a resource to an event in Scheduler Pro. It has a lot in common with Schedulers AssignmentModel, they are separate models but they share much functionality using the AssignmentModelMixin mixin.
It is a subclass of 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
9
Fields
9Common
The total projected cost for the assignment. The field value is calculated for a material or work resource assignment. For a cost-type resources the cost is meant to be provided.
Id 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.
The quantity of the assigned material resource.
Please note: The field is used for a material-type resource only.
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.
A numeric, percent-like value, indicating the "contribution level" of the resource availability to the event. Number 100 means that the assigned resource spends all its working time on the event. And number 50 means that the resource spends only half of its available time on the event. Setting the value to 0 will unassign the resource (and remove the assignment)
Please note: The field is used for a work-type resource only.