ResourceNonWorkingTime

Feature that highlights the non-working intervals for resources based on their calendar. If a resource has no calendar defined, the project's calendar will be used. The non-working time interval can also be recurring. You can find a live example showing how to achieve this in the Resource Non-Working Time Demo.

Resource non-working time
//<code-header>
fiddle.title = 'Resource non-working time';
CSSHelper.insertRule('.b-sch-resource-time-range.nonworking { background: transparent repeating-linear-gradient(-55deg, var(--b-neutral-94), var(--b-neutral-94) 10px, var(--b-neutral-99) 5px, var(--b-neutral-98) 20px); }', targetElement.getRootNode());
//</code-header>
const schedulerPro = new SchedulerPro({
    appendTo : targetElement,

    // makes scheduler as high as it needs to be to fit rows
    autoHeight : true,

    startDate : new Date(2022, 7, 2),
    endDate   : new Date(2022, 7, 14),

    columns : [
        { field : 'name', text : 'Name' },
        { field : 'calendar', text : 'Working on', editor : false }
    ],

    features : {
        nonWorkingTime         : true,
        resourceNonWorkingTime : {
            maxTimeAxisUnit : 'week'
        }
    },

    project : {
        resources : [
            { id : 1, name : 'Bernard', calendar : 'weekends' },
            { id : 2, name : 'Bianca', calendar : 'weekdays' }
        ],

        calendars : [
            {
                id                       : 'weekends',
                name                     : 'Weekends',
                unspecifiedTimeIsWorking : true,
                intervals                : [
                    {
                        recurrentStartDate : 'on Mon',
                        recurrentEndDate   : 'on Sat',
                        isWorking          : false,
                        cls                : 'nonworking'
                    }
                ]
            },
            {
                id                       : 'weekdays',
                name                     : 'Weekdays',
                unspecifiedTimeIsWorking : true,
                intervals                : [
                    {
                        recurrentStartDate : 'on Sat',
                        recurrentEndDate   : 'on Mon',
                        isWorking          : false,
                        cls                : 'weekend'
                    }
                ]
            }
        ]
    }
});

Data structure

Example data defining calendars and assigning the resources a calendar:

