mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-09 20:29:36 +02:00
fix some table drop conditions
This commit is contained in:
@@ -122,7 +122,11 @@ export const ItemTableListColumn = (props: ItemTableListColumn) => {
|
|||||||
target: DragTargetMap[props.itemType] || DragTarget.GENERIC,
|
target: DragTargetMap[props.itemType] || DragTarget.GENERIC,
|
||||||
},
|
},
|
||||||
drop: {
|
drop: {
|
||||||
canDrop: () => {
|
canDrop: (args) => {
|
||||||
|
if (args.source.type === DragTarget.TABLE_COLUMN) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (props.itemType === LibraryItem.QUEUE_SONG) {
|
if (props.itemType === LibraryItem.QUEUE_SONG) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -846,11 +850,14 @@ export const TableColumnHeaderContainer = (
|
|||||||
draggable({
|
draggable({
|
||||||
element: containerRef.current,
|
element: containerRef.current,
|
||||||
getInitialData: () => {
|
getInitialData: () => {
|
||||||
const data = dndUtils.generateDragData({
|
const data = dndUtils.generateDragData(
|
||||||
id: [props.type],
|
{
|
||||||
operation: [DragOperation.REORDER],
|
id: [props.type],
|
||||||
type: DragTarget.TABLE_COLUMN,
|
operation: [DragOperation.REORDER],
|
||||||
});
|
type: DragTarget.TABLE_COLUMN,
|
||||||
|
},
|
||||||
|
{ tableId: props.tableId },
|
||||||
|
);
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
onDragStart: () => {
|
onDragStart: () => {
|
||||||
@@ -866,16 +873,25 @@ export const TableColumnHeaderContainer = (
|
|||||||
dropTargetForElements({
|
dropTargetForElements({
|
||||||
canDrop: (args) => {
|
canDrop: (args) => {
|
||||||
const data = args.source.data as unknown as DragData;
|
const data = args.source.data as unknown as DragData;
|
||||||
|
const sourceTableId = (data.metadata as { tableId?: string })?.tableId;
|
||||||
const isSelf = (args.source.data.id as string[])[0] === props.type;
|
const isSelf = (args.source.data.id as string[])[0] === props.type;
|
||||||
return dndUtils.isDropTarget(data.type, [DragTarget.TABLE_COLUMN]) && !isSelf;
|
const isSameTable = sourceTableId === props.tableId;
|
||||||
|
return (
|
||||||
|
dndUtils.isDropTarget(data.type, [DragTarget.TABLE_COLUMN]) &&
|
||||||
|
!isSelf &&
|
||||||
|
isSameTable
|
||||||
|
);
|
||||||
},
|
},
|
||||||
element: containerRef.current,
|
element: containerRef.current,
|
||||||
getData: ({ element, input }) => {
|
getData: ({ element, input }) => {
|
||||||
const data = dndUtils.generateDragData({
|
const data = dndUtils.generateDragData(
|
||||||
id: [props.type],
|
{
|
||||||
operation: [DragOperation.REORDER],
|
id: [props.type],
|
||||||
type: DragTarget.TABLE_COLUMN,
|
operation: [DragOperation.REORDER],
|
||||||
});
|
type: DragTarget.TABLE_COLUMN,
|
||||||
|
},
|
||||||
|
{ tableId: props.tableId },
|
||||||
|
);
|
||||||
|
|
||||||
return attachClosestEdge(data, {
|
return attachClosestEdge(data, {
|
||||||
allowedEdges: ['left', 'right'],
|
allowedEdges: ['left', 'right'],
|
||||||
@@ -905,7 +921,7 @@ export const TableColumnHeaderContainer = (
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}, [props.type, props.enableColumnReorder, props.controls]);
|
}, [props.type, props.enableColumnReorder, props.controls, props.tableId]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex
|
<Flex
|
||||||
|
|||||||
Reference in New Issue
Block a user