diff --git a/src/Calendar.js b/src/Calendar.js
index 5426f3d02..6025cda32 100644
--- a/src/Calendar.js
+++ b/src/Calendar.js
@@ -1,28 +1,28 @@
+import clsx from 'clsx'
import PropTypes from 'prop-types'
import React from 'react'
import { uncontrollable } from 'uncontrollable'
-import clsx from 'clsx'
import {
accessor,
+ views as componentViews,
dateFormat,
dateRangeFormat,
DayLayoutAlgorithmPropType,
- views as componentViews,
} from './utils/propTypes'
-import { notify } from './utils/helpers'
-import { navigate, views } from './utils/constants'
import { mergeWithDefaults } from './localizer'
+import NoopWrapper from './NoopWrapper'
+import Toolbar from './Toolbar'
+import { navigate, views } from './utils/constants'
+import { notify } from './utils/helpers'
import message from './utils/messages'
import moveDate from './utils/move'
import VIEWS from './Views'
-import Toolbar from './Toolbar'
-import NoopWrapper from './NoopWrapper'
-import omit from 'lodash/omit'
import defaults from 'lodash/defaults'
-import transform from 'lodash/transform'
import mapValues from 'lodash/mapValues'
+import omit from 'lodash/omit'
+import transform from 'lodash/transform'
import { wrapAccessor } from './utils/accessors'
function viewNames(_views) {
@@ -632,6 +632,13 @@ class Calendar extends React.Component {
*/
enableAutoScroll: PropTypes.bool,
+ /**
+ * Determines the layout of resource groups in the calendar.
+ * When `true`, resources will be grouped by date in the week view.
+ * When `false`, resources will be grouped by week.
+ */
+ resourceGroupingLayout: PropTypes.bool,
+
/**
* Specify a specific culture code for the Calendar.
*
@@ -1008,6 +1015,7 @@ class Calendar extends React.Component {
toolbar,
events,
backgroundEvents,
+ resourceGroupingLayout,
style,
className,
elementProps,
@@ -1071,6 +1079,7 @@ class Calendar extends React.Component {
onSelectSlot={this.handleSelectSlot}
onShowMore={onShowMore}
doShowMoreDrillDown={doShowMoreDrillDown}
+ resourceGroupingLayout={resourceGroupingLayout}
/>
)
diff --git a/src/TimeGrid.js b/src/TimeGrid.js
index 4ae83354b..ae0cff36b 100644
--- a/src/TimeGrid.js
+++ b/src/TimeGrid.js
@@ -1,21 +1,21 @@
-import React, { Component, createRef } from 'react'
-import PropTypes from 'prop-types'
import clsx from 'clsx'
import * as animationFrame from 'dom-helpers/animationFrame'
import memoize from 'memoize-one'
+import PropTypes from 'prop-types'
+import React, { Component, createRef } from 'react'
+import getPosition from 'dom-helpers/position'
+import getWidth from 'dom-helpers/width'
import DayColumn from './DayColumn'
-import TimeGutter from './TimeGutter'
-import TimeGridHeader from './TimeGridHeader'
import PopOverlay from './PopOverlay'
-
-import getWidth from 'dom-helpers/width'
-import getPosition from 'dom-helpers/position'
+import TimeGridHeader from './TimeGridHeader'
+import TimeGridHeaderResources from './TimeGridHeaderResources'
+import TimeGutter from './TimeGutter'
import { views } from './utils/constants'
import { inRange, sortEvents } from './utils/eventLevels'
import { notify } from './utils/helpers'
-import Resources from './utils/Resources'
import { DayLayoutAlgorithmPropType } from './utils/propTypes'
+import Resources from './utils/Resources'
export default class TimeGrid extends Component {
constructor(props) {
@@ -131,56 +131,159 @@ export default class TimeGrid extends Component {
})
}
- renderEvents(range, events, backgroundEvents, now) {
- let { min, max, components, accessors, localizer, dayLayoutAlgorithm } =
- this.props
-
- const resources = this.memoizedResources(this.props.resources, accessors)
- const groupedEvents = resources.groupEvents(events)
- const groupedBackgroundEvents = resources.groupEvents(backgroundEvents)
+ renderDayColumn(
+ date,
+ id,
+ resource,
+ groupedEvents,
+ groupedBackgroundEvents,
+ localizer,
+ accessors,
+ components,
+ dayLayoutAlgorithm,
+ now
+ ) {
+ let { min, max } = this.props
+
+ let daysEvents = (groupedEvents.get(id) || []).filter((event) =>
+ localizer.inRange(
+ date,
+ accessors.start(event),
+ accessors.end(event),
+ 'day'
+ )
+ )
- return resources.map(([id, resource], i) =>
- range.map((date, jj) => {
- let daysEvents = (groupedEvents.get(id) || []).filter((event) =>
- localizer.inRange(
- date,
- accessors.start(event),
- accessors.end(event),
- 'day'
- )
+ let daysBackgroundEvents = (groupedBackgroundEvents.get(id) || []).filter(
+ (event) =>
+ localizer.inRange(
+ date,
+ accessors.start(event),
+ accessors.end(event),
+ 'day'
)
+ )
- let daysBackgroundEvents = (
- groupedBackgroundEvents.get(id) || []
- ).filter((event) =>
- localizer.inRange(
- date,
- accessors.start(event),
- accessors.end(event),
- 'day'
- )
- )
+ return (
+