Skip to content

Commit

Permalink
Scheduler: Fix R1 codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilya Vinogradov committed Sep 8, 2023
1 parent 7016a9c commit 1ad989c
Show file tree
Hide file tree
Showing 24 changed files with 112 additions and 107 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Scheduler, viewFunction as ViewFunction } from '../scheduler';
import { Widget, WidgetProps } from '../../common/widget';
import * as viewsModel from '../model/views';
import { ViewType } from '../types';
import ViewDataProvider from '../../../../ui/scheduler/workspaces/view_model/view_data_provider';
import ViewDataProvider from '../../../../__internal/scheduler/workspaces/view_model/m_view_data_provider';
import { WorkSpace } from '../workspaces/base/work_space';
import { SchedulerToolbar } from '../header/header';
import * as resourceUtils from '../../../../__internal/scheduler/resources/m_utils';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
getMaxWidth,
} from './popup_config';
// eslint-disable-next-line import/named
import { dxSchedulerAppointment } from '../../../../ui/scheduler';
import type { dxSchedulerAppointment } from '../../../../ui/scheduler';
import { EditForm } from './edit_form/layout';
import { DataAccessorType } from '../types';
import { AppointmentData } from '../appointment/types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { shallow } from 'enzyme';
// https://github.com/benmosher/eslint-plugin-import/issues/1699
/* eslint-disable-next-line import/named */
import { dxSchedulerAppointment } from '../../../../../ui/scheduler';
import type { dxSchedulerAppointment } from '../../../../../ui/scheduler';
import {
TooltipItemLayout,
viewFunction as TooltipItemLayoutView,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
OneWay, Template, Event, JSXTemplate,
} from '@devextreme-generator/declarations';
/* eslint-disable-next-line import/named */
import { dxSchedulerAppointment } from '../../../../ui/scheduler';
import type { dxSchedulerAppointment } from '../../../../ui/scheduler';
import {
AppointmentItem,
FormattedContent,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// https://github.com/benmosher/eslint-plugin-import/issues/1699
// eslint-disable-next-line import/named
import { dxSchedulerAppointment } from '../../../../ui/scheduler';
import type { dxSchedulerAppointment } from '../../../../ui/scheduler';

export type Color = string | undefined;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FormattedContent } from '../types';
/* eslint-disable-next-line import/named */
import { dxSchedulerAppointment } from '../../../../../ui/scheduler';
import type { dxSchedulerAppointment } from '../../../../../ui/scheduler';

export const defaultGetTextAndFormatDate = (): FormattedContent => ({ text: '', formatDate: '' });
export const defaultGetSingleAppointment = (): dxSchedulerAppointment => ({});
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AppointmentItem } from '../types';
/* eslint-disable-next-line import/named */
import { dxSchedulerAppointment } from '../../../../../ui/scheduler';
import type { dxSchedulerAppointment } from '../../../../../ui/scheduler';

export default (appointmentItem: AppointmentItem): dxSchedulerAppointment => {
const { settings, data, currentData } = appointmentItem;
Expand Down
2 changes: 1 addition & 1 deletion packages/devextreme/js/renovation/ui/scheduler/common.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { utils } from '../../../ui/scheduler/utils';
import { utils } from '../../../__internal/scheduler/m_utils';
import { DataAccessorsProps } from './props';
import { DataAccessorType } from './types';
import { ViewDataProviderValidationOptions } from './workspaces/types';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ViewDataProvider from '../../../../../ui/scheduler/workspaces/view_model/view_data_provider';
import ViewDataProvider from '../../../../../__internal/scheduler/workspaces/view_model/m_view_data_provider';
import { SchedulerProps, ViewProps } from '../../props';
import { ViewType } from '../../types';
import { prepareGenerationOptions } from '../../workspaces/base/work_space';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
getCellHeight,
getAllDayHeight,
PositionHelper,
} from '../../../../ui/scheduler/workspaces/helpers/positionHelper';
} from '../../../../__internal/scheduler/workspaces/helpers/m_position_helper';
import { SchedulerProps } from '../props';
import { CurrentViewConfigType } from '../workspaces/props';
import { getGroupCount } from '../../../../__internal/scheduler/resources/m_utils';
Expand All @@ -13,49 +13,14 @@ import dateUtils from '../../../../core/utils/date';

import { AppointmentsConfigType, AppointmentsModelType } from './types';

