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 recordsevents- 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
Properties
70
Properties
70Common
Returns all assignments for the resource
Get associated events
Returns the initials (first letter of the first & last space-separated word in the name) or an empty string if this resource has no name. You can override this method in a ResourceModel subclass to provide your own implementation
Get associated resource time ranges. Only available when using the ´ResourceTimeRange` feature.
Class hierarchy
Editing
Returns true if the resource can be persisted.
In a flat store, a resource is always considered persistable. In a tree store, a resource is considered
persistable if its parent node is persistable.
Scheduling
This resource´s effective calendar. Returns the project calendar if the resource has no own calendar provided.
JSON
Parent & children
Functions
60
Functions
60Editing
Set value for the specified field(s), triggering engine calculations immediately. See Model#set() for arguments.
This does not matter much on the resource itself, but is of importance when manipulating its references:
assignment.set('resourceId', 2);
// resource.assignments is not yet up to date
await assignment.setAsync('resourceId', 2);
// resource.assignments is up to date
| 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
Adds a rate table to the resource
| Parameter | Type | Description |
|---|---|---|
rateTable | ResourceRateModel | ResourceRateModel[] | ResourceRateModelConfig | ResourceRateModelConfig[] | A rate table instance or data object (or an array of instances or data objects to add multiple tables) |
An array of the added tables
Removes a rate table or multiple rate tables from the resource
| Parameter | Type | Description |
|---|---|---|
rateTable | ResourceRateModel | ResourceRateModel[] | A rate table or an array of tables to remove |
An array of the removed tables
Sets the calendar of the task. Will cause the schedule to be updated - returns a Promise
| Parameter | Type | Description |
|---|---|---|
calendar | CalendarModel | The new calendar. Provide |
Unassigns this Resource from all its Events
Configuration
Events
Parent & children
Typedefs
7
Typedefs
7An object containing info on the assignment effort in a certain time interval.
The object is used when rendering interval bars and tooltips so it additionally provides a rectConfig property
which contains a configuration object for therect SVG-element representing the interval bar.
| Parameter | Type | Description |
|---|---|---|
assignment | AssignmentModel | The assignment which allocation is displayed. |
effort | Number | Amount of work performed by the assigned resource in the interval |
tick | TickInfo | The interval of time the allocation is collected for |
units | Number | Assignment units value |
rectConfig | Object | The rectangle DOM configuration object |
inEventTimeSpan | Boolean | Indicates if the interval is in the middle of the event timespan. |
Resource allocation information.
| Parameter | Type | Description |
|---|---|---|
resource | ResourceModel | Resource model. |
owner | ResourceAllocationInfo | The allocation report this instance is part of. |
total | ResourceAllocationInterval[] | The resource allocation data collected. |
byAssignments | Map | A |
Class implementing resource allocation report - data representing the provided resource
utilization in the provided period of time.
The data is grouped by the provided time intervals (ticks).
| Parameter | Type | Description |
|---|---|---|
resource | ResourceModel | Resource model. |
allocation | ResourceAllocation | The collected allocation info. |
ticks | CalendarModel | A calendar specifying intervals to group the collected
allocation by. Working time intervals of the calendars will be used for grouping.
This also specifies the time period to collect allocation for.
So the first interval |
includeInactiveEvents | Boolean |
|
An object containing info on the resource allocation in a certain time interval.
The object is used when rendering interval bars and tooltips so it additionally provides a rectConfig property
which contains a configuration object for the rect SVG-element representing the interval bar.
| Parameter | Type | Description |
|---|---|---|
resource | ResourceModel | Resource model |
assignments | Set | Set of ongoing assignments for the interval |
assignmentIntervals | Map | Individual ongoing assignments allocation indexed by assignments |
effort | Number | Resource effort in the interval (in milliseconds) |
isOverallocated | Boolean |
|
isUnderallocated | Boolean |
|
maxEffort | Number | Maximum possible resource effort in the interval (in milliseconds) |
tick | TickInfo | The time interval |
units | Number | Resource allocation in percents |
inEventTimeSpan | Boolean | Indicates if the interval is in the middle of the event timespan. |
Config object used to set different values for top/left and bottom/right margin.
| Parameter | Type | Description |
|---|---|---|
start | Number | Margin top in horizontal mode, margin left in vertical mode |
end | Number | Margin bottom in horizontal mode, margin right in vertical mode |
An object representing a certain time interval.
| Parameter | Type | Description |
|---|---|---|
startDate | Date | The interval start date |
endDate | Date | The interval end date |
Fields
9
Fields
9Common
Specifies which rate table to use by default when assigning the resource.
The unit of measure for the material resource.
A maximum units "capacity" for this resource, in percents. Corresponds to units field. Default value is 100%. If the sum of all "units" of all assignments of a resource for a certain period exceeds this value, such resource is marked as "over-allocated" in the resource histogram.
You should increase this field's value, if it is normal for the resource to have more than 100% allocation. This is for example if resource actually represents a team from several people.
Contains the resource rate tables.
Other
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.
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.
Scheduling
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.
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