AssignmentStoreMixin
Properties
3
Properties
3Class hierarchy
Records
Applies a new dataset to the AssignmentStore. Use it to plug externally fetched data into the store.
NOTE: References (assignments, resources) on the assignments are determined async by a calculation engine. Thus they cannot be directly accessed after assigning the new dataset.
For example:
assignmentStore.data = [{ eventId, resourceId }];
// assignmentStore.first.event is not yet available
To guarantee references are available, wait for calculations for finish:
assignmentStore.data = [{ eventId, resourceId }];
await assignmentStore.project.commitAsync();
// assignmentStore.first.event is available
Alternatively use loadDataAsync() instead:
await assignmentStore.loadDataAsync([{ eventId, resourceId }]);
// assignmentStore.first.event is available
Functions
14
Functions
14Assign
Creates and adds assignment record(s) for a given event and resource(s).
| Parameter | Type | Description |
|---|---|---|
event | TimeSpan | |
resources | ResourceModel | ResourceModel[] | The resource(s) to assign to the event |
assignmentSetupFn | function | A hook function which takes an assignment as its argument and must return an assignment. |
removeExistingAssignments | Boolean |
|
An array with the created assignment(s)
Removes assignment record for a given event and resource.
| Parameter | Type | Description |
|---|---|---|
event | TimeSpan | String | Number | |
resources | ResourceModel | String | Number | The resource to unassign the event from. If omitted, all resources of the events will be unassigned |
Assignments
Returns an assignment record for a given event and resource
| Parameter | Type | Description |
|---|---|---|
event | EventModel | String | Number | The event or its id |
resource | ResourceModel | String | Number | The resource or its id |
Returns all assignments for a given resource.
| Parameter | Type | Description |
|---|---|---|
resource | ResourceModel |
Returns all events assigned to a resource
| Parameter | Type | Description |
|---|---|---|
resource | ResourceModel | String | Number |
Returns all resources assigned to an event.
| Parameter | Type | Description |
|---|---|---|
event | EventModel |
Checks whether an event is assigned to a resource.
| Parameter | Type | Description |
|---|---|---|
event | EventModel | String | Number | Event record or id |
resource | ResourceModel | String | Number | Resource record or id |
Maps over event assignments.
| Parameter | Type | Description |
|---|---|---|
event | EventModel | |
fn | function | |
filterFn | function |
Maps over resource assignments.
| Parameter | Type | Description |
|---|---|---|
resource | ResourceModel | Number | String | |
fn | function | |
filterFn | function |
Removes all assignments for given event
| Parameter | Type | Description |
|---|---|---|
event | TimeSpan |
Removes all assignments for given resource
| Parameter | Type | Description |
|---|---|---|
resource | ResourceModel | * |
CRUD
Add assignments to the store.
NOTE: References (event, resource) on the assignments are determined async by a calculation engine. Thus they cannot be directly accessed after using this function.
For example:
const [assignment] = assignmentStore.add({ eventId, resourceId });
// assignment.event is not yet available
To guarantee references are set up, wait for calculations for finish:
const [assignment] = assignmentStore.add({ eventId, resourceId });
await assignmentStore.project.commitAsync();
// assignment.event is available (assuming EventStore is loaded and so on)
Alternatively use addAsync() instead:
const [assignment] = await assignmentStore.addAsync({ eventId, resourceId });
// assignment.event is available (assuming EventStore is loaded and so on)
| Parameter | Type | Description |
|---|---|---|
records | AssignmentModel | AssignmentModel[] | AssignmentModelConfig | AssignmentModelConfig[] | Array of records/data or a single record/data to add to store |
silent | Boolean | Specify |
Added records
Add assignments to the store and triggers calculations directly after. Await this function to have up to date references on the added assignments.
const [assignment] = await assignmentStore.addAsync({ eventId, resourceId });
// assignment.event is available (assuming EventStore is loaded and so on)
| Parameter | Type | Description |
|---|---|---|
records | AssignmentModel | AssignmentModel[] | AssignmentModelConfig | AssignmentModelConfig[] | Array of records/data or a single record/data to add to store |
silent | Boolean | Specify |
Added records
Applies a new dataset to the AssignmentStore and triggers calculations directly after. Use it to plug externally fetched data into the store.
await assignmentStore.loadDataAsync([{ eventId, resourceId }]);
// assignmentStore.first.event is available
| Parameter | Type | Description |
|---|---|---|
data | AssignmentModelConfig[] | Array of AssignmentModel data objects |