fix(enhanced-kanban): correct sort order handling for task drop positions
- Updated the logic for determining the sort order when tasks are dropped in the EnhancedKanbanBoard component. - Added handling for dropping tasks at the end of a group and ensured proper assignment of sort orders, improving task organization during drag-and-drop operations.
This commit is contained in:
@@ -318,16 +318,24 @@ const EnhancedKanbanBoard: React.FC<EnhancedKanbanBoardProps> = ({ projectId, cl
|
|||||||
// Find sort_order for from and to
|
// Find sort_order for from and to
|
||||||
const fromSortOrder = movedTask.sort_order;
|
const fromSortOrder = movedTask.sort_order;
|
||||||
let toSortOrder = -1;
|
let toSortOrder = -1;
|
||||||
if (targetGroup.tasks[targetIndex]) {
|
let toLastIndex = false;
|
||||||
toSortOrder = targetGroup.tasks[targetIndex].sort_order;
|
if (targetIndex === targetGroup.tasks.length) {
|
||||||
|
// Dropping at the end
|
||||||
|
toSortOrder = -1;
|
||||||
|
toLastIndex = true;
|
||||||
|
} else if (targetGroup.tasks[targetIndex]) {
|
||||||
|
toSortOrder = typeof targetGroup.tasks[targetIndex].sort_order === 'number' ? targetGroup.tasks[targetIndex].sort_order! : -1;
|
||||||
|
toLastIndex = false;
|
||||||
} else if (targetGroup.tasks.length > 0) {
|
} else if (targetGroup.tasks.length > 0) {
|
||||||
toSortOrder = targetGroup.tasks[targetGroup.tasks.length - 1].sort_order;
|
const lastSortOrder = targetGroup.tasks[targetGroup.tasks.length - 1].sort_order;
|
||||||
|
toSortOrder = typeof lastSortOrder === 'number' ? lastSortOrder! : -1;
|
||||||
|
toLastIndex = false;
|
||||||
}
|
}
|
||||||
const body = {
|
const body = {
|
||||||
project_id: projectId,
|
project_id: projectId,
|
||||||
from_index: fromSortOrder,
|
from_index: fromSortOrder,
|
||||||
to_index: toSortOrder,
|
to_index: toSortOrder,
|
||||||
to_last_index: !toSortOrder,
|
to_last_index: toLastIndex,
|
||||||
from_group: sourceGroup.id,
|
from_group: sourceGroup.id,
|
||||||
to_group: targetGroup.id,
|
to_group: targetGroup.id,
|
||||||
group_by: groupBy || 'status',
|
group_by: groupBy || 'status',
|
||||||
|
|||||||
Reference in New Issue
Block a user