diff --git a/resources/views/kanban-scripts.blade.php b/resources/views/kanban-scripts.blade.php index f0adc1b..b4c0c78 100644 --- a/resources/views/kanban-scripts.blade.php +++ b/resources/views/kanban-scripts.blade.php @@ -17,7 +17,7 @@ function onUpdate(e) { const status = e.from.id const orderedIds = [].slice.call(e.from.children).map(child => child.id) - Livewire.dispatch('status-changed', {recordId, status, orderedIds}) + Livewire.dispatch('sort-changed', {recordId, status, orderedIds}) } window.onload = () => { diff --git a/src/Concerns/HasStatusChange.php b/src/Concerns/HasStatusChange.php index b7c58bb..bdf9e44 100644 --- a/src/Concerns/HasStatusChange.php +++ b/src/Concerns/HasStatusChange.php @@ -7,12 +7,23 @@ trait HasStatusChange { #[On('status-changed')] - public function statusChanged(int $recordId, string $status): void + public function statusChanged(int $recordId, string $status, array $fromOrderedIds, array $toOrderedIds): void { - $this->onStatusChanged($recordId, $status); + $this->onStatusChanged($recordId, $status, $fromOrderedIds, $toOrderedIds); } - public function onStatusChanged(int $recordId, string $status): void + public function onStatusChanged(int $recordId, string $status, array $fromOrderedIds, array $toOrderedIds): void + { + // + } + + #[On('sort-changed')] + public function sortChanged(int $recordId, string $status, array $orderedIds): void + { + $this->onSortChanged($recordId, $status, $orderedIds); + } + + public function onSortChanged(int $recordId, string $status, array $orderedIds): void { // }