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.
//<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
Configs
13Other
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.
The Model class to use for representing a ResourceTimeRangeModel
Misc
Properties
17
Properties
17Common
Class hierarchy
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.
Functions
29
Functions
29DOM
Returns a resource nonworking time range record from the passed element
| Parameter | Type | Description |
|---|---|---|
rangeElement | HTMLElement |
Configuration
Events
Misc
Other
Events
12
Events
12Triggered 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 }) => {
});| Parameter | Type | Description |
|---|---|---|
source | SchedulerPro | This Scheduler |
feature | ResourceNonWorkingTime | The ResourceNonWorkingTime feature |
resourceTimeRangeRecord | ResourceTimeRangeModel | Resource time range record |
resourceRecord | ResourceModel | Resource record |
domEvent | MouseEvent | 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 }) => {
});| Parameter | Type | Description |
|---|---|---|
source | SchedulerPro | This Scheduler |
feature | ResourceNonWorkingTime | The ResourceNonWorkingTime feature |
resourceTimeRangeRecord | ResourceTimeRangeModel | Resource time range record |
resourceRecord | ResourceModel | Resource record |
domEvent | MouseEvent | 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 }) => {
});| Parameter | Type | Description |
|---|---|---|
source | SchedulerPro | This Scheduler |
feature | ResourceNonWorkingTime | The ResourceNonWorkingTime feature |
resourceTimeRangeRecord | ResourceTimeRangeModel | Resource time range record |
resourceRecord | ResourceModel | Resource record |
domEvent | MouseEvent | 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 }) => {
});| Parameter | Type | Description |
|---|---|---|
source | SchedulerPro | This Scheduler |
feature | ResourceNonWorkingTime | The ResourceNonWorkingTime feature |
resourceTimeRangeRecord | ResourceTimeRangeModel | Resource time range record |
resourceRecord | ResourceModel | Resource record |
domEvent | MouseEvent | 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 }) => {
});| Parameter | Type | Description |
|---|---|---|
source | SchedulerPro | This Scheduler |
feature | ResourceNonWorkingTime | The ResourceNonWorkingTime feature |
resourceTimeRangeRecord | ResourceTimeRangeModel | Resource time range record |
resourceRecord | ResourceModel | Resource record |
domEvent | MouseEvent | 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 }) => {
});| Parameter | Type | Description |
|---|---|---|
source | SchedulerPro | This Scheduler |
feature | ResourceNonWorkingTime | The ResourceNonWorkingTime feature |
resourceTimeRangeRecord | ResourceTimeRangeModel | Resource time range record |
resourceRecord | ResourceModel | Resource record |
domEvent | MouseEvent | 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 }) => {
});| Parameter | Type | Description |
|---|---|---|
source | SchedulerPro | This Scheduler |
feature | ResourceNonWorkingTime | The ResourceNonWorkingTime feature |
resourceTimeRangeRecord | ResourceTimeRangeModel | Resource time range record |
resourceRecord | ResourceModel | Resource record |
domEvent | MouseEvent | Browser event |
Event handlers
12
Event handlers
12Called 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 }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | SchedulerPro | This Scheduler |
feature | ResourceNonWorkingTime | The ResourceNonWorkingTime feature |
resourceTimeRangeRecord | ResourceTimeRangeModel | Resource time range record |
resourceRecord | ResourceModel | Resource record |
domEvent | MouseEvent | 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 }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | SchedulerPro | This Scheduler |
feature | ResourceNonWorkingTime | The ResourceNonWorkingTime feature |
resourceTimeRangeRecord | ResourceTimeRangeModel | Resource time range record |
resourceRecord | ResourceModel | Resource record |
domEvent | MouseEvent | 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 }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | SchedulerPro | This Scheduler |
feature | ResourceNonWorkingTime | The ResourceNonWorkingTime feature |
resourceTimeRangeRecord | ResourceTimeRangeModel | Resource time range record |
resourceRecord | ResourceModel | Resource record |
domEvent | MouseEvent | 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 }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | SchedulerPro | This Scheduler |
feature | ResourceNonWorkingTime | The ResourceNonWorkingTime feature |
resourceTimeRangeRecord | ResourceTimeRangeModel | Resource time range record |
resourceRecord | ResourceModel | Resource record |
domEvent | MouseEvent | 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 }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | SchedulerPro | This Scheduler |
feature | ResourceNonWorkingTime | The ResourceNonWorkingTime feature |
resourceTimeRangeRecord | ResourceTimeRangeModel | Resource time range record |
resourceRecord | ResourceModel | Resource record |
domEvent | MouseEvent | 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 }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | SchedulerPro | This Scheduler |
feature | ResourceNonWorkingTime | The ResourceNonWorkingTime feature |
resourceTimeRangeRecord | ResourceTimeRangeModel | Resource time range record |
resourceRecord | ResourceModel | Resource record |
domEvent | MouseEvent | 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 }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | SchedulerPro | This Scheduler |
feature | ResourceNonWorkingTime | The ResourceNonWorkingTime feature |
resourceTimeRangeRecord | ResourceTimeRangeModel | Resource time range record |
resourceRecord | ResourceModel | Resource record |
domEvent | MouseEvent | Browser event |
Typedefs
1
Typedefs
1CSS variables
12
CSS variables
12| Name | Description |
|---|---|
--b-resource-non-working-time-opacity | Resource non-working time opacity |
--b-resource-non-working-time-background | Resource non-working time background color |
--b-resource-non-working-time-color | Resource non-working time color |
--b-resource-non-working-time-zindex | Resource non-working time canvas z-index |