ResourceView

A Calendar view which encapsulates a series of child Calendar views, one for each resource (often referred to as "calendar") in the project.

This view is a Panel which contains calendar views such as WeekView as child views. To configure the child views, use the view config.

The type of view displayed defaults to 'week', but this can be changed using the type property in the view config object.

Usage :

new Calendar({
    appendTo : domElement,

    // Resource avatar images are loaded from this path
    resourceImagePath : '../_shared/images/users/',

    modes : {
        // Let's not show the default views
        day    : null,
        week   : null,
        month  : null,
        year   : null,
        agenda : null,

        // Mode name can be anything if it contains a "type" property.
        monthResourceview : {
            // Type has the final say over which view type is created
            type : 'resource',

            // This is a config object for the subviews; one for each resource
            view : {
                // We show a month view for each resource in the project
                type : 'month'
            }
        }
    }
});

Resource view
//<code-header>
fiddle.title = 'Resource view';
//</code-header>
const dayView = new ResourceView({
    appendTo           : targetElement,
    height             : 500,
    date               : new Date(2020, 8, 2),
    dayStartTime       : 6,
    dayEndTime         : 19,
    visibleStartTime   : 6,
    resourceWidth      : '30em',
    hideNonWorkingDays : true,
    resources          : [
        {
            id         : 1,
            name       : 'John',
            eventColor : 'blue'
        },
        {
            id         : 2,
            name       : 'Mike',
            eventColor : 'orange'
        },
        {
            id         : 3,
            name       : 'Lisa',
            eventColor : 'red'
        }
    ],
    events : [
        { startDate : '2020-09-02T10:00', duration : 5, durationUnit : 'h', name : 'Studies', eventColor : 'red', resourceId : 1 },
        { startDate : '2020-09-02T07:00', duration : 5, durationUnit : 'h', name : 'Walk the dog', eventColor : 'yellow', resourceId : 2 },
        { startDate : '2020-09-03T09:00', duration : 2, durationUnit : 'h', name : 'Buy groceries', eventColor : 'orange', resourceId : 2 },
        { startDate : '2020-09-04T07:00', duration : 1, durationUnit : 'h', name : 'Zoom meeting', eventColor : 'deep-orange', resourceId : 1 },
        { startDate : '2020-09-05T09:00', duration : 1, durationUnit : 'h', name : 'Get a haircut', eventColor : 'gray', resourceId : 1 }
    ]
});

Configs

151

Common

listenersEvents

Other

eventRenderer: function | String

A function, or the name of a function in the ownership hierarchy which you can specify to customize event DOM content.

This function is called each time an event is rendered to allow developers to mutate the cell metadata, or the CSS classes to be applied to the event element.

It's called with the event record, and a eventData object which allows you to mutate event metadata such as cls, style.

The cls property is an object whose property names will be added to the event element if the property value is truthy.

The style property is an object containing style properties for the event element.

A non-null return value from the renderer is used as the event body content. A nullish return value causes the default renderer to be used which just uses the event name.

If a string is returned, it is used as the HTML content of the event body element.

If an object is returned, it is used as a DomConfig object to create complex content in the event body element.

You should never modify any records inside this method.
 eventRenderer({ eventRecord, renderData }) {
     if (eventRecord.name === 'Doctors appointment') {
         renderData.style.fontWeight = 'bold';
         renderData.cls['custom-cls'] = 1;

         return 'Special doctors appointment';
     }
 }

IMPORTANT: When returning content, be sure to consider how that content should be encoded to avoid XSS (Cross-Site Scripting) attacks. This is especially important when including user-controlled data such as the event's name. The function encodeHtml as well as xss can be helpful in these cases.

For example:

 eventRenderer({ eventRecord }) {
     return StringHelper.xss`Event: ${eventRecord.name}`;
 }
ParameterTypeDescription
detailObject

An object that contains data about the event being rendered

detail.viewCalendarView

The view rendering the event

detail.eventRecordEventModel

The event record

detail.resourceRecordResourceModel

The Resource record

detail.renderDataObject

A data object containing properties that will be used to create the event element

