v7.3.0
SupportExamplesFree Trial

ResourceModel

This class represent a single Resource in Scheduler Pro, usually added to a ResourceStore.

It is a subclass of Model. Please refer to the documentation for that class to become familiar with the base interface of the resource.

Fields and references

A resource has a few predefined fields, see Fields below. If you want to add more fields with meta data describing your resources then you should subclass this class:

class MyResource extends ResourceModel {
  static get fields() {
    return [
      // "id" and "name" fields are already provided by the superclass
      { name: 'company', type : 'string' }
    ];
  }
});

If you want to use other names in your data for the id and name fields you can configure them as seen below:

class MyResource extends ResourceModel {
  static get fields() {
    return [
       { name: 'name', dataSource: 'userName' }
    ];
  },
});

After load and project normalization, these references are accessible (assuming their respective stores are loaded):

  • assignments - The linked assignment records
  • events - The linked (through assignments) event records

Async resolving of references

As described above, a resource has links to assignments and events. These references are populated async, using the calculation engine of the project that the resource via its store is a part of. Because of this asyncness, references cannot be used immediately after assignment modifications:

assignment.resourceId = 2;
// resource.assignments is not yet up to date

To make sure references are updated, wait for calculations to finish:

assignment.resourceId = 2;
await assignment.project.commitAsync();
// resource.assignments is up to date

As an alternative, you can also use setAsync() to trigger calculations directly after the change:

await assignment.setAsync({ resourceId : 2});
// resource.assignments is up to date

See also

No results

Fields

Fields belong to a Model class and define the Model data structure
  • Specifies which rate table to use by default when assigning the resource.

  • Unique identifier

  • The unit of measure for the material resource.

  • Get or set resource name

  • Contains the resource rate tables.

  • type : 'work'/'material'/'cost''work'

    Indicates whether the resource is a work, material or a cost resource. Work resources are people and equipment. Material resources are consumable supplies, such as concrete, or soil. And cost resources let to apply a cost to an event by assigning a cost item (like an extra expenditure on flights) to that event.

  • Set to false to prevent overlapping events for this resource

  • Margin between stacked event bars for this resource, in px.

  • A boolean field used by the LockRows feature for pinning a row to the top.

  • The calendar, assigned to the entity. Allows you to set the time when entity can perform the work.

  • The total projected cost for the resource.

  • costAccrual : 'start'/'prorated'/'end''prorated'

    Specifies how and when the resource cost are to be charged, or accrued, to the cost of an event. The options are:

    • 'start' - costs are charged when events start
    • 'prorated' - costs are prorated across event durations
    • 'end' - costs are charged when events finish
  • CSS class (or several classes divided by space) to append to row elements

  • eventStyle : 'tonal'/'filled'/'bordered'/'traced'/'outlined'+ 9 more
    ResourceModelMixin

    Controls the style used for events assigned to this resource. Can be overridden per event using EventModels eventStyle config. See Schedulers eventStyle config for available options.

  • Icon for row (used automatically in tree, feel free to use it in renderer in other cases)

  • Image name relative to resourceImagePath, used by ResourceInfoColumn and vertical modes ResourceHeader to display a miniature image for the resource. Set value to false to disable image display.

  • Fully qualified image URL, used by ResourceInfoColumn and vertical modes ResourceHeader to display a miniature image for the resource.

  • Set to false to not display an avatar for this resource in the ResourceInfoColumn

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

  • A link to use for this record when rendered into a TreeColumn.

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

    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.

  • target : '_self'/'_blank'/'_parent'/'_top'/null
    GridRowModel

    The target to use if this tree node provides a value for the href field.

Properties

Properties are getters/setters or publicly accessible variables on this class
  • isModelStm : Booleantrue
    READONLY
    static
    ADVANCED
    ModelStm
    Identifies an object as an instance of ModelStm class, or subclass thereof.
  • isResourceModel : Booleantrue
    READONLY
    static
    ADVANCED
    Identifies an object as an instance of ResourceModel class, or subclass thereof.
  • isResourceModelMixin : Booleantrue
    READONLY
    static
    ADVANCED
    ResourceModelMixin
    Identifies an object as an instance of ResourceModelMixin class, or subclass thereof.
  • isTreeNode : Booleantrue
    READONLY
    static
    ADVANCED
    TreeNode
    Identifies an object as an instance of TreeNode class, or subclass thereof.
  • properties : Object
    internal
    static
    GridRowModel

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

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

    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.

Functions

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

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

  • initClass( )
    static
    ADVANCED
    GridRowModel

    Registers this class type with its Factory

  • exposeRelations( )
    internal
    static
    GridRowModel

    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

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

  • Unassigns this Resource from all its Events

  • clear( )
    private
    TreeNode

    Removes all records from the rootNode

Type definitions

Source path

SchedulerPro/model/ResourceModel.js

Contents