Skip to content
Closed
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
@@ -0,0 +1,68 @@
import {
describe, expect, it,
} from '@jest/globals';

import type { WorkspaceGroupedStrategyConfig } from '../workspaces/types';
import HorizontalGroupedStrategy from '../workspaces/work_space_grouped_strategy_horizontal';
import VerticalGroupedStrategy from '../workspaces/work_space_grouped_strategy_vertical';

const createConfig = (
overrides: Partial<WorkspaceGroupedStrategyConfig> = {},
): WorkspaceGroupedStrategyConfig => ({
isGroupedByDate: () => false,
getCellCount: () => 7,
getGroupCount: () => 3,
getRowCount: () => 48,
getCellWidth: () => 75,
getCellHeight: () => 50,
getAllDayHeight: () => 30,
getTimePanelWidth: () => 100,
getGroupTableWidth: () => 60,
getWorkSpaceWidth: () => 800,
getWorkSpaceLeftOffset: () => 160,
getIndicatorOffset: () => 10,
getIndicationHeight: () => 200,
getIndicationWidth: () => 300,
getCellIndexByCoordinates: () => 5,
supportAllDayRow: () => true,
getScrollableScrollTop: () => 0,
getScrollableContentElement: () => document.createElement('div'),
getElement: () => document.createElement('div'),
getHeaderPanelContainerElement: () => document.createElement('div'),
isRtlEnabled: () => false,
isShowAllDayPanel: () => true,
isCrossScrollingEnabled: () => false,
getStartDayHour: () => 0,
getEndDayHour: () => 24,
getHoursInterval: () => 0.5,
getHeaderHeight: () => 40,
...overrides,
});

describe('HorizontalGroupedStrategy with config object', () => {
it('should work with config interface instead of workspace', () => {
const strategy = new HorizontalGroupedStrategy(
createConfig({ getCellCount: () => 5, getGroupCount: () => 4 }),
);

const result = strategy.prepareCellIndexes({ rowIndex: 2, columnIndex: 3 }, 2);

expect(result.columnIndex).toBe(3 + 2 * 5);
expect(result.rowIndex).toBe(2);
});
});

describe('VerticalGroupedStrategy with config object', () => {
it('should work with config interface instead of workspace', () => {
const strategy = new VerticalGroupedStrategy(createConfig({
getRowCount: () => 10,
supportAllDayRow: () => true,
isShowAllDayPanel: () => true,
}));

const result = strategy.prepareCellIndexes({ rowIndex: 3, columnIndex: 2 }, 2, false);

expect(result.rowIndex).toBe(3 + 2 * 10 + 2 + 1);
expect(result.columnIndex).toBe(2);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ import {
getMaxAllowedPosition,
PositionHelper,
} from './helpers/position_helper';
import type { WorkspaceGroupedStrategyConfig } from './types';
import type { ViewDataProviderOptions } from './view_model/m_types';
import ViewDataProvider from './view_model/m_view_data_provider';
import { VirtualScrollingDispatcher, VirtualScrollingRenderer } from './virtual_scrolling';
Expand Down Expand Up @@ -924,6 +925,18 @@ class SchedulerWorkSpace extends Widget<WorkspaceOptionsInternal> {
});
}

protected getIndicatorOffset(): number {
return 0;
}

protected getIndicationHeight(): number {
return 0;
}

protected getIndicationWidth(): number {
return 0;
}

private isVirtualModeOn() {
return this.option('scrolling.mode') === 'virtual';
}
Expand Down Expand Up @@ -2625,7 +2638,37 @@ class SchedulerWorkSpace extends Widget<WorkspaceOptionsInternal> {
? VerticalGroupedStrategy
: HorizontalGroupedStrategy;

this.groupedStrategy = new Strategy(this);
const config: WorkspaceGroupedStrategyConfig = {
isGroupedByDate: this.isGroupedByDate.bind(this),
getCellCount: this.getCellCount.bind(this),
getGroupCount: this.getGroupCount.bind(this),
getRowCount: this.getRowCount.bind(this),
getCellWidth: this.getCellWidth.bind(this),
getCellHeight: this.getCellHeight.bind(this),
getAllDayHeight: this.getAllDayHeight.bind(this),
getTimePanelWidth: this.getTimePanelWidth.bind(this),
getGroupTableWidth: this.getGroupTableWidth.bind(this),
getWorkSpaceWidth: this.getWorkSpaceWidth.bind(this),
getWorkSpaceLeftOffset: this.getWorkSpaceLeftOffset.bind(this),
getIndicatorOffset: () => this.getIndicatorOffset(),
getIndicationHeight: () => this.getIndicationHeight(),
getIndicationWidth: () => this.getIndicationWidth(),
getCellIndexByCoordinates: this.getCellIndexByCoordinates.bind(this),
Comment thread
bit-byte0 marked this conversation as resolved.
supportAllDayRow: this.supportAllDayRow.bind(this),
getScrollableScrollTop: () => this.getScrollable().scrollTop(),
getScrollableContentElement: () => this.getScrollable().$content().get(0) as HTMLElement,
getElement: () => (this.$element() as any).get(0) as HTMLElement,
getHeaderPanelContainerElement: () => this.$headerPanelContainer.get(0) as HTMLElement,
isRtlEnabled: () => this.option('rtlEnabled'),
isShowAllDayPanel: () => this.option('showAllDayPanel'),
isCrossScrollingEnabled: () => this.option('crossScrollingEnabled'),
getStartDayHour: () => this.option('startDayHour'),
getEndDayHour: () => this.option('endDayHour'),
getHoursInterval: () => this.option('hoursInterval'),
getHeaderHeight: () => this.option('getHeaderHeight')(),
};

this.groupedStrategy = new Strategy(config);
}

protected getDefaultGroupStrategy() {
Expand Down
32 changes: 32 additions & 0 deletions packages/devextreme/js/__internal/scheduler/workspaces/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
export interface WorkspaceGroupedStrategyConfig {
isGroupedByDate: () => boolean;
getCellCount: () => number;
getGroupCount: () => number;
getRowCount: () => number;
getCellWidth: () => number;
getCellHeight: () => number;
getAllDayHeight: () => number;
getTimePanelWidth: () => number;
getGroupTableWidth: () => number;
getWorkSpaceWidth: () => number;
getWorkSpaceLeftOffset: () => number;
getIndicatorOffset: () => number;
getIndicationHeight: () => number;
getIndicationWidth: () => number;
Comment thread
bit-byte0 marked this conversation as resolved.
getCellIndexByCoordinates: (
coordinates: { top: number; left: number },
allDay?: boolean,
) => number;
supportAllDayRow: () => boolean;
getScrollableScrollTop: () => number;
getScrollableContentElement: () => HTMLElement;
getElement: () => HTMLElement;
getHeaderPanelContainerElement: () => HTMLElement;
isRtlEnabled: () => boolean;
isShowAllDayPanel: () => boolean;
isCrossScrollingEnabled: () => boolean;
getStartDayHour: () => number;
getEndDayHour: () => number;
getHoursInterval: () => number;
getHeaderHeight: () => number;
}
Loading
Loading