detail.renderData.styleObject

The style property is an object containing style properties for the event element

detail.renderData.clsObject

The cls property is an object whose property names will be added to the event element if the property value is truthy

detail.renderData.iconStyleObject

The iconStyle property is an object containing style properties for the icon element if an icon element is to be used

detail.renderData.iconClsObject

The iconCls property is an object whose property names will be added to the icon element. Initially set from the event record's iconCls. Can be mutated by the renderer. If null, or no properties are set, no icon will be rendered

detail.renderData.eventColorString

Color to be applied to the event

detail.renderData.datasetObject

An object which produces the dataset of the resulting event bar

detail.renderData.solidBarBoolean

This is valid for views which create event bars. This is set to true by default for all day and interday events so that these appear as a solid block of background color. An eventRenderer may mutate this flag to change in what manner the event bar is coloured - as a solid bar of colour, or using the foreground colour (text and icons) such as the MonthView, the CalendarRow (all day events in a DayView), and OverflowPopups

detail.renderData.bodyColorString

When used in a DayView, this color is applied to the body of the event element. Note that this must be light enough that the text colour (From the SASS variable $dayview-event-color) is visible

detail.renderData.showBulletBoolean

If there is no iconCls, and the event is not recurring, then by default a "bullet" circular icon is shown if the view's showBullet if set. Setting this property in an event renderer overrides this behaviour.

Returns: DomConfig | DomConfig[] | String | null

Set to true to hide non-working days

includeTimeRanges: Boolean= false

When ResourceTimeRangeModels are included in the data, they are only rendered in subviews of ResourceViews and normal TimeRangeModels are not rendered in subviews of ResourceViews.

Set this to true to render normal TimeRangeModels in subviews of this view.

meta: String | function

A field name or a function returning a string to be displayed below resource name in the resource view headers.

const calendar = new Calendar({
    modes : {
        // Mode name can be anything if it contains a "type" property.
        weekResources : {
            type  : 'resource',
            // Get meta string to display
            meta : resource => resource.title
        }
    }
});
ParameterTypeDescription
resourceResourceModel

Displayed resource

Returns: String -

Text to be displayed below resource name

If the displayed view is a DateRangeOwner, this may be used to set the range of all child views.

The width of a resource calendar panel (view always stretches to fill window)

showAvatars: Boolean= true

Display an avatar in the resource view headers, either as an image or using resource initials.

Looks for an image name in the imageUrl and image fields on the resource. Set resourceImagePath on Calendar to specify where to load images from. If no image is found, resource initials are displayed.

stableResourceOrder: Boolean= true

By default, the resource views are displayed in the order that the resources appear in the project's resourceStore, so they will appear in a stable position, meaning when a view is filtered out, then filtering it in will replace it in the same position.

If this config is false, re-adding a view will place it at the end.

A config object used to configure the sub views. The default type used is 'weekview'

After instantiation, while in use, changes to the view property, will be propagated to all child views.

This property may be used to adjust properties of every child view of the resource view in one statement.

viewGap: String | Number= 0.5emAlso a property

The space to leave between each subview.

activationKeyCalendarMixin
allowDragCreateCalendarMixin
allowDragMoveCalendarMixin
allowDragResizeCalendarMixin
animateTimeShiftCalendarMixin
autoCreateCalendarMixin
columnWidget
defaultFocusContainer
descriptionRendererCalendarMixin
dragUnitCalendarMixin
drawerPanel
eventHeightCalendarMixin
eventSorterCalendarMixin
extendAllDayEndDayCalendarMixin
labelPositionContainer
maxDateCalendarMixin
minDateCalendarMixin
nonWorkingDaysCalendarMixin
pastEventClsCalendarMixin
renditionContainer
resourceImagePathCalendarMixin
responsiveResponsive
responsiveRootResponsive
responsiveStateResponsive
rtlRTL
selectorButtonCalendarMixin
selectorMenuItemCalendarMixin
shortDateFormatCalendarMixin
shortDateTimeFormatCalendarMixin
shortEventClsCalendarMixin
shortEventDurationCalendarMixin
showBulletCalendarMixin
showResourceAvatarsCalendarMixin
spanWidget
syncCalendarDateCalendarMixin
syncViewDateCalendarMixin
timeFormatCalendarMixin
weekStartDayCalendarMixin

