/**
* Returns an array of events for the passed resource which overlap the time range passed.
* @param {Date} start The start date
* @param {Date} end The end date
* @param {Scheduler.model.EventModel|null} excludeEvent An event to exclude from the check (or null)
* @param {Scheduler.model.ResourceModel|Scheduler.model.ResourceModel[]} resourceRecords The resources(s) to check.
* @return {Scheduler.model.EventModel[]} The events for the resource which overlap the time range
*/
function getConflictingEvents(eventStore, start, end, excludeEvent, resourceRecords) {
if (!Array.isArray(resourceRecords)) {
resourceRecords = [resourceRecords];
}
// This should be an array of unique event records
const allEvents = [];
// Collect all events assigned to the resource(s)
for (let i = 0, { length } = resourceRecords; i < length; i++) {
allEvents.push(...eventStore.getEventsForResource(resourceRecords[i], excludeEvent));
}
// return all the events which overlap the "start"->"end" range
return [...new Set(allEvents)].reduce((result, event) => {
if (event.isScheduled && DateHelper.intersectSpans(start, end, event.startDate, event.endDate)) {
result.push(event);
}
return result;
}, []);
}
Disclaimer. This is just suggested code. You may write something similar in your application.