Skip to content

Commit

Permalink
add sorting abilities
Browse files Browse the repository at this point in the history
  • Loading branch information
mokhosh committed Nov 29, 2023
1 parent 5bff0d4 commit 24cd2c7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion resources/views/kanban-scripts.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand Down
17 changes: 14 additions & 3 deletions src/Concerns/HasStatusChange.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
//
}
Expand Down

0 comments on commit 24cd2c7

Please sign in to comment.