Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
$scheduler-base-border: null !default;
$scheduler-base-border-color: null !default;

.dx-scheduler-week-number-label {
pointer-events: none;
user-select: none;
text-align: center;
opacity: 0.56;
font-size: 0.85em;
padding: 2px 0;
}

.dx-scheduler-work-space-day {
&:not(.dx-scheduler-work-space-count) {
&:not(.dx-scheduler-work-space-grouped) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,33 @@ $scheduler-workspace-month-text-color: null !default;
$scheduler-month-date-text-padding: null !default;
$scheduler-first-month-cell-background-color: null !default;

.dx-scheduler-week-number-cell,
.dx-scheduler-week-number-header-cell {
pointer-events: none;
user-select: none;
text-align: center;
width: 28px;
min-width: 28px;
max-width: 28px;
overflow: hidden;
opacity: 0.56;
font-size: 0.85em;
}

.dx-scheduler-week-number-cell {
vertical-align: middle;
padding: 0 2px;
}

.dx-scheduler-week-number-header-cell {
font-weight: normal;

div {
text-transform: uppercase;
letter-spacing: 0.02em;
}
}

.dx-scheduler-work-space-month {
.dx-scheduler-all-day-title {
display: none;
Expand Down
11 changes: 11 additions & 0 deletions packages/devextreme/js/__internal/scheduler/m_scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,13 @@ class Scheduler extends SchedulerOptionsBaseWidget {
_optionChanged(args: OptionChanged<SafeSchedulerOptions>): void {
this.schedulerOptionChanged(args);

const optionName = args.name as string;
if (optionName === 'showWeekNumbers' || optionName === 'weekNumberRule') {
this.updateOption('workSpace', optionName, args.value);
this.repaint();
return;
}

const { value, name } = args;

switch (args.name) {
Expand Down Expand Up @@ -1519,6 +1526,10 @@ class Scheduler extends SchedulerOptionsBaseWidget {
focusStateEnabled: this.option('focusStateEnabled'),
cellDuration: this.option('cellDuration'),
showAllDayPanel: this.option('showAllDayPanel'),
// eslint-disable-next-line @typescript-eslint/no-explicit-any
showWeekNumbers: (this as any).option('showWeekNumbers') ?? false,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
weekNumberRule: (this as any).option('weekNumberRule') ?? 'auto',
showCurrentTimeIndicator: this.option('showCurrentTimeIndicator'),
indicatorTime: this.option('indicatorTime'),
indicatorUpdateInterval: this.option('indicatorUpdateInterval'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export interface DateHeaderProps extends PropsWithViewContext {
groups: Group[];
dateCellTemplate?: JSXTemplate<DateTimeCellTemplateProps>;
timeCellTemplate?: JSXTemplate<DateTimeCellTemplateProps>;
showWeekNumbers?: boolean;
}

export const DateHeaderDefaultProps = {
Expand All @@ -42,9 +43,11 @@ export class DateHeader extends BaseInfernoComponent<DateHeaderProps> {
groupByDate,
groupOrientation,
groups,
showWeekNumbers,
} = this.props;
const isHorizontalGrouping = isHorizontalGroupingApplied(groups.length, groupOrientation)
&& !groupByDate;
const isMonthView = viewContext.view.type === 'month';

return (
<>
Expand All @@ -59,38 +62,45 @@ export class DateHeader extends BaseInfernoComponent<DateHeaderProps> {
rightVirtualCellCount={rightVirtualCellCount}
isHeaderRow={true}
>
{
dateHeaderRow.map(({
colSpan,
groupIndex,
groups: cellGroups,
index,
isFirstGroupCell,
isLastGroupCell,
key,
startDate,
text,
today,
}) => (
<DateHeaderCell
key={key}
viewContext={viewContext}
startDate={startDate}
groups={isHorizontalGrouping ? cellGroups : undefined}
groupIndex={isHorizontalGrouping ? groupIndex : undefined}
today={today ?? false}
isWeekDayCell={false}
isTimeCellTemplate={false}
index={index}
text={text}
isFirstGroupCell={isFirstGroupCell}
isLastGroupCell={isLastGroupCell}
dateCellTemplate={dateCellTemplate}
colSpan={colSpan}
splitText={isMaterialBased}
/>
))
}
<>
{showWeekNumbers && isMonthView && rowIndex === 0 && (
<th className="dx-scheduler-week-number-header-cell" scope="col">
<div>Wk</div>
</th>
)}
{
dateHeaderRow.map(({
colSpan,
groupIndex,
groups: cellGroups,
index,
isFirstGroupCell,
isLastGroupCell,
key,
startDate,
text,
today,
}) => (
<DateHeaderCell
key={key}
viewContext={viewContext}
startDate={startDate}
groups={isHorizontalGrouping ? cellGroups : undefined}
groupIndex={isHorizontalGrouping ? groupIndex : undefined}
today={today ?? false}
isWeekDayCell={false}
isTimeCellTemplate={false}
index={index}
text={text}
isFirstGroupCell={isFirstGroupCell}
isLastGroupCell={isLastGroupCell}
dateCellTemplate={dateCellTemplate}
colSpan={colSpan}
splitText={isMaterialBased}
/>
))
}
</>
</Row>
))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ export class DateTable extends InfernoWrapperComponent<DateTableProps> {
dataCellTemplate,
groupOrientation,
addVerticalSizesClassToRows,
showWeekNumbers,
weekNumberRule,
firstDayOfWeek,
...restProps
} = this.props;
const classes = addDateTableClass ? 'dx-scheduler-date-table' : undefined;
Expand Down Expand Up @@ -70,6 +73,9 @@ export class DateTable extends InfernoWrapperComponent<DateTableProps> {
topVirtualRowHeight={DateTableBodyDefaultProps.topVirtualRowHeight}
bottomVirtualRowHeight={DateTableBodyDefaultProps.bottomVirtualRowHeight}
addDateTableClass={DateTableBodyDefaultProps.addDateTableClass}
showWeekNumbers={showWeekNumbers}
weekNumberRule={weekNumberRule}
firstDayOfWeek={firstDayOfWeek}
/>
</Table>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import dateLocalization from '@js/common/core/localization/date';
import dateUtils from '@js/core/utils/date';
import { BaseInfernoComponent } from '@ts/core/r1/runtime/inferno/index';
import type { JSXTemplate } from '@ts/core/r1/types';
import { PublicTemplate } from '@ts/scheduler/r1/components/templates/index';
Expand All @@ -12,6 +14,19 @@ import type { LayoutProps } from './layout_props';
import { LayoutDefaultProps } from './layout_props';
import { Row, RowDefaultProps } from './row';

function getLocaleBasedRule(): string {
return dateLocalization.firstDayOfWeekIndex() === 1 ? 'firstFourDays' : 'firstDay';
}

function resolveWeekNumber(
date: Date,
firstDayOfWeek: number | undefined,
rule: string | undefined,
): number {
const effectiveRule = !rule || rule === 'auto' ? getLocaleBasedRule() : rule;
return dateUtils.getWeekNumber(date, firstDayOfWeek ?? 0, effectiveRule);
}

export interface DateTableBodyProps extends LayoutProps {
cellTemplate: JSXTemplate<CellTemplateProps>;
}
Expand All @@ -29,7 +44,11 @@ export class DateTableBody extends BaseInfernoComponent<DateTableBodyProps> {
addVerticalSizesClassToRows,
cellTemplate,
dataCellTemplate,
showWeekNumbers,
weekNumberRule,
firstDayOfWeek,
} = this.props;
const isMonthView = viewContext.view.type === 'month';
const rowClasses = combineClasses({
[DATE_TABLE_ROW_CLASS]: true,
'dx-scheduler-cell-sizes-vertical': addVerticalSizesClassToRows,
Expand Down Expand Up @@ -74,8 +93,16 @@ export class DateTableBody extends BaseInfernoComponent<DateTableBodyProps> {
leftVirtualCellCount={viewData.leftVirtualCellCount}
rightVirtualCellCount={viewData.rightVirtualCellCount}
>
{
cells.map(({
<>
{showWeekNumbers && isMonthView && cells.length > 0 && (
<td
className="dx-scheduler-week-number-cell"
aria-label={`Week ${resolveWeekNumber(cells[0].startDate, firstDayOfWeek, weekNumberRule)}`}
>
{resolveWeekNumber(cells[0].startDate, firstDayOfWeek, weekNumberRule)}
</td>
)}
{cells.map(({
key: cellKey,
endDate,
isFirstDayMonthHighlighting,
Expand All @@ -91,26 +118,27 @@ export class DateTableBody extends BaseInfernoComponent<DateTableBodyProps> {
text,
today,
}) => <PublicTemplate
template={cellTemplate}
templateProps={{
key: cellKey,
viewContext,
isFirstGroupCell,
isLastGroupCell,
startDate,
endDate,
groups,
groupIndex: cellGroupIndex,
index: cellIndex,
dataCellTemplate,
text,
today,
otherMonth,
isFirstDayMonthHighlighting,
isSelected,
isFocused,
} as CellTemplateProps} />)
}
template={cellTemplate}
templateProps={{
key: cellKey,
viewContext,
isFirstGroupCell,
isLastGroupCell,
startDate,
endDate,
groups,
groupIndex: cellGroupIndex,
index: cellIndex,
dataCellTemplate,
text,
today,
otherMonth,
isFirstDayMonthHighlighting,
isSelected,
isFocused,
} as CellTemplateProps} />)
}
</>
</Row>
))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface HeaderPanelProps extends GroupPanelProps {
dateCellTemplate?: JSXTemplate<DateTimeCellTemplateProps>;
timeCellTemplate?: JSXTemplate<DateTimeCellTemplateProps>;
dateHeaderTemplate: JSXTemplate<DateHeaderProps, 'dateHeaderData'>;
showWeekNumbers?: boolean;
}

export const HeaderPanelDefaultProps = {
Expand All @@ -43,6 +44,7 @@ export class HeaderPanel extends InfernoWrapperComponent<HeaderPanelProps> {
dateHeaderTemplate,
resourceCellTemplate,
timeCellTemplate,
showWeekNumbers,
} = this.props;
const isHorizontalGrouping = isHorizontalGroupingApplied(groups.length, groupOrientation);

Expand Down Expand Up @@ -72,6 +74,7 @@ export class HeaderPanel extends InfernoWrapperComponent<HeaderPanelProps> {
groups,
dateCellTemplate,
timeCellTemplate,
showWeekNumbers,
}}
/>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ export interface LayoutProps extends PropsWithViewContext {
addVerticalSizesClassToRows: boolean;
width?: number;
dataCellTemplate?: JSXTemplate<DataCellTemplateProps>;
showWeekNumbers?: boolean;
weekNumberRule?: string;
firstDayOfWeek?: number;
}

export const LayoutDefaultProps: DefaultProps<LayoutProps> = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ export class DateTableMonth extends InfernoWrapperComponent<DateTableProps> {
groupOrientation,
tableRef,
width,
showWeekNumbers,
weekNumberRule,
firstDayOfWeek,
...restProps
} = this.props;

Expand All @@ -35,6 +38,9 @@ export class DateTableMonth extends InfernoWrapperComponent<DateTableProps> {
tableRef={tableRef}
addVerticalSizesClassToRows={addVerticalSizesClassToRows}
width={width}
showWeekNumbers={showWeekNumbers}
weekNumberRule={weekNumberRule}
firstDayOfWeek={firstDayOfWeek}
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ export class DateTableMonthComponent extends DateTableComponent {
'addVerticalSizesClassToRows',
'width',
'dataCellTemplate',
'showWeekNumbers',
'weekNumberRule',
'firstDayOfWeek',
],
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export class HeaderPanelComponent extends ComponentWrapper {
'height',
'className',
'resourceCellTemplate',
'showWeekNumbers',
],
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export class OptionManager {
const viewOrientation = panelName === 'allDayPanel' ? 'horizontal' : nativeViewOrientation;
const isCompactCollector = isAdaptivityEnabled || viewOrientation === 'vertical';
const collectorCSS = workspace.getCollectorDimension(isCompactCollector, panelName);
const DOMMetaData = workspace.getDOMElementsMetaData();
const {
allDayPanelCellSize,
cellSize,
Expand All @@ -92,7 +93,7 @@ export class OptionManager {
viewOrientation,
isAdaptivityEnabled,
collectorCSS,
DOMMetaData: workspace.getDOMElementsMetaData(),
DOMMetaData,
panelName,
});

Expand Down Expand Up @@ -137,6 +138,7 @@ export class OptionManager {
isAllDayPanel: panelName === 'allDayPanel',
}),
panelSize: panelDOMSize,
panelLeftOffset: DOMMetaData.dateTableCellsMeta[0]?.[0]?.left ?? 0,
};
const collectorOptions: CollectorOptions = {
cells,
Expand Down
Loading
Loading