v7.3.0
SupportExamplesFree Trial

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

See also

  • AssignmentStore — The store that holds assignment records
  • EventModel — The event model that assignments link to resources
  • ResourceModel — The resource model that assignments link to events
  • ProjectModel — Central project that manages all stores and models
No results

Fields

Fields belong to a Model class and define the Model data structure
  • 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.

  • Specify false to opt out of drawing dependencies from/to this assignment

  • A numeric value indicating the effort contributed by the assigned resource to the event.

  • 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 the event to assign

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

  • Id for the resource to assign to

  • The end date of the assignment. If not provided the assignments lasts till the task end date. Please note that the field has effect only only in the Gantt and when TimePhasedProjectModel is used.

  • The start date of the assignment. If not provided the assignment starts from the task start date. Please note that the field has effect only only in the Gantt and when TimePhasedProjectModel is used.

  • Start expanded or not (only valid for tree data)

  • This is a read-only field provided in server synchronization packets to specify which position the node takes in the parent's ordered children array. This index is set on load and gets updated on reordering nodes in tree. Sorting and filtering have no effect on it.

  • parentId : String/Number/null
    READONLY
    Model

    This is a read-only field provided in server synchronization packets to specify which record id is the parent of the record.

  • This is a read-only field provided in server synchronization packets to specify which position the node takes in the parent's children array. This index is set on load and gets updated automatically after row reordering, sorting, etc. To save the order, need to persist the field on the server and when data is fetched to be loaded, need to sort by this field.

  • Deprecated:

    This field has been deprecated. Please read the guide to find out if your app needs to use the new isFullyLoaded field.

    This field is added to the class at runtime when the Store is configured with lazyLoad. The number specified should reflect the total amount of children of a parent node, including nested descendants.

Properties

