EventStoreMixin
Configs
2
Configs
2Configure with true to also remove the event when removing the last assignment from the linked
AssignmentStore. This config has no effect when using EventStore in legacy resourceId-mode.
Configure with true to force single-resource mode, an event can only be assigned to a single resource.
If not provided, the mode will be inferred from
- presence of an assignment store (i.e. multi-assignment)
- presence of
resourceIdin the event store data (i.e. single assignment mode)
Properties
4
Properties
4Class hierarchy
Records
Applies a new dataset to the EventStore. Use it to plug externally fetched data into the store.
NOTE: Dates, durations and relations (assignments, resources) on the events are determined async by a calculation engine. Thus they cannot be directly accessed after assigning the new dataset.
For example:
eventStore.data = [{ startDate, duration }];
// eventStore.first.endDate is not yet calculated
To guarantee data is in a calculated state, wait for calculations for finish:
eventStore.data = [{ startDate, duration }];
await eventStore.project.commitAsync();
// eventStore.first.endDate is calculated
Alternatively use loadDataAsync() instead:
await eventStore.loadDataAsync([{ startDate, duration }]);
// eventStore.first.endDate is calculated
Class used to represent records. Defaults to class EventModel.
Functions
18
Functions
18Assignment
Creates and adds assignment record for a given event and a resource.
| Parameter | Type | Description |
|---|---|---|
event | EventModel | String | Number | |
resource | ResourceModel | String | Number | ResourceModel[] | String[] | Number[] | The resource(s) to assign to the event |
removeExistingAssignments | Boolean |
|
An array with the created assignment(s)
Returns all assignments for a given event.
| Parameter | Type | Description |
|---|---|---|
event | EventModel | The event to get assignments for |
Array of assignments for the event
Returns all assignments for a given resource.
| Parameter | Type | Description |
|---|---|---|
resource | ResourceModel | String | Number |
Checks whether an event is assigned to a resource.
| Parameter | Type | Description |
|---|---|---|
event | EventModel | String | Number | |
resource | ResourceModel | String | Number |
Reassigns an event from an old resource to a new resource
| Parameter | Type | Description |
|---|---|---|
event | EventModel | An event or id of the event to reassign |
oldResource | ResourceModel | ResourceModel[] | A resource or id to unassign from |
newResource | ResourceModel | ResourceModel[] | A resource or id to assign to |
Removes all assignments for given event
| Parameter | Type | Description |
|---|---|---|
event | EventModel | String | Number |
Removes all assignments for given resource
| Parameter | Type | Description |
|---|---|---|
resource | ResourceModel | String | Number |
Removes assignment record for a given event and a resource.
| Parameter | Type | Description |
|---|---|---|
event | EventModel | String | Number | |
resource | ResourceModel | String | Number |
CRUD
Add events to the store.
NOTE: Dates, durations and references (assignments, resources) on the events are determined async by a calculation engine. Thus they cannot be directly accessed after using this function.
For example:
eventStore.add({ startDate, duration });
// endDate is not yet calculated
To guarantee data is in a calculated state, wait for calculations for finish:
eventStore.add({ startDate, duration });
await eventStore.project.commitAsync();
// endDate is calculated
Alternatively use addAsync() instead:
await eventStore.addAsync({ startDate, duration });
// endDate is calculated
| Parameter | Type | Description |
|---|---|---|
records | EventModel | EventModel[] | EventModelConfig | EventModelConfig[] | Array of records/data or a single record/data to add to store |
silent | Boolean | Specify |
Added records
Add events to the store and triggers calculations directly after. Await this function to have up to date data on the added events.
await eventStore.addAsync({ startDate, duration });
// endDate is calculated
| Parameter | Type | Description |
|---|---|---|
records | EventModel | EventModel[] | EventModelConfig | EventModelConfig[] | Array of records/data or a single record/data to add to store |
silent | Boolean | Specify |
Added records
Appends a new record to the store
| Parameter | Type | Description |
|---|---|---|
record | EventModel | The record to append to the store |
Applies a new dataset to the EventStore and triggers calculations directly after. Use it to plug externally fetched data into the store.
await eventStore.loadDataAsync([{ startDate, duration }]);
// eventStore.first.endDate is calculated
| Parameter | Type | Description |
|---|---|---|
data | EventModelConfig[] | Array of EventModel data objects |
Events
Calls the supplied iterator function once for every scheduled event, providing these arguments
- event : the event record
- startDate : the event start date
- endDate : the event end date
Returning false cancels the iteration.
| Parameter | Type | Description |
|---|---|---|
fn | function | iterator function |
thisObj | Object |
|
Returns a Map, keyed by YYYY-MM-DD date keys containing event counts for all the days
between the passed startDate and endDate. Occurrences of recurring events are included.
Example:
eventCounts = eventStore.getEventCounts({
startDate : scheduler.timeAxis.startDate,
endDate : scheduler.timeAxis.endDate
});
| Parameter | Type | Description |
|---|---|---|
options | Object | An options object determining which events to return |
options.startDate | Date | The start date for the range of events to include. |
options.endDate | Date | The end date for the range of events to include. |
Returns an object defining the earliest start date and the latest end date of all the events in the store.
An object with 'startDate' and 'endDate' properties (or null values if data is missing).
Checks if given event record is persistable. By default it always is, override EventModels isPersistable if you
need custom logic.
| Parameter | Type | Description |
|---|---|---|
event | EventModel |
Resource
Returns all events assigned to a resource. NOTE: this does not include occurrences of recurring events. Use the getEvents API to include occurrences of recurring events.
| Parameter | Type | Description |
|---|---|---|
resource | ResourceModel | String | Number | Resource or resource id. |
Returns all resources assigned to an event.
| Parameter | Type | Description |
|---|---|---|
event | EventModel | String | Number |