import { DataAccessorType, ViewType } from '../types';
import { DataAccessorType } from '../types';
import { calculateIsGroupedAllDayPanel, getCellDuration } from '../view_model/to_test/views/utils/base';
import { TimeZoneCalculator } from '../timeZoneCalculator/utils';
import { getAppointmentRenderingStrategyName } from './utils';

// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
const toMs = (name: string): number => dateUtils.dateToMilliseconds(name);

export const getAppointmentRenderingStrategyName = (viewType: ViewType): string => {
const appointmentRenderingStrategyMap: Record<ViewType, { renderingStrategy: string }> = {
day: {
renderingStrategy: 'vertical',
},
week: {
renderingStrategy: 'week',
},
workWeek: {
renderingStrategy: 'week',
},
month: {
renderingStrategy: 'horizontalMonth',
},
timelineDay: {
renderingStrategy: 'horizontal',
},
timelineWeek: {
renderingStrategy: 'horizontal',
},
timelineWorkWeek: {
renderingStrategy: 'horizontal',
},
timelineMonth: {
renderingStrategy: 'horizontalMonthLine',
},
agenda: {
renderingStrategy: 'agenda',
},
};

const { renderingStrategy } = appointmentRenderingStrategyMap[viewType];

return renderingStrategy;
};

export const getAppointmentsConfig = (
schedulerConfig: Pick<
SchedulerProps,
Expand Down
37 changes: 37 additions & 0 deletions packages/devextreme/js/renovation/ui/scheduler/model/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { ViewType } from '../types';

export const getAppointmentRenderingStrategyName = (viewType: ViewType): string => {
const appointmentRenderingStrategyMap: Record<ViewType, { renderingStrategy: string }> = {
day: {
renderingStrategy: 'vertical',
},
week: {
renderingStrategy: 'week',
},
workWeek: {
renderingStrategy: 'week',
},
month: {
renderingStrategy: 'horizontalMonth',
},
timelineDay: {
renderingStrategy: 'horizontal',
},
timelineWeek: {
renderingStrategy: 'horizontal',
},
timelineWorkWeek: {
renderingStrategy: 'horizontal',
},
timelineMonth: {
renderingStrategy: 'horizontalMonthLine',
},
agenda: {
renderingStrategy: 'agenda',
},
};

const { renderingStrategy } = appointmentRenderingStrategyMap[viewType];

return renderingStrategy;
};
6 changes: 4 additions & 2 deletions packages/devextreme/js/renovation/ui/scheduler/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,17 +413,19 @@ export class SchedulerProps extends BaseWidgetProps {
// eslint-disable-next-line max-len
template | ((model: AppointmentTooltipTemplateData, itemIndex: number, contentElement: DxElement) => string | UserDefinedElement);

/* eslint-disable @typescript-eslint/no-explicit-any */
@OneWay()
toolbar: SchedulerToolbarItem[] = [
{
defaultElement: 'dateNavigator',
location: 'before',
},
} as any,
{
defaultElement: 'viewSwitcher',
location: 'after',
},
} as any,
];
/* eslint-enable @typescript-eslint/no-explicit-any */
}

export type DataAccessorsProps = Pick<
Expand Down
4 changes: 2 additions & 2 deletions packages/devextreme/js/renovation/ui/scheduler/scheduler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
} from '@devextreme-generator/declarations';
import { TimeZoneCalculator } from './timeZoneCalculator/utils';
// eslint-disable-next-line import/named
import { Appointment } from '../../../ui/scheduler';
import type { Appointment } from '../../../ui/scheduler';
import { ViewProps, SchedulerProps } from './props';

import { Widget } from '../common/widget';
Expand All @@ -25,7 +25,7 @@ import {
} from './workspaces/types';
import { WorkSpace } from './workspaces/base/work_space';
import { SchedulerToolbar } from './header/header';
import { getViewDataGeneratorByViewType } from '../../../ui/scheduler/workspaces/view_model/utils';
import { getViewDataGeneratorByViewType } from '../../../__internal/scheduler/workspaces/view_model/m_utils';
import type { AppointmentDataItem, DataAccessorType, DataSourcePromise } from './types';
import {
createDataAccessors, isViewDataProviderConfigValid,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TimeZoneCalculator } from './utils';
import timeZoneUtils from '../../../../ui/scheduler/utils.timeZone';
import timeZoneUtils from '../../../../__internal/scheduler/m_utils_time_zone';

