Skip to content

Commit 0e0cea8

Browse files
committed
refactor: add drill level limitation
1 parent d5e7e00 commit 0e0cea8

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

frontend/src/app/components/ChartDrill/ChartDrillContextMenu.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,14 @@ const ChartDrillContextMenu: FC<{}> = memo(({ children }) => {
5757
{!!currentDrillLevel && (
5858
<Menu.Item key={'rollUp'}>{t('rollUp')}</Menu.Item>
5959
)}
60-
{drillOption?.mode !== DrillMode.Expand && (
61-
<Menu.Item key={DrillMode.Drill}>{t('showNextLevel')}</Menu.Item>
62-
)}
63-
{drillOption?.mode !== DrillMode.Drill && (
64-
<Menu.Item key={DrillMode.Expand}>{t('expandNextLevel')}</Menu.Item>
65-
)}
60+
{drillOption?.mode !== DrillMode.Expand &&
61+
!drillOption?.isBottomLevel && (
62+
<Menu.Item key={DrillMode.Drill}>{t('showNextLevel')}</Menu.Item>
63+
)}
64+
{drillOption?.mode !== DrillMode.Drill &&
65+
!drillOption?.isBottomLevel && (
66+
<Menu.Item key={DrillMode.Expand}>{t('expandNextLevel')}</Menu.Item>
67+
)}
6668
{drillOption?.mode !== DrillMode.Expand && (
6769
<Menu.Item key="selectDrillStatus">
6870
<MenuSwitch

frontend/src/app/models/ChartDrillOption.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ export class ChartDrillOption implements IChartDrillOption {
5959
return this.isSelected;
6060
}
6161

62+
public get isBottomLevel() {
63+
return this.cursor + 2 === this.drillFields.length;
64+
}
65+
6266
public get canSelect() {
6367
return isEmptyArray(this.expandDownFields);
6468
}

frontend/src/app/pages/MainPage/pages/VizPage/ChartPreview/ChartPreview.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,10 @@ const ChartPreviewBoard: FC<{
159159
{
160160
name: 'click',
161161
callback: param => {
162-
if (drillOptionRef.current?.isSelectedDrill) {
162+
if (
163+
drillOptionRef.current?.isSelectedDrill &&
164+
!drillOptionRef.current.isBottomLevel
165+
) {
163166
const option = drillOptionRef.current;
164167
option.drillDown(param.data.rowData);
165168
drillOptionRef.current = option;

frontend/src/app/types/ChartDrillOption.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { ChartDataSectionField } from 'app/types/ChartConfig';
2121
export interface IChartDrillOption {
2222
mode: DrillMode;
2323
isSelectedDrill: boolean;
24+
isBottomLevel: boolean;
2425
canSelect: boolean;
2526
toggleSelectedDrill(enable?: boolean): void;
2627
getAllFields(): ChartDataSectionField[];

0 commit comments

Comments
 (0)