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.

Calendar highlight
//<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

Common

disabledInstancePlugin
listenersEvents

Other

calendar: event | resource= event

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

A context object

context.schedulerSchedulerPro

The scheduler instance

context.eventRecordsEventModel[]

The event records

Returns: ResourceModel[] -

An array with the available resource records

inflate: Number | ObjectAlso a property

A number allowing you to expand or shrink (using a negative number) the highlighted box.

ParameterTypeDescription
xNumber

The horizontal amount in pixels to inflate the rectangle by (use negative value to shrink box)

yNumber

The vertical amount in pixels to inflate the rectangle by (use negative value to shrink box)

Misc

clientInstancePlugin
localeClassLocalizable
localizableLocalizable
tabIndexResourceTimeRangesBase

Properties

17

Common

disabledInstancePlugin

Class hierarchy

isCalendarHighlight: Boolean= truereadonly
Identifies an object as an instance of CalendarHighlight class, or subclass thereof.
isCalendarHighlight: Boolean= truereadonlystatic
Identifies an object as an instance of CalendarHighlight class, or subclass thereof.
isEventsEvents
isInstancePluginInstancePlugin
isLocalizableLocalizable
isResourceTimeRangesBaseResourceTimeRangesBase

Other

inflate: Number | ObjectAlso a config

A number allowing you to expand or shrink (using a negative number) the highlighted box.

ParameterTypeDescription
xNumber

The horizontal amount in pixels to inflate the rectangle by (use negative value to shrink box)

yNumber

The vertical amount in pixels to inflate the rectangle by (use negative value to shrink box)

Lifecycle

configBase

Misc

clientInstancePlugin
localeHelperLocalizable
localeManagerLocalizable

Functions

32

Other

Highlights the time spans representing the calendars of the passed event records, and resource records.

ParameterTypeDescription
eventRecordsEventModel[]

The event records

resourceRecordsResourceModel[]

The resource records

clearExistingBoolean

Provide false to leave previous highlight elements

Highlights the time spans representing the working time calendars of the passed resource records.

ParameterTypeDescription
resourceRecordsResourceModel[]

The resource records

clearExistingBoolean

Provide false to leave previous highlight elements

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.

ParameterTypeDescription
eventRecordsEventModel[]

The event records

clearExistingBoolean

Provide false to leave previous highlight elements

Removes all highlight elements.

LstaticLocalizable
onEvents
relayAllEvents
triggerEvents
unEvents

Configuration

applyDefaultsstaticBase

Events

Lifecycle

destroystaticBase

Misc

doDisableInstancePlugin
initClassstaticBase
isOfTypeNamestaticBase
mixinstaticBase
optionalLstaticLocalizable

Events

6

Fires 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 }) => {

});
ParameterTypeDescription
sourceScheduler
eventsEventModel[]

The event records about to be rendered

resourceResourceModel

The resource for the current highlighting items

highlightsTimeSpan[]

The highlighting items about to be rendered. It is supported to replace the value of this parameter with a new array instance.

catchAllEvents
destroyEvents
disableInstancePlugin
enableInstancePlugin

Event handlers

6

Called 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 }) {

    }
});
ParameterTypeDescription
sourceScheduler
eventsEventModel[]

The event records about to be rendered

resourceResourceModel

The resource for the current highlighting items

highlightsTimeSpan[]

The highlighting items about to be rendered. It is supported to replace the value of this parameter with a new array instance.

onDestroyEvents
onDisableInstancePlugin
onEnableInstancePlugin

Typedefs

1

CSS variables

14
NameDescription
--b-calendar-highlight-border-styleHighlight border style
--b-calendar-highlight-border-widthHighlight border width
--b-calendar-highlight-background-transparencyHighlight background transparency (primary is color mixed with transparent xx)
--b-calendar-highlight-colorHighlight text color
--b-calendar-highlight-backgroundHighlight background color
--b-calendar-highlight-border-colorHighlight border color