export const createTimeZoneCalculator = (
currentTimeZone: string,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Appointment } from '../../../../ui/scheduler';
import { AppointmentDataItem, DataAccessorType, LoadDataType } from '../types';
import { replaceWrongEndDate } from '../../../../__internal/scheduler/appointments/data_provider/m_utils';
import { createAppointmentAdapter } from '../../../../ui/scheduler/appointmentAdapter';
import { createAppointmentAdapter } from '../../../../__internal/scheduler/m_appointment_adapter';
import { TimeZoneCalculator } from '../timeZoneCalculator/utils';
import { isDefined } from '../../../../core/utils/type';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Appointment } from '../../../../../ui/scheduler';
import AppointmentAdapter, { createAppointmentAdapter } from '../../../../../ui/scheduler/appointmentAdapter';
import AppointmentAdapter, { createAppointmentAdapter } from '../../../../../__internal/scheduler/m_appointment_adapter';
import { TimeZoneCalculator } from '../../timeZoneCalculator/utils';
import { DataAccessorType } from '../../types';
import dateSerialization from '../../../../../core/utils/date_serialization';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ViewDataProvider from '../../../../../../ui/scheduler/workspaces/view_model/view_data_provider';
import ViewDataProvider from '../../../../../../__internal/scheduler/workspaces/view_model/m_view_data_provider';
import { SchedulerProps, ViewProps } from '../../../props';
import { DataAccessorType, ViewType } from '../../../types';
import { prepareGenerationOptions } from '../../../workspaces/base/work_space';
Expand All @@ -13,8 +13,8 @@ import { AppointmentsConfigType } from '../../../model/types';
import { TimeZoneCalculator } from '../../../timeZoneCalculator/utils';
import { getCurrentViewConfig } from '../../../model/views';

jest.mock('../../../../../../ui/scheduler/workspaces/helpers/positionHelper', () => ({
...jest.requireActual('../../../../../../ui/scheduler/workspaces/helpers/positionHelper'),
jest.mock('../../../../../../__internal/scheduler/workspaces/helpers/m_position_helper', () => ({
...jest.requireActual('../../../../../../__internal/scheduler/workspaces/helpers/m_position_helper'),
PositionHelper: jest.fn(() => ({
getHorizontalMax: (): number => 100,
getResizableStep: (): number => 110,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ export type GetDateForHeaderText = (
export type CalculateCellIndex = (
rowIndex: number, columnIndex: number, rowCount: number, columnCount: number,
) => number;

export type CalculateStartViewDate = (
currentDate: Date,
startDayHour: number,
startDate: Date,
intervalCount: number,
firstDayOfWeekOption: number,
firstDayOfWeekOption?: number,
) => Date;
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import errors from '../../../../../../../ui/widget/ui.errors';
import dateUtils from '../../../../../../../core/utils/date';
import { isDefined } from '../../../../../../../core/utils/type';
import dateLocalization from '../../../../../../../localization/date';
import timeZoneUtils from '../../../../../../../ui/scheduler/utils.timeZone';
import { VERTICAL_GROUP_COUNT_CLASSES } from '../../../../../../../ui/scheduler/classes';
import { VIEWS } from '../../../../../../../ui/scheduler/constants';
import timeZoneUtils from '../../../../../../../__internal/scheduler/m_utils_time_zone';
import { VERTICAL_GROUP_COUNT_CLASSES } from '../../../../../../../__internal/scheduler/m_classes';
import { VIEWS } from '../../../../../../../__internal/scheduler/m_constants';
import { getGroupCount } from '../../../../../../../__internal/scheduler/resources/m_utils';
import { isVerticalGroupingApplied } from '../../../../workspaces/utils';
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import timeZoneUtils from '../../../../../../../ui/scheduler/utils.timeZone';
import timeZoneUtils from '../../../../../../../__internal/scheduler/m_utils_time_zone';
import { GetDateForHeaderText } from '../types';
import { getStartViewDateWithoutDST } from './base';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
getViewStartByOptions,
setOptionHour,
} from './base';
import timeZoneUtils from '../../../../../../../ui/scheduler/utils.timeZone';
import timeZoneUtils from '../../../../../../../__internal/scheduler/m_utils_time_zone';
import { CalculateStartViewDate } from '../types';

export const getIntervalDuration = (
Expand All @@ -15,7 +15,7 @@ export const getIntervalDuration = (

export const getValidStartDate = (
startDate: Date | undefined,
firstDayOfWeek: number,
firstDayOfWeek?: number,
): Date | undefined => (startDate
? dateUtils.getFirstWeekDate(startDate, firstDayOfWeek)
: undefined);
Expand Down
Loading

0 comments on commit 1ad989c

Please sign in to comment.