Skip to content

Commit

Permalink
[REF] pivot, clickable cells: iterate over visible positions
Browse files Browse the repository at this point in the history
Those 2 methods were iterating over all visible positions using 2 nested for
loops, but there's a getter returning exactly those positions.
Now it's only one for loop, which is simpler.

closes #5432

Task: 4461339
Signed-off-by: Rémi Rahir (rar) <[email protected]>
  • Loading branch information
LucasLefevre committed Jan 8, 2025
1 parent 45998ae commit 5482a21
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 23 deletions.
26 changes: 10 additions & 16 deletions src/components/dashboard/clickable_cell_store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,23 +65,17 @@ export class ClickableCellsStore extends SpreadsheetStore {
const cells: ClickableCell[] = [];
const getters = this.getters;
const sheetId = getters.getActiveSheetId();
for (const col of getters.getSheetViewVisibleCols()) {
for (const row of getters.getSheetViewVisibleRows()) {
const position = { sheetId, col, row };
if (!getters.isMainCellPosition(position)) {
continue;
}
const action = this.getClickableAction(position);
if (!action) {
continue;
}
const zone = getters.expandZone(sheetId, positionToZone(position));
cells.push({
coordinates: getters.getVisibleRect(zone),
position,
action,
});
for (const position of this.getters.getVisibleCellPositions()) {
const action = this.getClickableAction(position);
if (!action) {
continue;
}
const zone = getters.expandZone(sheetId, positionToZone(position));
cells.push({
coordinates: getters.getVisibleRect(zone),
position,
action,
});
}
return cells;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,10 @@ export class PivotSidePanelStore extends SpreadsheetStore {
}

private isDynamicPivotInViewport() {
const sheetId = this.getters.getActiveSheetId();
for (const col of this.getters.getSheetViewVisibleCols()) {
for (const row of this.getters.getSheetViewVisibleRows()) {
const isDynamicPivot = this.getters.isSpillPivotFormula({ sheetId, col, row });
if (isDynamicPivot) {
return true;
}
for (const position of this.getters.getVisibleCellPositions()) {
const isDynamicPivot = this.getters.isSpillPivotFormula(position);
if (isDynamicPivot) {
return true;
}
}
return false;
Expand Down

0 comments on commit 5482a21

Please sign in to comment.