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 assignment
  • resourceId - The id of the resource assigned (optionally replaced with resource for load)
  • eventId - The id of the event to which the resource is assigned (optionally replaced with event for 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 record
  • resource - 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

Class hierarchy

isAssignmentModel: Boolean= truereadonly
Identifies an object as an instance of AssignmentModel class, or subclass thereof.
isAssignmentModel: Boolean= truereadonlystatic
Identifies an object as an instance of AssignmentModel class, or subclass thereof.
Identifies an object as an instance of AssignmentModelMixin class, or subclass thereof.
isAssignmentModelMixin: Boolean= truereadonlystaticAssignmentModelMixin
Identifies an object as an instance of AssignmentModelMixin class, or subclass thereof.
isModelModel
isModelLinkModelLink
isModelStmModelStm
isTreeNodeTreeNode

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.

$namestaticModel
relationsstaticModel

Editing

copyOfModel
isValidModel

Fields

allFieldsstaticModel
autoExposeFieldsstaticModel
childrenFieldstaticModel
defaultsstaticModel
fieldMapstaticModel
fieldsstaticModel
idFieldstaticModel

Grouping

Identification

keyModel

JSON

jsonModel

Lifecycle

configBase

Linked records

hasLinksModelLink
isLinkedModelLink
recordLinksModelLink

Misc

stmModelStm

Parent & children

allChildrenTreeNode
childLevelTreeNode
firstChildTreeNode
isLeafTreeNode
isLoadedTreeNode
isParentTreeNode
isRootTreeNode
lastChildTreeNode
nextSiblingTreeNode
parentTreeNode
parentIdTreeNode

Functions

56

Editing

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
ParameterTypeDescription
fieldString | Object

The field to set value for, or an object with multiple values to set in one call

value*

Value to set

silentBoolean

Set to true to not trigger events automatically.

copyModel
getDataModel
removeModel
setModel

Other

Returns the resource associated with this assignment.

Returns: ResourceModel -

Instance of resource

Returns a textual representation of this assignment (e.g. Mike 50%).

Returns: String

Configuration

applyDefaultsstaticBase

Events

Fields

addFieldstaticModel
getModel
processFieldstaticModel
removeFieldstaticModel

Identification

asIdstaticModel
generateIdstaticModel

JSON

toJSONModel

Lifecycle

destroystaticBase

Misc

equalsModel
initClassstaticBase
isOfTypeNamestaticBase
linkModelLink
mixinstaticBase

Parent & children

appendChildTreeNode
bubbleTreeNode
bubbleWhileTreeNode
containsTreeNode
insertChildTreeNode
isExpandedTreeNode
removeChildTreeNode
traverseTreeNode

Typedefs

1

Fields

2

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.

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.