forked from DevExpress/DevExtreme
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Scheduler: migrate DateHeaderTimeline + GroupPanel (DevExpress#27162) (…
- Loading branch information
1 parent
ae8ba3e
commit 056a2a4
Showing
8 changed files
with
230 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
...evextreme/js/__internal/scheduler/__migration/components/timeline/date_header_timeline.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
import { BaseInfernoComponent } from '@devextreme/runtime/inferno'; | ||
import { getTemplate } from '@ts/core/component_wrappers/utils/index'; | ||
import { getThemeType } from '@ts/scheduler/__migration/utils/themes'; | ||
import type { VNode } from 'inferno'; | ||
import { | ||
createComponentVNode, | ||
createFragment, | ||
} from 'inferno'; | ||
|
||
import { isHorizontalGroupingApplied } from '../../utils/index'; | ||
import type { DateHeaderProps } from '../base/date_header'; | ||
import { DateHeaderDefaultProps } from '../base/date_header'; | ||
import { DateHeaderCell } from '../base/date_header_cell'; | ||
import { Row } from '../base/row'; | ||
|
||
const { | ||
isMaterialBased, | ||
} = getThemeType(); | ||
|
||
export class TimelineDateHeaderLayout extends BaseInfernoComponent<DateHeaderProps> { | ||
render(): VNode { | ||
const { | ||
groupByDate, | ||
groupOrientation, | ||
groups, | ||
dateHeaderData, | ||
dateCellTemplate, | ||
timeCellTemplate, | ||
} = this.props; | ||
const { | ||
dataMap, | ||
isMonthDateHeader, | ||
leftVirtualCellCount, | ||
leftVirtualCellWidth, | ||
rightVirtualCellCount, | ||
rightVirtualCellWidth, | ||
weekDayLeftVirtualCellCount, | ||
weekDayLeftVirtualCellWidth, | ||
weekDayRightVirtualCellCount, | ||
weekDayRightVirtualCellWidth, | ||
} = dateHeaderData; | ||
const isHorizontalGrouping = isHorizontalGroupingApplied(groups, groupOrientation) | ||
&& !groupByDate; | ||
const dateCellTemplateComponent = getTemplate(dateCellTemplate); | ||
const timeCellTemplateComponent = getTemplate(timeCellTemplate); | ||
|
||
return createFragment(dataMap.map((dateHeaderRow, rowIndex) => { | ||
const rowsCount = dataMap.length; | ||
const isTimeCellTemplate = rowsCount - 1 === rowIndex; | ||
const isWeekDayRow = rowsCount > 1 && rowIndex === 0; | ||
const splitText = isMaterialBased && (isMonthDateHeader || isWeekDayRow); | ||
|
||
let validLeftVirtualCellCount: number | undefined = leftVirtualCellCount; | ||
let validRightVirtualCellCount: number | undefined = rightVirtualCellCount; | ||
let validRightVirtualCellWidth: number | undefined = rightVirtualCellWidth; | ||
let validLeftVirtualCellWidth: number | undefined = leftVirtualCellWidth; | ||
|
||
if (isWeekDayRow) { | ||
validLeftVirtualCellCount = weekDayLeftVirtualCellCount; | ||
validRightVirtualCellCount = weekDayRightVirtualCellCount; | ||
validRightVirtualCellWidth = weekDayRightVirtualCellWidth; | ||
validLeftVirtualCellWidth = weekDayLeftVirtualCellWidth; | ||
} | ||
|
||
return createComponentVNode(2, Row, { | ||
className: 'dx-scheduler-header-row', | ||
leftVirtualCellWidth: validLeftVirtualCellWidth, | ||
leftVirtualCellCount: validLeftVirtualCellCount, | ||
rightVirtualCellWidth: validRightVirtualCellWidth, | ||
rightVirtualCellCount: validRightVirtualCellCount, | ||
children: dateHeaderRow.map((_ref2) => { | ||
const { | ||
colSpan, | ||
endDate, | ||
groupIndex, | ||
groups: cellGroups, | ||
index, | ||
isFirstGroupCell, | ||
isLastGroupCell, | ||
key, | ||
startDate, | ||
text, | ||
today, | ||
} = _ref2; | ||
return createComponentVNode(2, DateHeaderCell, { | ||
startDate, | ||
endDate, | ||
groups: isHorizontalGrouping ? cellGroups : undefined, | ||
groupIndex: isHorizontalGrouping ? groupIndex : undefined, | ||
today, | ||
index, | ||
text, | ||
isFirstGroupCell, | ||
isLastGroupCell, | ||
isWeekDayCell: isWeekDayRow, | ||
colSpan, | ||
splitText, | ||
dateCellTemplate: dateCellTemplateComponent, | ||
timeCellTemplate: timeCellTemplateComponent, | ||
isTimeCellTemplate, | ||
}, key); | ||
}), | ||
}, rowIndex.toString()); | ||
}), 0); | ||
} | ||
} | ||
|
||
TimelineDateHeaderLayout.defaultProps = DateHeaderDefaultProps; |
46 changes: 46 additions & 0 deletions
46
...vextreme/js/__internal/scheduler/__migration/components/timeline/header_panel_timeline.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import type { InfernoEffect } from '@devextreme/runtime/inferno'; | ||
import { createReRenderEffect, InfernoWrapperComponent } from '@devextreme/runtime/inferno'; | ||
import { getTemplate } from '@ts/core/component_wrappers/utils/index'; | ||
import type { VNode } from 'inferno'; | ||
import { createComponentVNode } from 'inferno'; | ||
|
||
import type { HeaderPanelProps } from '../base/header_panel'; | ||
import { HeaderPanel, HeaderPanelDefaultProps } from '../base/header_panel'; | ||
import { TimelineDateHeaderLayout } from './date_header_timeline'; | ||
|
||
export class HeaderPanelTimeline extends InfernoWrapperComponent<HeaderPanelProps> { | ||
createEffects(): InfernoEffect[] { | ||
return [createReRenderEffect()]; | ||
} | ||
|
||
render(): VNode { | ||
const { | ||
dateCellTemplate, | ||
dateHeaderData, | ||
groupByDate, | ||
groupOrientation, | ||
groupPanelData, | ||
groups, | ||
isRenderDateHeader, | ||
resourceCellTemplate, | ||
timeCellTemplate, | ||
} = this.props; | ||
const dateCellTemplateComponent = getTemplate(dateCellTemplate); | ||
const resourceCellTemplateComponent = getTemplate(resourceCellTemplate); | ||
const timeCellTemplateComponent = getTemplate(timeCellTemplate); | ||
|
||
return createComponentVNode(2, HeaderPanel, { | ||
dateHeaderTemplate: TimelineDateHeaderLayout, | ||
dateHeaderData, | ||
groupPanelData, | ||
groupByDate, | ||
groups, | ||
groupOrientation, | ||
isRenderDateHeader, | ||
resourceCellTemplate: resourceCellTemplateComponent, | ||
dateCellTemplate: dateCellTemplateComponent, | ||
timeCellTemplate: timeCellTemplateComponent, | ||
}); | ||
} | ||
} | ||
HeaderPanelTimeline.defaultProps = HeaderPanelDefaultProps; |
39 changes: 39 additions & 0 deletions
39
packages/devextreme/js/__internal/scheduler/__migration/components/wrappers/group_panel.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import registerComponent from '@js/core/component_registrator'; | ||
import { ComponentWrapper } from '@ts/core/component_wrappers/index'; | ||
|
||
import { GroupPanel } from '../base/group_panel'; | ||
|
||
export class GroupPanelComponent extends ComponentWrapper { | ||
_setOptionsByReference(): void { | ||
// @ts-expect-error badly typed DomComponent | ||
super._setOptionsByReference(); | ||
// @ts-expect-error badly typed DomComponent | ||
this._optionsByReference = { | ||
// @ts-expect-error badly typed DomComponent | ||
...this._optionsByReference, | ||
resourceCellTemplate: true, | ||
}; | ||
} | ||
|
||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ | ||
/* eslint-disable @typescript-eslint/explicit-function-return-type */ | ||
get _propsInfo() { | ||
return { | ||
twoWay: [], | ||
allowNull: [], | ||
elements: [], | ||
templates: ['resourceCellTemplate'], | ||
props: ['groups', 'groupOrientation', 'groupPanelData', 'groupByDate', 'height', 'className', 'resourceCellTemplate'], | ||
}; | ||
} | ||
|
||
/* eslint-enable @typescript-eslint/explicit-module-boundary-types */ | ||
/* eslint-enable @typescript-eslint/explicit-function-return-type */ | ||
|
||
// @ts-expect-error types error in R1 | ||
get _viewComponent(): typeof GroupPanel { | ||
return GroupPanel; | ||
} | ||
} | ||
|
||
registerComponent('dxGroupPanel', GroupPanelComponent); |
25 changes: 25 additions & 0 deletions
25
...vextreme/js/__internal/scheduler/__migration/components/wrappers/header_panel_timeline.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import registerComponent from '@js/core/component_registrator'; | ||
|
||
import { HeaderPanelTimeline } from '../timeline/header_panel_timeline'; | ||
import { HeaderPanelComponent } from './header_panel'; | ||
|
||
export class HeaderPanelTimelineComponent extends HeaderPanelComponent { | ||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ | ||
/* eslint-disable @typescript-eslint/explicit-function-return-type */ | ||
get _propsInfo() { | ||
return { | ||
twoWay: [], | ||
allowNull: [], | ||
elements: [], | ||
templates: ['dateCellTemplate', 'timeCellTemplate', 'dateHeaderTemplate', 'resourceCellTemplate'], | ||
props: ['dateHeaderData', 'isRenderDateHeader', 'dateCellTemplate', 'timeCellTemplate', 'dateHeaderTemplate', 'groups', 'groupOrientation', 'groupPanelData', 'groupByDate', 'height', 'className', 'resourceCellTemplate'], | ||
}; | ||
} | ||
/* eslint-enable @typescript-eslint/explicit-module-boundary-types */ | ||
/* eslint-enable @typescript-eslint/explicit-function-return-type */ | ||
|
||
get _viewComponent(): typeof HeaderPanelTimeline { | ||
return HeaderPanelTimeline; | ||
} | ||
} | ||
registerComponent('dxTimelineHeaderPanelLayout', HeaderPanelTimelineComponent); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters