EventStoreMixin

Configs

2
removeUnassignedEvent: Boolean= true

Configure 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

  1. presence of an assignment store (i.e. multi-assignment)
  2. presence of resourceId in the event store data (i.e. single assignment mode)

Properties

4

Class hierarchy

isEventStoreMixin: Boolean= truereadonly
Identifies an object as an instance of EventStoreMixin class, or subclass thereof.
isEventStoreMixin: Boolean= truereadonlystatic
Identifies an object as an instance of EventStoreMixin class, or subclass thereof.

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

Assignment

Creates and adds assignment record for a given event and a resource.

ParameterTypeDescription
eventEventModel | String | Number
resourceResourceModel | String | Number | ResourceModel[] | String[] | Number[]

The resource(s) to assign to the event

removeExistingAssignmentsBoolean

true to first remove existing assignments

Returns: AssignmentModel[] -

An array with the created assignment(s)

Returns all assignments for a given event.

ParameterTypeDescription
eventEventModel

The event to get assignments for

Returns: AssignmentModel[] -

Array of assignments for the event

Returns all assignments for a given resource.

ParameterTypeDescription
resourceResourceModel | String | Number
Returns: AssignmentModel[]

Checks whether an event is assigned to a resource.

ParameterTypeDescription
eventEventModel | String | Number
resourceResourceModel | String | Number
Returns: Boolean

Reassigns an event from an old resource to a new resource

ParameterTypeDescription
eventEventModel

An event or id of the event to reassign

oldResourceResourceModel | ResourceModel[]

A resource or id to unassign from

newResourceResourceModel | ResourceModel[]

A resource or id to assign to

Removes all assignments for given event

ParameterTypeDescription
eventEventModel | String | Number

Removes all assignments for given resource

ParameterTypeDescription
resourceResourceModel | String | Number

Removes assignment record for a given event and a resource.

ParameterTypeDescription
eventEventModel | String | Number
resourceResourceModel | 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
ParameterTypeDescription
recordsEventModel | EventModel[] | EventModelConfig | EventModelConfig[]

Array of records/data or a single record/data to add to store

silentBoolean

Specify true to suppress events

Returns: EventModel[] -

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
ParameterTypeDescription
recordsEventModel | EventModel[] | EventModelConfig | EventModelConfig[]

Array of records/data or a single record/data to add to store

silentBoolean

Specify true to suppress events

Returns: EventModel[] -

Added records

Appends a new record to the store

ParameterTypeDescription
recordEventModel

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
ParameterTypeDescription
dataEventModelConfig[]

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.

ParameterTypeDescription
fnfunction

iterator function

thisObjObject

this reference for the function

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
 });
ParameterTypeDescription
optionsObject

An options object determining which events to return

options.startDateDate

The start date for the range of events to include.

options.endDateDate

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.

Returns: Object -

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.

ParameterTypeDescription
eventEventModel
Returns: Boolean

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.

ParameterTypeDescription
resourceResourceModel | String | Number

Resource or resource id.

Returns: EventModel[]

Returns all resources assigned to an event.

ParameterTypeDescription
eventEventModel | String | Number
Returns: ResourceModel[]