Skip to content

Commit cac6c85

Browse files
committed
Refactor TasksBoard and InteractsWithBoard to support descending order for task reordering
1 parent b48cb31 commit cac6c85

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/Concerns/InteractsWithBoard.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,13 @@ public function updateRecordsOrderAndColumn(string $columnId, array $recordIds):
100100
// Add sort order if reordering is configured
101101
$reorderBy = $board->getReorderBy();
102102
if ($reorderBy && $this->modelHasOrderColumn($record, $reorderBy['column'])) {
103-
$updateData[$reorderBy['column']] = $index;
103+
// For DESC order: first item (index 0) gets highest value
104+
// For ASC order: first item (index 0) gets lowest value (0)
105+
if ($reorderBy['direction'] === 'desc') {
106+
$updateData[$reorderBy['column']] = count($recordIds) - 1 - $index;
107+
} else {
108+
$updateData[$reorderBy['column']] = $index;
109+
}
104110
}
105111

106112
$success = $record->update($updateData) && $success;

0 commit comments

Comments
 (0)