Skip to content

Commit

Permalink
fix: should change table columns orders when drag items in section, i…
Browse files Browse the repository at this point in the history
  • Loading branch information
Cuiyansong committed Aug 22, 2022
1 parent 0be21a9 commit 5211ce6
Showing 1 changed file with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export const ChartDraggableTargetContainer: FC<ChartDataConfigSectionProps> =
},
canDrop: (item: ChartDataSectionField, monitor) => {
let items = Array.isArray(item) ? item : [item];
const currentRowNames = currentConfig.rows?.map(col => col.colName);

if (
[CHART_DRAG_ELEMENT_TYPE.DATASET_COLUMN_GROUP].includes(
monitor.getItemType() as any,
Expand Down Expand Up @@ -194,6 +194,16 @@ export const ChartDraggableTargetContainer: FC<ChartDataConfigSectionProps> =
return false;
}

const currentSectionDimensionRowNames = currentConfig.rows
?.filter(
r =>
!items
?.map(i => i?.uid)
?.filter(Boolean)
.includes(r?.uid),
)
?.map(col => col.colName);

if (
items[0].category ===
ChartDataViewFieldCategory.DateLevelComputedField
Expand All @@ -207,8 +217,10 @@ export const ChartDraggableTargetContainer: FC<ChartDataConfigSectionProps> =
) {
return false;
}
return currentRowNames
? currentRowNames.every(v => !v?.includes(items[0].colName))
return currentSectionDimensionRowNames
? currentSectionDimensionRowNames.every(
v => !v?.includes(items[0].colName),
)
: true;
}

Expand All @@ -217,7 +229,7 @@ export const ChartDraggableTargetContainer: FC<ChartDataConfigSectionProps> =
}

const isNotExist = items.every(
i => !currentRowNames?.includes(i.colName),
i => !currentSectionDimensionRowNames?.includes(i.colName),
);
return isNotExist;
},
Expand Down

0 comments on commit 5211ce6

Please sign in to comment.