ResourceNonWorkingTime
Feature
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> 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.
Useful configs
| Config | Description |
|---|---|
| maxTimeAxisUnit | Largest unit to render non-working time |
| enableMouseEvents | Enable mouse interaction with ranges |
See also
- CalendarModel — Defines working and non-working time intervals
- CalendarHighlight — Highlights event or resource calendars during interactions
- calendar — The resource field linking to a calendar
Configs
Configs are options you supply in a configuration object when creating an instance of this class-
Set to
trueto 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.Has a corresponding runtime enableMouseEvents property.
-
The Model class to use for representing a ResourceTimeRangeModel
-
Internal listeners, that cannot be removed by the user.
-
The widget which this plugin is to attach to.
Has a corresponding runtime client property.
-
Set to
falseto disable localization of this object. -
Specify value to use for the tabIndex attribute of range elements
Properties
Properties are getters/setters or publicly accessible variables on this class-
Identifies an object as an instance of Events class, or subclass thereof.
-
Identifies an object as an instance of Localizable class, or subclass thereof.
-
Identifies an object as an instance of ResourceNonWorkingTime class, or subclass thereof.
-
A class property getter for the default values of internal properties for this class.
-
Set to
trueto 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.Has a corresponding enableMouseEvents config.
-
An empty array that can be used as a default value.
-
An empty object that can be used as a default value.
-
Identifies an object as an instance of InstancePlugin class, or subclass thereof.
-
Identifies an object as an instance of ResourceNonWorkingTime class, or subclass thereof.
-
Identifies an object as an instance of ResourceTimeRangesBase class, or subclass thereof.
-
Returns a copy of the full configuration which was used to configure this object.
-
This property is set to
truebefore theconstructorreturns. -
This property is set to
trueon entry to the destroy method. It remains on the objects after returning fromdestroy(). If isDestroyed istrue, this property will also betrue, so there is no need to test for both (for example,comp.isDestroying || comp.isDestroyed). -
The Widget which was passed into the constructor, which is the Widget we are providing extra services for.
Has a corresponding client config.
-
Get the global LocaleHelper
-
Get the global LocaleManager
Functions
Functions are methods available for calling on the class-
This optional class method is called when a class is mixed in using the mixin() method.
-
Registers this class type with its Factory
-
Internal function used to hook destroy() calls when using thisObj
-
Internal function used restore hooked destroy() calls when using thisObj
-
Auto detaches listeners registered from start, if set as detachable
-
Internal function used to run a callback function after an event is triggered
-
Removes all listeners registered to this object by the application.
-
This will merge a feature's (subclass of InstancePlugin) keyMap with it's client's keyMap.
Events
Events are triggered for certain actions in this class and can be listened for to react to those actions in your codeEvent handlers
Event handlers are callbacks called as a result of certain actions in this classCSS variables
CSS variables that can be set to adjust appearance| Name | Description |
|---|---|
| --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-opacity | Resource non-working time opacity |
| --b-resource-non-working-time-zindex | Resource non-working time canvas z-index |