CalendarHighlight
This feature temporarily visualizes calendars for the event or resource calendar (controlled by the calendar config). The calendars are highlighted while a user is creating, dragging or resizing a task. Enabling this feature makes it easier for the end user to understand the underlying rules of the schedule.
//<code-header>
fiddle.title = 'Calendar highlight';
//</code-header>
const schedulerPro = new SchedulerPro({
appendTo : targetElement,
// makes scheduler as high as it needs to be to fit rows
autoHeight : true,
snap : true,
startDate : new Date(2022, 4, 15),
endDate : new Date(2022, 4, 29),
columns : [
{ field : 'name', text : 'Name', width : 100 }
],
features : {
eventDrag : {
snapToResource : true
},
dependencies : false,
scheduleTooltip : false,
calendarHighlight : true
},
project : {
calendarManagerStore : {
validateForCalendarEditorOnLoad : false
},
resources : [
{ id : 1, name : 'Bernard' },
{ id : 2, name : 'Bianca' }
],
events : [
{ id : 1, name : 'Drag me', startDate : '2022-05-18', duration : 2, resizable : false, calendar : 'inspection' }
],
assignments : [
{
id : 1,
event : 1,
resource : 1
}
],
calendars : [
{
id : 'inspection',
name : 'Inspection period May 16-23',
unspecifiedTimeIsWorking : false,
intervals : [
{
name : 'Inspection period',
startDate : '2022-05-16',
endDate : '2022-05-24',
isWorking : true
}
]
}
]
},
getDateConstraints(resourceRecord, eventRecord) {
if (eventRecord) {
const { startDate, endDate } = eventRecord.effectiveCalendar.intervals.first;
if (startDate) {
return {
start : startDate,
end : endDate
};
}
}
}
});
(async() => {
await schedulerPro.project.commitAsync();
if (!schedulerPro.isDestroyed) {
schedulerPro.features.calendarHighlight.highlightEventCalendars(schedulerPro.eventStore.first);
}
})();Example usage
new SchedulerPro({
features : {
calendarHighlight : {
// visualize resource calendars while interacting with events
calendar : 'resource'
}
}
})
This feature is disabled by default.
Configs
13
Configs
13Other
A string defining which calendar(s) to highlight during drag drop, resize or create flows.
Valid values are event or resource.
A callback function which is called when you interact with one or more events (e.g. drag drop) to highlight only available resources.
new SchedulerPro({
features : {
calendarHighlight : {
collectAvailableResources({ scheduler, eventRecords }) {
const mainEvent = eventRecords[0];
return scheduler.resourceStore.query(resource => resource.role === mainEvent.requiredRole || !mainEvent.requiredRole);
}
}
}
});
| Parameter | Type | Description |
|---|---|---|
context | Object | A context object |
context.scheduler | SchedulerPro | The scheduler instance |
context.eventRecords | EventModel[] | The event records |
An array with the available resource records
A number allowing you to expand or shrink (using a negative number) the highlighted box.
| Parameter | Type | Description |
|---|---|---|
x | Number | The horizontal amount in pixels to inflate the rectangle by (use negative value to shrink box) |
y | Number | The vertical amount in pixels to inflate the rectangle by (use negative value to shrink box) |
Misc
Properties
17
Properties
17Common
Class hierarchy
Other
A number allowing you to expand or shrink (using a negative number) the highlighted box.
| Parameter | Type | Description |
|---|---|---|
x | Number | The horizontal amount in pixels to inflate the rectangle by (use negative value to shrink box) |
y | Number | The vertical amount in pixels to inflate the rectangle by (use negative value to shrink box) |
Functions
32
Functions
32Other
Highlights the time spans representing the calendars of the passed event records, and resource records.
| Parameter | Type | Description |
|---|---|---|
eventRecords | EventModel[] | The event records |
resourceRecords | ResourceModel[] | The resource records |
clearExisting | Boolean | Provide |
Highlights the time spans representing the working time calendars of the passed resource records.
| Parameter | Type | Description |
|---|---|---|
resourceRecords | ResourceModel[] | The resource records |
clearExisting | Boolean | Provide |
Highlights the time spans representing the available time for resources that can perform the passed eventRecords. This method will call collectAvailableResources to collect the available resources.
| Parameter | Type | Description |
|---|---|---|
eventRecords | EventModel[] | The event records |
clearExisting | Boolean | Provide |
Removes all highlight elements.
Configuration
Events
Misc
Events
6
Events
6Fires on the owning Scheduler when the CalendarHighlight feature has created highlighting items which are about to be rendered.
// Adding a listener using the "on" method
calendarHighlight.on('beforeRenderCalendarHighlights', ({ source, events, resource, highlights }) => {
});| Parameter | Type | Description |
|---|---|---|
source | Scheduler | |
events | EventModel[] | The event records about to be rendered |
resource | ResourceModel | The resource for the current highlighting items |
highlights | TimeSpan[] | The highlighting items about to be rendered. It is supported to replace the value of this parameter with a new array instance. |
Event handlers
6
Event handlers
6Called on the owning Scheduler when the CalendarHighlight feature has created highlighting items which are about to be rendered.
new CalendarHighlight({
onBeforeRenderCalendarHighlights({ source, events, resource, highlights }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | Scheduler | |
events | EventModel[] | The event records about to be rendered |
resource | ResourceModel | The resource for the current highlighting items |
highlights | TimeSpan[] | The highlighting items about to be rendered. It is supported to replace the value of this parameter with a new array instance. |
Typedefs
1
Typedefs
1CSS variables
14
CSS variables
14| Name | Description |
|---|---|
--b-calendar-highlight-border-style | Highlight border style |
--b-calendar-highlight-border-width | Highlight border width |
--b-calendar-highlight-background-transparency | Highlight background transparency (primary is color mixed with transparent xx) |
--b-calendar-highlight-color | Highlight text color |
--b-calendar-highlight-background | Highlight background color |
--b-calendar-highlight-border-color | Highlight border color |