Accessibility

ariaLabelWidget
keyMapKeyMap

Content

bbarPanel
defaultsContainer
footerPanel
headerPanel
itemsContainer
lazyItemsContainer
namedItemsContainer
stripsPanel
tbarPanel
textContentContainer
toolsPanel

CSS

bodyClsPanel
borderContainer
clsWidget
colorWidget
htmlClsWidget
itemClsContainer
styleWidget
uiPanel

DOM

adoptWidget
appendToWidget
contentWidget
datasetWidget
htmlWidget
idWidget
tagWidget

Float & align

alignWidget
anchorWidget
centeredWidget
draggableWidget
floatingWidget
xWidget
yWidget

Layout

alignSelfWidget
dockWidget
flexWidget
heightWidget
hiddenWidget
hideWhenEmptyContainer
layoutContainer
layoutStyleContainer
marginWidget
maxHeightWidget
maxWidthWidget
minHeightWidget
minWidthWidget
textAlignWidget
weightWidget
widthWidget

misc

tabBarItemsContainer

Misc

dataFieldWidget
disabledWidget
iconPanel
localeClassLocalizable
localizableLocalizable
maskedWidget
ownerWidget
readOnlyWidget
refWidget
rippleWidget
tabWidget
titlePanel
tooltipWidget

Record

recordContainer

Scrolling

State

stateIdState

Properties

130

Class hierarchy

isResourceView: Boolean= truereadonly
Identifies an object as an instance of ResourceView class, or subclass thereof.
isResourceView: Boolean= truereadonlystatic
Identifies an object as an instance of ResourceView class, or subclass thereof.
isCalendarMixinCalendarMixin
isContainerContainer
isDelayableDelayable
isEventsEvents
isKeyMapKeyMap
isLocalizableLocalizable
isPanelPanel
isResponsiveResponsive
isStateState
isToolableToolable
isWidgetWidget

Other

fixedDuration: Booleanreadonly

Returns the value of the child view's fixedDuration property.

Set to true to hide non-working days

If the displayed view is a DateRangeOwner, this may be used to set the range of all child views.

The width of a resource calendar panel (view always stretches to fill window)

A config object used to configure the sub views. The default type used is 'weekview'

After instantiation, while in use, changes to the view property, will be propagated to all child views.

This property may be used to adjust properties of every child view of the resource view in one statement.

viewGap: String | Number= 0.5emAlso a config

The space to leave between each subview.

views: CalendarMixin[]readonly

Yields the views which this ResourceView owns.

$namestaticWidget
allowDragCreateCalendarMixin
allowDragMoveCalendarMixin
allowDragResizeCalendarMixin
animateTimeShiftCalendarMixin
autoCreateCalendarMixin
columnWidget
dayCellClsCalendarMixin
dragUnitCalendarMixin
durationCalendarMixin
eventCountCalendarMixin
extendAllDayEndDayCalendarMixin
firstItemContainer
firstVisibleCellCalendarMixin
firstVisibleDateCalendarMixin
hasChangesContainer
isValidContainer
itemsContainer
labelPositionContainer
lastItemContainer
lastVisibleCellCalendarMixin
lastVisibleDateCalendarMixin
maxDateCalendarMixin
minDateCalendarMixin
modeNameCalendarMixin
nonWorkingDaysCalendarMixin
pastEventClsCalendarMixin
renditionContainer
rtlRTL
shortDateFormatCalendarMixin
shortDateTimeFormatCalendarMixin
spanWidget
stepUnitCalendarMixin
syncCalendarDateCalendarMixin
syncViewDateCalendarMixin
toolsPanel
typestaticWidget
valuesContainer
visibleCellSelectorCalendarMixin

Accessibility

keyMapKeyMap

Content

bbarPanel
tbarPanel

CSS

clsWidget

DOM