Properties are getters/setters or publicly accessible variables on this class
  • isAssignmentModel : Booleantrue
    READONLY
    static
    ADVANCED
    Identifies an object as an instance of AssignmentModel class, or subclass thereof.
  • isAssignmentModelMixin : Booleantrue
    READONLY
    static
    ADVANCED
    AssignmentModelMixin
    Identifies an object as an instance of AssignmentModelMixin class, or subclass thereof.
  • isModelStm : Booleantrue
    READONLY
    static
    ADVANCED
    ModelStm
    Identifies an object as an instance of ModelStm class, or subclass thereof.
  • isTreeNode : Booleantrue
    READONLY
    static
    ADVANCED
    Model
    Identifies an object as an instance of TreeNode class, or subclass thereof.
  • properties : Object
    internal
    static
    Model

    A class property getter for the default values of internal properties for this class.

  • allFields : DataField[]
    READONLY
    static
    Model

    An array containing all the defined fields for this Model class. This will include all superclass's defined fields.

  • fieldMap : Object<String, DataField>
    READONLY
    static
    Model

    An object containing all the defined fields for this Model class. This will include all superclass's defined fields through its prototype chain. So be aware that Object.keys and Object.entries will only access this class's defined fields.

  • The data source for the id field which provides the ID of instances of this Model.

  • Convenience property to get the name of the associated event.

  • A key made up from the event id and the id of the resource assigned to.

  • Convenience property to get the name of the associated resource.

  • emptyArray : Array
    internal
    READONLY
    Model

    An empty array that can be used as a default value.

  • emptyObject : Object
    internal
    READONLY
    Model

    An empty object that can be used as a default value.

  • isAssignmentModel : Booleantrue
    READONLY
    ADVANCED
    Identifies an object as an instance of AssignmentModel class, or subclass thereof.
  • isModel : Booleantrue
    READONLY
    ADVANCED
    Model
    Identifies an object as an instance of Model class, or subclass thereof.
  • copyOf : Model
    READONLY
    Model

    For copied records, this property links to the original model instance from which it was copied.

  • True if this Model is currently batching its changes.

  • True if this models changes are currently being committed.

  • True if this model has any uncommitted changes.

  • isValid : Boolean
    READONLY
    Model

    Check if record has valid data. Default implementation returns true, override in your model to do actual validation.

  • Get a map of the modified fields in form of an object. The field´s dataSource is used as the property name in the returned object. The record's id is included unless its persist config is false.

  • Get a map of the modified data fields along with any alwaysWrite fields, in form of an object. The field´s dataSource is used as the property name in the returned object. Used internally by AjaxStore / CrudManager when sending updates.

  • persistableData : Object
    internal
    READONLY
    Model

    Returns data for allpersistable fields in form of an object, using dataSource if present.

  • rawModificationData : Object
    internal
    READONLY
    Model

    Returns a map of the modified persistable fields

  • Returns the string value for display purposes of an instance of this Model class. Needs to be overridden in subclasses.

  • When called on a group header row returns list of records in that group. Returns undefined otherwise.

  • Returns true for a group header record

  • Gets the records internalId. It is assigned during creation, guaranteed to be globally unique among models.

  • Returns true if the record is new and has not been persisted (and received a proper id).

  • config : Object
    READONLY
    ADVANCED
    Model

    Returns a copy of the full configuration which was used to configure this object.

  • isConstructing : Boolean
    READONLY
    ADVANCED
    Model

    This property is set to true before the constructor returns.

  • isDestroying : Boolean
    READONLY
    ADVANCED
    Model

    This property is set to true on entry to the destroy method. It remains on the objects after returning from destroy(). If isDestroyed is true, this property will also be true, so there is no need to test for both (for example, comp.isDestroying || comp.isDestroyed).

  • Is this record linked to another record?

  • Get the original record this record is linked to.

  • Get the first store that this model is assigned to.

  • Reference to STM manager, if used

  • isRemoved : Boolean
    internal
    READONLY
    Model

    Returns true if this record is not part of any store.

  • Retrieve all children, excluding filtered out nodes (by traversing sub nodes)

  • Retrieve all children, including filtered out nodes (by traversing sub nodes)

  • Depth in the tree at which this node exists. First visual level of nodes are at level 0, their direct children at level 1 and so on.

  • Count all children (including sub-children) for a node (in its `firstStore´)

  • Get the first child of this node

  • indexPath : Number[]
    private
    READONLY
    Model

    Returns index path to this node. This is the index of each node in the node path starting from the topmost parent. (only relevant when its part of a tree store).

  • isLeaf : Boolean
    READONLY
    Model

    Is a leaf node in a tree structure?

  • Returns true for parent nodes with children loaded (there might still be no children)

  • Is a parent node in a tree structure?

  • isRoot : Boolean
    READONLY
    Model

    Returns true if this node is the root of the tree

  • lastChild : Model
    READONLY
    Model

    Get the last child of this node

  • Get the next sibling of this node

  • parent : Model
    READONLY
    Model

    This is a read-only property providing access to the parent node.

  • Get the previous sibling of this node

  • Returns count of all preceding sibling nodes (including their children).

  • Array of tree nodes without any filter applied. On first filter, will take order from sorted children, but is not thereafter kept in sorted order, so order should not be relied upon.

  • Count visible (expanded) children (including sub-children) for a node (in its firstStore)

  • Returns values of the persistable tree-defining fields: parentId, orderedParentIndex, and parentIndex or sparseIndex. parentIndex is omitted when sparseIndex is used.

Functions

Functions are methods available for calling on the class
  • onClassMixedIn( )
    internal
    static
    Model

    This optional class method is called when a class is mixed in using the mixin() method.

  • initClass( )
    static
    ADVANCED
    Model

    Registers this class type with its Factory

  • exposeRelations( )
    internal
    static
    Model

    Makes getters and setters for related records. Populates a Model#relation array with the relations, to allow it to be modified later when assigning stores.

  • Cancels current batch operation. Any changes during the batch are discarded.

  • Reverts changes in this back to their original values.

  • Called from insertChild to notify StateTrackingManager about children insertion. Provides it with all necessary context information collected in beforeInsertChild required to undo/redo the action.

  • Called from removeChild to notify StateTrackingManager about children removing. Provides it with all necessary context information collected in beforeRemoveChild required to undo/redo the action.

  • Called during creation to also turn any children into Models joined to the same stores as this model

  • initRelations( )
    private
    Model

    Initializes model relations. Called from store when adding a record.

  • clear( )
    private
    Model

    Removes all records from the rootNode

Source path

SchedulerPro/model/AssignmentModel.js

Contents