Skip to content
Open
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
Expand Up @@ -7,12 +7,10 @@ import { getResourceManagerMock } from '../__mock__/resource_manager.mock';
import SchedulerTimelineDay from '../workspaces/m_timeline_day';
import SchedulerTimelineMonth from '../workspaces/m_timeline_month';
import SchedulerTimelineWeek from '../workspaces/m_timeline_week';
import SchedulerTimelineWorkWeek from '../workspaces/m_timeline_work_week';
import type SchedulerWorkSpace from '../workspaces/m_work_space';
import SchedulerWorkSpaceDay from '../workspaces/m_work_space_day';
import SchedulerWorkSpaceMonth from '../workspaces/m_work_space_month';
import SchedulerWorkSpaceWeek from '../workspaces/m_work_space_week';
import SchedulerWorkSpaceWorkWeek from '../workspaces/m_work_space_work_week';
import { setupSchedulerTestEnvironment } from './__mock__/m_mock_scheduler';

jest.mock('@ts/core/m_devices', () => {
Expand Down Expand Up @@ -67,11 +65,11 @@ const workSpaces: {
}[] = [
{ currentView: 'day', WorkSpace: SchedulerWorkSpaceDay },
{ currentView: 'week', WorkSpace: SchedulerWorkSpaceWeek },
{ currentView: 'workWeek', WorkSpace: SchedulerWorkSpaceWorkWeek },
{ currentView: 'workWeek', WorkSpace: SchedulerWorkSpaceWeek },
{ currentView: 'month', WorkSpace: SchedulerWorkSpaceMonth },
{ currentView: 'timelineDay', WorkSpace: SchedulerTimelineDay },
{ currentView: 'timelineWeek', WorkSpace: SchedulerTimelineWeek },
{ currentView: 'timelineWorkWeek', WorkSpace: SchedulerTimelineWorkWeek },
{ currentView: 'timelineWorkWeek', WorkSpace: SchedulerTimelineWeek },
{ currentView: 'timelineMonth', WorkSpace: SchedulerTimelineMonth },
];

Expand Down Expand Up @@ -210,7 +208,7 @@ describe('scheduler workspace skipped days support', () => {
});

it('should use full week layout for work week when skippedDays override is empty', () => {
const { workspace } = createWorkspace(SchedulerWorkSpaceWorkWeek, 'workWeek', {
const { workspace } = createWorkspace(SchedulerWorkSpaceWeek, 'workWeek', {
currentDate: new Date(2026, 3, 1), // Wednesday
firstDayOfWeek: 0, // Sunday
skippedDays: [],
Expand All @@ -221,7 +219,7 @@ describe('scheduler workspace skipped days support', () => {
});

it('should use custom skippedDays in work week runtime layout', () => {
const { workspace } = createWorkspace(SchedulerWorkSpaceWorkWeek, 'workWeek', {
const { workspace } = createWorkspace(SchedulerWorkSpaceWeek, 'workWeek', {
currentDate: new Date(2026, 3, 1), // Wednesday
firstDayOfWeek: 0, // Sunday
skippedDays: [3], // Wednesday
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ describe('day hiddenWeekDays support in header utils', () => {
});
});

describe('workWeek hiddenWeekDays support in header utils', () => {
it('should keep Mon-Fri caption for default skippedDays', () => {
describe('week hiddenWeekDays support in header utils', () => {
it('should keep Mon-Fri caption for weekend skippedDays', () => {
expect(getCaptionInterval({
date: new Date(2026, 3, 8), // Wednesday
step: 'workWeek',
step: 'week',
intervalCount: 1,
skippedDays: [0, 6],
firstDayOfWeek: 0,
Expand All @@ -77,7 +77,7 @@ describe('workWeek hiddenWeekDays support in header utils', () => {
it('should use full week caption when skippedDays override is empty', () => {
expect(getCaptionInterval({
date: new Date(2026, 3, 8), // Wednesday
step: 'workWeek',
step: 'week',
intervalCount: 1,
skippedDays: [],
firstDayOfWeek: 0,
Expand All @@ -90,7 +90,7 @@ describe('workWeek hiddenWeekDays support in header utils', () => {
it('should use first and last visible days for custom skippedDays', () => {
expect(getCaptionInterval({
date: new Date(2026, 3, 8), // Wednesday
step: 'workWeek',
step: 'week',
intervalCount: 1,
skippedDays: [1, 2],
firstDayOfWeek: 0,
Expand All @@ -99,9 +99,6 @@ describe('workWeek hiddenWeekDays support in header utils', () => {
endDate: new Date(2026, 3, 11, 23, 59, 59, 999),
});
});
});

describe('week hiddenWeekDays support in header utils', () => {
it('should use first and last visible day for week caption', () => {
expect(getCaptionInterval({
date: new Date(2026, 3, 8), // Wednesday
Expand Down
11 changes: 4 additions & 7 deletions packages/devextreme/js/__internal/scheduler/header/m_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ const getIntervalStartDate = (options: IntervalOptions): Date => {
);
case 'month':
return getPeriodStart(date, step, false, firstDayOfWeek) as Date;
case 'week':
case 'workWeek': {
case 'week': {
const weekStart = getPeriodStart(date, 'week', false, firstDayOfWeek) as Date;
return getFirstVisibleDate(weekStart, skippedDays, nextDay);
}
Expand All @@ -120,7 +119,6 @@ const getPeriodEndDate = (
day: () => nextDay(currentPeriodStartDate),
week: () => getDateAfterWeek(currentPeriodStartDate, firstDayOfWeek, skippedDays),
month: () => nextMonth(currentPeriodStartDate),
workWeek: () => getDateAfterWeek(currentPeriodStartDate, firstDayOfWeek, skippedDays),
agenda: () => nextAgendaStart(currentPeriodStartDate, agendaDuration),
};

Expand All @@ -134,7 +132,7 @@ const getNextPeriodStartDate = (
): Date => {
let date = addMS(currentPeriodEndDate);

if (step === 'day' || step === 'week' || step === 'workWeek') {
if (step === 'day' || step === 'week') {
date = getFirstVisibleDate(date, skippedDays, nextDay);
}

Expand Down Expand Up @@ -204,7 +202,6 @@ export const getNextIntervalDate = (options: IntervalOptions, direction: Directi
direction,
);
case 'week':
case 'workWeek':
dayDuration = 7 * intervalCount;
break;
case 'agenda':
Expand Down Expand Up @@ -342,11 +339,11 @@ export const getCaption = (options: IntervalOptions, isShort: boolean, customiza
const STEP_MAP: Record<ViewType, Step> = {
day: 'day',
week: 'week',
workWeek: 'workWeek',
workWeek: 'week',
month: 'month',
timelineDay: 'day',
timelineWeek: 'week',
timelineWorkWeek: 'workWeek',
timelineWorkWeek: 'week',
timelineMonth: 'month',
agenda: 'agenda',
} as const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export interface HeaderOptions {
_useShortDateFormat?: boolean;
}

export type Step = 'day' | 'week' | 'workWeek' | 'month' | 'agenda';
export type Step = 'day' | 'week' | 'month' | 'agenda';

export interface IntervalOptions {
date: Date;
Expand Down
6 changes: 2 additions & 4 deletions packages/devextreme/js/__internal/scheduler/m_scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,9 @@ import SchedulerAgenda from './workspaces/m_agenda';
import SchedulerTimelineDay from './workspaces/m_timeline_day';
import SchedulerTimelineMonth from './workspaces/m_timeline_month';
import SchedulerTimelineWeek from './workspaces/m_timeline_week';
import SchedulerTimelineWorkWeek from './workspaces/m_timeline_work_week';
import SchedulerWorkSpaceDay from './workspaces/m_work_space_day';
import SchedulerWorkSpaceMonth from './workspaces/m_work_space_month';
import SchedulerWorkSpaceWeek from './workspaces/m_work_space_week';
import SchedulerWorkSpaceWorkWeek from './workspaces/m_work_space_work_week';

const toMs = dateUtils.dateToMilliseconds;

Expand All @@ -115,7 +113,7 @@ const VIEWS_CONFIG = {
renderingStrategy: 'vertical',
},
workWeek: {
workSpace: SchedulerWorkSpaceWorkWeek,
workSpace: SchedulerWorkSpaceWeek,
renderingStrategy: 'vertical',
},
month: {
Expand All @@ -131,7 +129,7 @@ const VIEWS_CONFIG = {
renderingStrategy: 'horizontal',
},
timelineWorkWeek: {
workSpace: SchedulerTimelineWorkWeek,
workSpace: SchedulerTimelineWeek,
renderingStrategy: 'horizontal',
},
timelineMonth: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ import {
getIntervalDuration,
getTimePanelCellText,
} from './week';
import {
calculateStartViewDate as workWeekCalculateStartViewDate,
} from './work_week';

export {
calculateCellIndex,
Expand Down Expand Up @@ -104,10 +101,6 @@ export const weekUtils = {
calculateViewStartDate: weekCalculateViewStartDate,
};

export const workWeekUtils = {
calculateStartViewDate: workWeekCalculateStartViewDate,
};

export const monthUtils = {
getViewStartByOptions,
getCellText,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import dateUtils from '@js/core/utils/date';

import type { CalculateStartViewDate } from '../../types';
import { formatImplicitSchedulerTime } from '../../utils/global_formats';
import { getFirstVisibleDate } from '../../utils/skipped_days';
import {
getCalculatedFirstDayOfWeek,
getValidCellDateForLocalTimeFormat,
Expand Down Expand Up @@ -50,6 +51,7 @@ export const calculateStartViewDate: CalculateStartViewDate = (
startDate,
intervalDuration,
firstDayOfWeekOption,
skippedDays = [],
) => {
const firstDayOfWeek = getCalculatedFirstDayOfWeek(firstDayOfWeekOption);
const viewStart = getViewStartByOptions(
Expand All @@ -59,7 +61,12 @@ export const calculateStartViewDate: CalculateStartViewDate = (
getValidStartDate(startDate, firstDayOfWeek),
);

const firstViewDate = dateUtils.getFirstWeekDate(viewStart, firstDayOfWeek);
const weekStartDate = dateUtils.getFirstWeekDate(viewStart, firstDayOfWeek);
const firstViewDate = getFirstVisibleDate(
weekStartDate,
skippedDays,
(date) => new Date(date.getFullYear(), date.getMonth(), date.getDate() + 1),
);

return setOptionHour(firstViewDate, startDayHour);
};
Expand Down

This file was deleted.

1 change: 1 addition & 0 deletions packages/devextreme/js/__internal/scheduler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export type CalculateStartViewDate = (
startDate: Date,
intervalCount: number,
firstDayOfWeekOption?: number,
skippedDays?: number[],
) => Date;

export interface ViewCellData {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ import { VIEWS } from '../utils/options/constants_view';
import SchedulerTimeline from './m_timeline';

const TIMELINE_CLASS = 'dx-scheduler-timeline-week';
const TIMELINE_WORK_WEEK_CLASS = 'dx-scheduler-timeline-work-week';

export default class SchedulerTimelineWeek extends SchedulerTimeline {
get type() { return VIEWS.TIMELINE_WEEK; }
get type(): string {
return this.option('type') ?? VIEWS.TIMELINE_WEEK;
}

protected override getElementClass() {
return TIMELINE_CLASS;
return this.type === VIEWS.TIMELINE_WORK_WEEK ? TIMELINE_WORK_WEEK_CLASS : TIMELINE_CLASS;
}

protected override needRenderWeekHeader() {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ type WorkspaceOptionsInternal = Omit<dxSchedulerOptions, 'groups'> & {
startDayHour: number;
endDayHour: number;
skippedDays?: number[];
type?: ViewType;
};
class SchedulerWorkSpace extends Widget<WorkspaceOptionsInternal> {
private viewDataProviderValue: any;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ import { VIEWS } from '../utils/options/constants_view';
import SchedulerWorkSpaceVertical from './m_work_space_vertical';

const WEEK_CLASS = 'dx-scheduler-work-space-week';
const WORK_WEEK_CLASS = 'dx-scheduler-work-space-work-week';
class SchedulerWorkSpaceWeek extends SchedulerWorkSpaceVertical {
get type() { return VIEWS.WEEK; }
get type(): string {
return this.option('type') ?? VIEWS.WEEK;
}

protected override getElementClass() {
return WEEK_CLASS;
return this.type === VIEWS.WORK_WEEK ? WORK_WEEK_CLASS : WEEK_CLASS;
}

protected override calculateViewStartDate() {
Expand Down

This file was deleted.

Loading
Loading