{
  "success"   : true,
  "calendars" : {
      "rows" : [
          {
              "id"                       : "day",
              "name"                     : "Day shift",
              "unspecifiedTimeIsWorking" : false,
              "cls"                      : "dayshift",
              "intervals"                : [
                  {
                      "recurrentStartDate" : "at 8:00",
                      "recurrentEndDate"   : "at 17:00",
                      "isWorking"          : true,
                  }
              ]
          }
   ],
   "resources" : {
      "rows" : [
          {
              "id"         : 1,
              "name"       : "George",
              "calendar"   : "day",
              "role"       : "Office",
              "eventColor" : "blue"
          },
          {
              "id"         : 2,
              "name"       : "Rob",
              "calendar"   : "day",
              "role"       : "Office",
              "eventColor" : "blue"
          }
       ]
  [...]
const scheduler = new SchedulerPro({
  // A Project holding the data and the calculation engine for Scheduler Pro. It also acts as a CrudManager, allowing
  // loading data into all stores at once
  project : {
      autoLoad  : true,
      transport : {
          load : {
              url : './data/data.json'
          }
      }
  },
  features : {
      resourceNonWorkingTime : true
  },
  [...]
}):

Styling non-working time interval elements

To style the elements representing the non-working time elements you can set the cls field in your data. This will add a CSS class to all non-working time elements for the calendar. You can also add an iconCls value specifying an icon to display inside the interval.

{
  "success"   : true,
  "calendars" : {
      "rows" : [
          {
              "id"                       : "day",
              "name"                     : "Day shift",
              "unspecifiedTimeIsWorking" : false,
              "cls"                      : "dayshift",
              "intervals"                : [
                  {
                      "recurrentStartDate" : "at 8:00",
                      "recurrentEndDate"   : "at 17:00",
                      "isWorking"          : true
                  }
              ]
          }
      ]
   }
}

You can also add a cls value and an iconCls to individual intervals:

{
  "success"   : true,
  "calendars" : {
      "rows" : [
          {
              "id"                       : "day",
              "name"                     : "Day shift",
              "unspecifiedTimeIsWorking" : true,
              "intervals"                : [
                  {
                     "startDate"          : "2022-03-23T02:00",
                     "endDate"            : "2022-03-23T04:00",
                     "isWorking"          : false,
                     "cls"                : "factoryShutdown",
                     "iconCls"            : "warningIcon"
                 }
              ]
          }
      ]
   }
}

This feature is disabled by default. For info on enabling it, see GridFeatures.

Configs

13

Common

disabledInstancePlugin
listenersEvents

Other

Set to true to allow mouse interactions with the rendered range elements. By default, the range elements are not reachable with the mouse, and only serve as a static background.

The largest time axis unit to display non working ranges for ('hour' or 'day' etc). When zooming to a view with a larger unit, no non-working time elements will be rendered.

Note: Be careful with setting this config to big units like 'year'. When doing this, make sure the timeline start and end dates are set tightly. When using a long range (for example many years) with non-working time elements rendered per hour, you will end up with millions of elements, impacting performance. When zooming, use the zoomKeepsOriginalTimespan config.

Misc

clientInstancePlugin
localeClassLocalizable
localizableLocalizable
tabIndexResourceTimeRangesBase

Properties

17

Common

disabledInstancePlugin

Class hierarchy

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

Other

Set to true to allow mouse interactions with the rendered range elements. By default, the range elements are not reachable with the mouse, and only serve as a static background.

Lifecycle

configBase

Misc

clientInstancePlugin
localeHelperLocalizable
localeManagerLocalizable

Functions

29

DOM

Returns a resource nonworking time range record from the passed element

ParameterTypeDescription
rangeElementHTMLElement

Configuration

applyDefaultsstaticBase

Events

Lifecycle

destroystaticBase

Misc

doDisableInstancePlugin
initClassstaticBase
isOfTypeNamestaticBase
mixinstaticBase
optionalLstaticLocalizable

Other

LstaticLocalizable
onEvents
relayAllEvents
triggerEvents
unEvents

Events

12

Triggered for click on a resource nonworking time range. Only triggered if the ResourceNonWorkingTime feature is configured with enableMouseEvents: true.

// Adding a listener using the "on" method
resourceNonWorkingTime.on('resourceNonWorkingTimeClick', ({ source, feature, resourceTimeRangeRecord, resourceRecord, domEvent }) => {

});
ParameterTypeDescription
sourceSchedulerPro

This Scheduler

featureResourceNonWorkingTime

The ResourceNonWorkingTime feature

resourceTimeRangeRecordResourceTimeRangeModel

Resource time range record

resourceRecordResourceModel

Resource record

domEventMouseEvent

Browser event

Triggered for right-click on a resource nonworking time range. Only triggered if the ResourceNonWorkingTime feature is configured with enableMouseEvents: true.

// Adding a listener using the "on" method
resourceNonWorkingTime.on('resourceNonWorkingTimeContextMenu', ({ source, feature, resourceTimeRangeRecord, resourceRecord, domEvent }) => {

});
ParameterTypeDescription
sourceSchedulerPro

This Scheduler

featureResourceNonWorkingTime

The ResourceNonWorkingTime feature

resourceTimeRangeRecordResourceTimeRangeModel

Resource time range record

resourceRecordResourceModel

Resource record

domEventMouseEvent

Browser event

Triggered for double-click on a resource nonworking time range. Only triggered if the ResourceNonWorkingTime feature is configured with enableMouseEvents: true.

// Adding a listener using the "on" method
resourceNonWorkingTime.on('resourceNonWorkingTimeDblClick', ({ source, feature, resourceTimeRangeRecord, resourceRecord, domEvent }) => {

});
ParameterTypeDescription
sourceSchedulerPro

This Scheduler

featureResourceNonWorkingTime

The ResourceNonWorkingTime feature

resourceTimeRangeRecordResourceTimeRangeModel

Resource time range record

resourceRecordResourceModel

Resource record

domEventMouseEvent

Browser event

Triggered for mouse down ona resource nonworking time range. Only triggered if the ResourceNonWorkingTime feature is configured with enableMouseEvents: true.

// Adding a listener using the "on" method
resourceNonWorkingTime.on('resourceNonWorkingTimeMouseDown', ({ source, feature, resourceTimeRangeRecord, resourceRecord, domEvent }) => {

});
ParameterTypeDescription
sourceSchedulerPro

This Scheduler

featureResourceNonWorkingTime

The ResourceNonWorkingTime feature

resourceTimeRangeRecordResourceTimeRangeModel

Resource time range record

resourceRecordResourceModel

Resource record

domEventMouseEvent

Browser event

Triggered for mouse out of a resource nonworking time range. Only triggered if the ResourceNonWorkingTime feature is configured with enableMouseEvents: true.

// Adding a listener using the "on" method
resourceNonWorkingTime.on('resourceNonWorkingTimeMouseOut', ({ source, feature, resourceTimeRangeRecord, resourceRecord, domEvent }) => {

});
ParameterTypeDescription
sourceSchedulerPro

This Scheduler

featureResourceNonWorkingTime

The ResourceNonWorkingTime feature

resourceTimeRangeRecordResourceTimeRangeModel

Resource time range record

resourceRecordResourceModel

Resource record

domEventMouseEvent

Browser event

Triggered for mouse over on a resource nonworking time range. Only triggered if the ResourceNonWorkingTime feature is configured with enableMouseEvents: true.

// Adding a listener using the "on" method
resourceNonWorkingTime.on('resourceNonWorkingTimeMouseOver', ({ source, feature, resourceTimeRangeRecord, resourceRecord, domEvent }) => {

});
ParameterTypeDescription
sourceSchedulerPro

This Scheduler

featureResourceNonWorkingTime

The ResourceNonWorkingTime feature

resourceTimeRangeRecordResourceTimeRangeModel

Resource time range record

resourceRecordResourceModel

Resource record

domEventMouseEvent

Browser event

Triggered for mouse up ona resource nonworking time range. Only triggered if the ResourceNonWorkingTime feature is configured with enableMouseEvents: true.

// Adding a listener using the "on" method
resourceNonWorkingTime.on('resourceNonWorkingTimeMouseUp', ({ source, feature, resourceTimeRangeRecord, resourceRecord, domEvent }) => {

});
ParameterTypeDescription
sourceSchedulerPro

This Scheduler

featureResourceNonWorkingTime

The ResourceNonWorkingTime feature

resourceTimeRangeRecordResourceTimeRangeModel

Resource time range record

resourceRecordResourceModel

Resource record

domEventMouseEvent

Browser event

catchAllEvents
destroyEvents
disableInstancePlugin
enableInstancePlugin

Event handlers

12

Called for click on a resource nonworking time range. Only called if the ResourceNonWorkingTime feature is configured with enableMouseEvents: true.

new ResourceNonWorkingTime({
    onResourceNonWorkingTimeClick({ source, feature, resourceTimeRangeRecord, resourceRecord, domEvent }) {

    }
});
ParameterTypeDescription
sourceSchedulerPro

This Scheduler

featureResourceNonWorkingTime

The ResourceNonWorkingTime feature

resourceTimeRangeRecordResourceTimeRangeModel

Resource time range record

resourceRecordResourceModel

Resource record

domEventMouseEvent

Browser event

Called for right-click on a resource nonworking time range. Only called if the ResourceNonWorkingTime feature is configured with enableMouseEvents: true.

new ResourceNonWorkingTime({
    onResourceNonWorkingTimeContextMenu({ source, feature, resourceTimeRangeRecord, resourceRecord, domEvent }) {

    }
});
ParameterTypeDescription
sourceSchedulerPro

This Scheduler

featureResourceNonWorkingTime

The ResourceNonWorkingTime feature

resourceTimeRangeRecordResourceTimeRangeModel

Resource time range record

resourceRecordResourceModel

Resource record

domEventMouseEvent

Browser event

Called for double-click on a resource nonworking time range. Only called if the ResourceNonWorkingTime feature is configured with enableMouseEvents: true.

new ResourceNonWorkingTime({
    onResourceNonWorkingTimeDblClick({ source, feature, resourceTimeRangeRecord, resourceRecord, domEvent }) {

    }
});
ParameterTypeDescription
sourceSchedulerPro

This Scheduler

featureResourceNonWorkingTime

The ResourceNonWorkingTime feature

resourceTimeRangeRecordResourceTimeRangeModel

Resource time range record

resourceRecordResourceModel

Resource record

domEventMouseEvent

Browser event

Called for mouse down ona resource nonworking time range. Only called if the ResourceNonWorkingTime feature is configured with enableMouseEvents: true.

new ResourceNonWorkingTime({
    onResourceNonWorkingTimeMouseDown({ source, feature, resourceTimeRangeRecord, resourceRecord, domEvent }) {

    }
});
ParameterTypeDescription
sourceSchedulerPro

This Scheduler

featureResourceNonWorkingTime

The ResourceNonWorkingTime feature

resourceTimeRangeRecordResourceTimeRangeModel

Resource time range record

resourceRecordResourceModel

Resource record

domEventMouseEvent

Browser event

Called for mouse out of a resource nonworking time range. Only called if the ResourceNonWorkingTime feature is configured with enableMouseEvents: true.

new ResourceNonWorkingTime({
    onResourceNonWorkingTimeMouseOut({ source, feature, resourceTimeRangeRecord, resourceRecord, domEvent }) {

    }
});
ParameterTypeDescription
sourceSchedulerPro

This Scheduler

featureResourceNonWorkingTime

The ResourceNonWorkingTime feature

resourceTimeRangeRecordResourceTimeRangeModel

Resource time range record

resourceRecordResourceModel

Resource record

domEventMouseEvent

Browser event

Called for mouse over on a resource nonworking time range. Only called if the ResourceNonWorkingTime feature is configured with enableMouseEvents: true.

new ResourceNonWorkingTime({
    onResourceNonWorkingTimeMouseOver({ source, feature, resourceTimeRangeRecord, resourceRecord, domEvent }) {

    }
});
ParameterTypeDescription
sourceSchedulerPro

This Scheduler

featureResourceNonWorkingTime

The ResourceNonWorkingTime feature

resourceTimeRangeRecordResourceTimeRangeModel

Resource time range record

resourceRecordResourceModel

Resource record

domEventMouseEvent

Browser event

Called for mouse up ona resource nonworking time range. Only called if the ResourceNonWorkingTime feature is configured with enableMouseEvents: true.

new ResourceNonWorkingTime({
    onResourceNonWorkingTimeMouseUp({ source, feature, resourceTimeRangeRecord, resourceRecord, domEvent }) {

    }
});
ParameterTypeDescription
sourceSchedulerPro

This Scheduler

featureResourceNonWorkingTime

The ResourceNonWorkingTime feature

resourceTimeRangeRecordResourceTimeRangeModel

Resource time range record

resourceRecordResourceModel

Resource record

domEventMouseEvent

Browser event

onDestroyEvents
onDisableInstancePlugin
onEnableInstancePlugin

Typedefs

1

CSS variables

12
NameDescription
--b-resource-non-working-time-opacityResource non-working time opacity
--b-resource-non-working-time-backgroundResource non-working time background color
--b-resource-non-working-time-colorResource non-working time color
--b-resource-non-working-time-zindexResource non-working time canvas z-index