Skip to content

Commit f4a89c5

Browse files
committed
feat: create spike
1 parent 4feac3e commit f4a89c5

File tree

14 files changed

+316
-9
lines changed

14 files changed

+316
-9
lines changed

packages/devextreme-scss/scss/widgets/base/scheduler/views/_index.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ $scheduler-month-date-text-padding: 6px;
6060
$scheduler-month-date-text-padding: $scheduler-month-date-text-padding,
6161
$scheduler-first-month-cell-background-color: $scheduler-first-month-cell-background-color,
6262
);
63+
@use "./year";
6364
@use "./timelines" with (
6465
$scheduler-workspace-date-table-cell-height: $scheduler-workspace-date-table-cell-height,
6566
$scheduler-accent-border: $scheduler-accent-border,
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
.dx-scheduler-work-space-year {
2+
.dx-scheduler-all-day-title {
3+
display: none;
4+
}
5+
6+
.dx-scheduler-header-panel {
7+
display: none;
8+
}
9+
10+
.dx-scheduler-time-panel {
11+
display: none;
12+
}
13+
14+
.dx-scheduler-year-calendars-container {
15+
display: grid;
16+
grid-template-columns: 1fr 1fr 1fr 1fr;
17+
grid-column-gap: 12px;
18+
grid-row-gap: 20px;
19+
padding: 12px;
20+
height: 100%;
21+
width: 100%;
22+
box-sizing: border-box;
23+
}
24+
25+
.dx-scheduler-year-calendar-label {
26+
font-size: 14px;
27+
font-weight: 500;
28+
margin-bottom: 8px;
29+
text-align: center;
30+
}
31+
32+
.dx-scheduler-year-calendar-wrapper {
33+
display: flex;
34+
flex-direction: column;
35+
min-height: 0;
36+
width: 100%;
37+
38+
.dx-calendar-navigator {
39+
display: none;
40+
}
41+
42+
.dx-calendar-cell.dx-calendar-selected-date span {
43+
color: unset;
44+
background-color: unset;
45+
}
46+
}
47+
}

packages/devextreme/js/__internal/scheduler/a11y_status/a11y_status_text.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const viewTypeLocalization: Record<ViewType, string> = {
1414
agenda: 'dxScheduler-switcherAgenda',
1515
day: 'dxScheduler-switcherDay',
1616
month: 'dxScheduler-switcherMonth',
17+
year: 'dxScheduler-switcherYear',
1718
week: 'dxScheduler-switcherWeek',
1819
workWeek: 'dxScheduler-switcherWorkWeek',
1920
timelineDay: 'dxScheduler-switcherTimelineDay',

packages/devextreme/js/__internal/scheduler/header/m_utils.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ const getIntervalStartDate = (options: IntervalOptions) => {
8181
case 'day':
8282
case 'week':
8383
case 'month':
84+
case 'year':
8485
return getPeriodStart(date, step, false, firstDayOfWeek);
8586
case 'workWeek':
8687
// eslint-disable-next-line no-case-declarations
@@ -133,6 +134,10 @@ const getPeriodEndDate = (currentPeriodStartDate: Date, step: Step, agendaDurati
133134
case 'month':
134135
date = nextMonth(currentPeriodStartDate);
135136
break;
137+
case 'year':
138+
date = new Date(currentPeriodStartDate);
139+
date.setFullYear(date.getFullYear() + 1);
140+
break;
136141
case 'workWeek':
137142
date = getDateAfterWorkWeek(currentPeriodStartDate);
138143
break;
@@ -176,6 +181,10 @@ export const getNextIntervalDate = (options, direction: Direction): Date => {
176181
break;
177182
case 'month':
178183
return getNextMonthDate(date, intervalCount, direction);
184+
case 'year':
185+
{ const nextYearDate = new Date(date);
186+
nextYearDate.setFullYear(nextYearDate.getFullYear() + intervalCount * direction);
187+
return nextYearDate; }
179188
}
180189

181190
return addDateInterval(date, { days: dayDuration }, direction);
@@ -299,6 +308,10 @@ const getCaptionText = (startDate: Date, endDate: Date, isShort: boolean, step):
299308
return formatMonthViewCaption(startDate, endDate);
300309
}
301310

311+
if (step === 'year') {
312+
return String(formatDate(startDate, 'year') ?? '');
313+
}
314+
302315
return formatCaptionByMonths(startDate, endDate, isShort);
303316
};
304317

@@ -319,6 +332,7 @@ const STEP_MAP: Record<ViewType, Step> = {
319332
week: 'week',
320333
workWeek: 'workWeek',
321334
month: 'month',
335+
year: 'year',
322336
timelineDay: 'day',
323337
timelineWeek: 'week',
324338
timelineWorkWeek: 'workWeek',

packages/devextreme/js/__internal/scheduler/header/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export interface HeaderOptions {
1818
customizeDateNavigatorText: SafeSchedulerOptions['customizeDateNavigatorText'];
1919
}
2020

21-
export type Step = 'day' | 'week' | 'workWeek' | 'month' | 'agenda';
21+
export type Step = 'day' | 'week' | 'workWeek' | 'month' | 'year' | 'agenda';
2222

2323
export interface IntervalOptions {
2424
date: Date;

packages/devextreme/js/__internal/scheduler/m_scheduler.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ import SchedulerWorkSpaceDay from './workspaces/m_work_space_day';
8989
import SchedulerWorkSpaceMonth from './workspaces/m_work_space_month';
9090
import SchedulerWorkSpaceWeek from './workspaces/m_work_space_week';
9191
import SchedulerWorkSpaceWorkWeek from './workspaces/m_work_space_work_week';
92+
import SchedulerWorkSpaceYear from './workspaces/m_work_space_year';
9293

9394
const toMs = dateUtils.dateToMilliseconds;
9495

@@ -119,6 +120,10 @@ const VIEWS_CONFIG = {
119120
workSpace: SchedulerWorkSpaceMonth,
120121
renderingStrategy: 'horizontalMonth',
121122
},
123+
year: {
124+
workSpace: SchedulerWorkSpaceYear,
125+
renderingStrategy: 'horizontalMonth',
126+
},
122127
timelineDay: {
123128
workSpace: SchedulerTimelineDay,
124129
renderingStrategy: 'horizontal',
@@ -1308,6 +1313,15 @@ class Scheduler extends SchedulerOptionsBaseWidget {
13081313
const currentViewType = this.currentView.type;
13091314
const workSpaceComponent = VIEWS_CONFIG[currentViewType].workSpace;
13101315
const workSpaceConfig = this._workSpaceConfig(this.currentView);
1316+
1317+
// Add callback for year view date click
1318+
if (currentViewType === 'year') {
1319+
workSpaceConfig.onDateClick = (date: Date) => {
1320+
this.option('currentView', 'day');
1321+
this.option('currentDate', date);
1322+
};
1323+
}
1324+
13111325
// @ts-expect-error
13121326
this._workSpace = this._createComponent($workSpace, workSpaceComponent, workSpaceConfig);
13131327

packages/devextreme/js/__internal/scheduler/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { AppointmentViewModelPlain } from './view_model/types';
66

77
export type Direction = 'vertical' | 'horizontal';
88
export type GroupOrientation = 'vertical' | 'horizontal';
9-
export type ViewType = 'agenda' | 'day' | 'month' | 'timelineDay' | 'timelineMonth' | 'timelineWeek' | 'timelineWorkWeek' | 'week' | 'workWeek';
9+
export type ViewType = 'agenda' | 'day' | 'month' | 'year' | 'timelineDay' | 'timelineMonth' | 'timelineWeek' | 'timelineWorkWeek' | 'week' | 'workWeek';
1010
export type AllDayPanelModeType = 'all' | 'allDay' | 'hidden';
1111
export type RenderStrategyName = 'horizontal' | 'horizontalMonth' | 'horizontalMonthLine' | 'vertical' | 'week' | 'agenda';
1212
export type FilterItemType = Record<string, string | number> | string | number;

packages/devextreme/js/__internal/scheduler/utils/options/constants_view.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export const VIEWS: Record<string, ViewType> = {
55
WEEK: 'week',
66
WORK_WEEK: 'workWeek',
77
MONTH: 'month',
8+
YEAR: 'year',
89
TIMELINE_DAY: 'timelineDay',
910
TIMELINE_WEEK: 'timelineWeek',
1011
TIMELINE_WORK_WEEK: 'timelineWorkWeek',
@@ -32,6 +33,7 @@ export const DEFAULT_VIEW_OPTIONS: Record<Exclude<ViewType, 'agenda'>, View> & {
3233
week: getView('week', 'horizontal'),
3334
workWeek: getView('workWeek', 'horizontal', WEEKENDS),
3435
month: getView('month', 'horizontal'),
36+
year: getView('year', 'horizontal'),
3537
timelineDay: getView('timelineDay', 'vertical'),
3638
timelineWeek: getView('timelineWeek', 'vertical'),
3739
timelineWorkWeek: getView('timelineWorkWeek', 'vertical', WEEKENDS),

packages/devextreme/js/__internal/scheduler/view_model/filtration/utils/get_filter_options/get_filter_options.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { FilterOptions } from '../../../types';
66
import { getVisibleDateTimeIntervals } from './get_visible_date_time_intervals';
77

88
const VIEWS_WITH_ALL_DAY_PANEL: ViewType[] = ['day', 'week', 'workWeek'];
9-
const DATE_TIME_VIEWS: ViewType[] = ['day', 'week', 'workWeek', 'timelineDay', 'timelineWeek', 'timelineWorkWeek'];
9+
const DATE_TIME_VIEWS: ViewType[] = ['day', 'week', 'workWeek', 'year', 'timelineDay', 'timelineWeek', 'timelineWorkWeek'];
1010

1111
export const getFilterOptions = (schedulerStore: Scheduler): FilterOptions => {
1212
const compareOptions = getCompareOptions(schedulerStore);

packages/devextreme/js/__internal/scheduler/view_model/generate_view_model/options/get_view_model_options.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const configByView: Record<Exclude<ViewType, 'agenda'>, {
1414
week: { isTimelineView: false, isMonthView: false, viewOrientation: 'vertical' },
1515
workWeek: { isTimelineView: false, isMonthView: false, viewOrientation: 'vertical' },
1616
month: { isTimelineView: false, isMonthView: true, viewOrientation: 'horizontal' },
17+
year: { isTimelineView: false, isMonthView: true, viewOrientation: 'horizontal' },
1718
timelineDay: { isTimelineView: true, isMonthView: false, viewOrientation: 'horizontal' },
1819
timelineWeek: { isTimelineView: true, isMonthView: false, viewOrientation: 'horizontal' },
1920
timelineWorkWeek: { isTimelineView: true, isMonthView: false, viewOrientation: 'horizontal' },

0 commit comments

Comments
 (0)