Skip to content

Commit aa4297a

Browse files
committed
refactor: revert findCellPositionInMap
1 parent e83275d commit aa4297a

1 file changed

Lines changed: 25 additions & 27 deletions

File tree

packages/devextreme/js/__internal/scheduler/workspaces/view_model/grouped_data_map_provider.ts

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,26 @@ export class GroupedDataMapProvider {
145145
const {
146146
groupIndex, startDate, allDay, index,
147147
} = cellInfo;
148+
const {
149+
allDayPanelGroupedMap,
150+
dateTableGroupedMap,
151+
} = this.groupedDataMap;
148152
const { viewOffset } = this.viewOptions;
149153

150-
// eslint-disable-next-line @typescript-eslint/init-declarations
151-
let foundPosition: CellPositionData | undefined;
152-
this.getRowsForCellSearch(allDay, groupIndex).forEach((row) => {
153-
row.forEach((cell) => {
154+
const gIdx = groupIndex ?? 0;
155+
let rows: CellInfo[][] = dateTableGroupedMap[gIdx] || [];
156+
157+
if (allDay && !this.viewOptions.isVerticalGrouping) {
158+
const allDayRow = allDayPanelGroupedMap[gIdx];
159+
rows = allDayRow ? [allDayRow] : [];
160+
}
161+
162+
/* eslint-disable @typescript-eslint/prefer-for-of, max-depth */
163+
for (let rowIndex = 0; rowIndex < rows.length; rowIndex += 1) {
164+
const row = rows[rowIndex];
165+
166+
for (let columnIndex = 0; columnIndex < row.length; columnIndex += 1) {
167+
const cell = row[columnIndex];
154168
const originCellData = cell.cellData;
155169
// NOTE: If this is appointment's render call
156170
// we should shift the real cellData dates by viewOffset
@@ -163,32 +177,16 @@ export class GroupedDataMapProvider {
163177
}
164178
: originCellData;
165179

166-
if (
167-
foundPosition === undefined
168-
&& this.isSameGroupIndexAndIndex(cellData, groupIndex, index)
169-
&& this.isStartDateInCell(startDate, allDay, cellData, originCellData)
170-
) {
171-
foundPosition = cell.position;
180+
if (this.isSameGroupIndexAndIndex(cellData, groupIndex, index)) {
181+
if (this.isStartDateInCell(startDate, allDay, cellData, originCellData)) {
182+
return cell.position;
183+
}
172184
}
173-
});
174-
});
175-
176-
return foundPosition;
177-
}
178-
179-
private getRowsForCellSearch(
180-
allDay: boolean | undefined,
181-
groupIndex: number | undefined,
182-
): CellInfo[][] {
183-
const { allDayPanelGroupedMap, dateTableGroupedMap } = this.groupedDataMap;
184-
const gIdx = groupIndex ?? 0;
185-
186-
if (allDay && !this.viewOptions.isVerticalGrouping) {
187-
const allDayRow = allDayPanelGroupedMap[gIdx];
188-
return allDayRow ? [allDayRow] : [];
185+
}
189186
}
187+
/* eslint-enable @typescript-eslint/prefer-for-of, max-depth */
190188

191-
return dateTableGroupedMap[gIdx] ?? [];
189+
return undefined;
192190
}
193191

194192
private isStartDateInCell(

0 commit comments

Comments
 (0)