Skip to content

Commit cb358bc

Browse files
Scheduler - Fix TS strict build errors in form refactor
1 parent d8e4a76 commit cb358bc

3 files changed

Lines changed: 14 additions & 9 deletions

File tree

packages/devextreme/js/__internal/scheduler/appointment_popup/m_form.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ import { customizeFormItems } from './m_customize_form_items';
3838
import { RecurrenceForm } from './m_recurrence_form';
3939
import { createFormIconTemplate, getStartDateCommonConfig, RecurrenceRule } from './utils';
4040

41+
type SchedulerEditingObject = Exclude<NonNullable<SchedulerProperties['editing']>, boolean>;
42+
4143
export interface AppointmentFormConfig {
4244
dataAccessors: AppointmentDataAccessor;
4345
editing: SchedulerProperties['editing'];
@@ -232,12 +234,17 @@ export class AppointmentForm {
232234
this.createForm(customizedItems);
233235
}
234236

235-
private getEditingForm(): NonNullable<NonNullable<SchedulerProperties['editing']>['form']> | undefined {
237+
private getEditingForm(): SchedulerEditingObject['form'] {
238+
const editing = this.getEditingObject();
239+
return editing?.form;
240+
}
241+
242+
private getEditingObject(): SchedulerEditingObject | undefined {
236243
const { editing } = this.config;
237244
if (isBoolean(editing) || !editing) {
238245
return undefined;
239246
}
240-
return editing.form ?? undefined;
247+
return editing;
241248
}
242249

243250
private getIconsShowMode(): AppointmentFormIconsShowMode {
@@ -512,8 +519,7 @@ export class AppointmentForm {
512519
timeItemOptions?: SimpleItem,
513520
timezoneItemOptions?: SimpleItem,
514521
): GroupItem {
515-
const { editing } = this.config;
516-
const allowTimeZoneEditing = !isBoolean(editing) ? editing?.allowTimeZoneEditing : undefined;
522+
const allowTimeZoneEditing = this.getEditingObject()?.allowTimeZoneEditing;
517523
const { startDateExpr, endDateExpr } = this.config.dataAccessors.expr;
518524
const isStartDateEditor = dateExpr === startDateExpr;
519525

@@ -869,8 +875,7 @@ export class AppointmentForm {
869875

870876
showMainGroup(): void {
871877
const currentHeight = this.dxPopup.option('height') as string | number | undefined;
872-
const { editing } = this.config;
873-
const configuredHeight = (!isBoolean(editing) && editing?.popup?.height) || 'auto';
878+
const configuredHeight = this.getEditingObject()?.popup?.height ?? 'auto';
874879

875880
if (typeof currentHeight === 'number') {
876881
this.dxPopup.option('height', configuredHeight);

packages/devextreme/js/__internal/scheduler/appointment_popup/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import type { Rule } from '../recurrence/types';
1313

1414
export const createFormIconTemplate = (iconName: string): () => dxElementWrapper => (): dxElementWrapper => getImageContainer(iconName) ?? $('<div>').addClass('dx-scheduler-form-icon-sized-gap');
1515

16-
export const getStartDateCommonConfig = (firstDayOfWeek: string): SimpleItem => ({
16+
export const getStartDateCommonConfig = (firstDayOfWeek: number): SimpleItem => ({
1717
colSpan: 1,
1818
itemType: 'simple',
1919
editorType: 'dxDateBox',

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,8 +1139,8 @@ class Scheduler extends SchedulerOptionsBaseWidget {
11391139
dataAccessors: this._dataAccessors,
11401140
editing: this.editing,
11411141
resourceManager: this.resourceManager,
1142-
firstDayOfWeek: this.option('firstDayOfWeek'),
1143-
startDayHour: this.option('startDayHour'),
1142+
firstDayOfWeek: this.option('firstDayOfWeek') ?? 0,
1143+
startDayHour: this.option('startDayHour') ?? 0,
11441144
// @ts-expect-error
11451145
createComponent: (element, component, options) => this._createComponent(element, component, options),
11461146
getCalculatedEndDate: (startDateWithStartHour) => this._workSpace.calculateEndDate(startDateWithStartHour),

0 commit comments

Comments
 (0)