appendToWidget
contentWidget
datasetWidget
elementWidget
htmlWidget
idWidget
styleWidget

Float & align

xWidget
yWidget

Layout

alignSelfWidget
flexWidget
heightWidget
layoutContainer
layoutStyleContainer
marginWidget
maxHeightWidget
maxWidthWidget
minHeightWidget
minWidthWidget
widthWidget

Lifecycle

configBase

Misc

cellInfoWidget
disabledWidget
localeHelperLocalizable
localeManagerLocalizable
readOnlyWidget
refWidget
tabWidget
titlePanel
tooltipWidget

Record

recordContainer

State

stateState

Visibility

hiddenWidget
isVisibleWidget

Widget hierarchy

ownerWidget
parentWidget
widgetMapContainer

Functions

91

Other

Executes the passed function for each child view corresponding to each resource in the resourceStore.

ParameterTypeDescription
fnfunction

The function to call.

argsObject[]

The arguments to pass. Defaults to the view being called followed by its index.

thisObjObject

The this reference for the function. Defaults to the view being called.

addContainer
calendarHitTestCalendarMixin
composeWidget
createEventCalendarMixin
createOnFrameDelayable
disableWidget
enableWidget
focusWidget
getAtContainer
getDayElementCalendarMixin
getEventElementCalendarMixin
getEventElementsCalendarMixin
getEventRecordCalendarMixin
getResourceRecordCalendarMixin
getTimeRangesCalendarMixin
getWidgetByIdContainer
insertContainer
isTodayCalendarMixin
LstaticLocalizable
maskWidget
nextCalendarMixin
onEvents
onEventCreatedCalendarMixin
previousCalendarMixin
recomposeWidget
refreshCalendarMixin
refreshSoonCalendarMixin
relayAllEvents
removeContainer
removeAllContainer
resetValuesContainer
resolveEventRecordCalendarMixin
scrollToCalendarMixin
setValuesContainer
triggerEvents
unEvents
unmaskWidget

Configuration

applyDefaultsstaticBase

Events

Float & align

alignToWidget
setXYWidget
showByWidget
toFrontWidget

Lifecycle

createstaticWidget
destroystaticBase
initClassstaticWidget

Misc

attachTooltipstaticWidget
fromElementstaticWidget
fromSelectorstaticWidget
getByIdstaticWidget
isOfTypeNamestaticBase
mixinstaticBase
optionalLstaticLocalizable

State

Visibility

hideWidget
showWidget

Widget hierarchy

closestWidget
containsWidget
ownsWidget
queryWidget
queryAllWidget
upWidget

Events

28

Fires when this ResourceView refreshes.

// Adding a listener using the "on" method
resourceView.on('refresh', ({ source }) => {

});
ParameterTypeDescription
sourceResourceView

The triggering instance.

Fires when a new sub view is created.

// Adding a listener using the "on" method
resourceView.on('viewCreate', ({ source, view }) => {

});
ParameterTypeDescription
sourceResourceView

The triggering instance.

viewCalendarView

The newly created sub view.

beforeAutoCreateCalendarMixin
beforeChangeDateCalendarMixin
catchAllEvents
destroyEvents
eventAutoCreatedCalendarMixin
expandPanel
focusInWidget
focusOutWidget
hideWidget
paintWidget
readOnlyWidget
recomposeWidget
resizeWidget
showWidget

Event handlers

28

Called when this ResourceView refreshes.

new ResourceView({
    onRefresh({ source }) {

    }
});
ParameterTypeDescription
sourceResourceView

The triggering instance.

Called when a new sub view is created.

new ResourceView({
    onViewCreate({ source, view }) {

    }
});
ParameterTypeDescription
sourceResourceView

The triggering instance.

viewCalendarView

The newly created sub view.

onBeforeAutoCreateCalendarMixin
onBeforeChangeDateCalendarMixin
onDestroyEvents
onEventAutoCreatedCalendarMixin
onFocusInWidget
onHideWidget
onPaintWidget
onResizeWidget
onShowWidget

Typedefs

8

CSS variables

53
NameDescription
--b-resource-view-header-heightResource header height

Inherited