intial ticket fix partial delete fix

This commit is contained in:
Mark Gregory
2026-06-18 13:20:41 +01:00
parent 22452f9ab9
commit 704ac4de41
2 changed files with 164 additions and 2 deletions
+103
View File
@@ -19,6 +19,13 @@ final class TicketIndex extends Component
{
use WithPagination;
public bool $confirmingTicketDeletion = false;
public ?int $ticketDeletionId = null;
public ?string $ticketDeletionReference = null;
#[Url]
public string $search = '';
@@ -79,4 +86,100 @@ final class TicketIndex extends Component
->latest('last_activity_at')
->paginate(15);
}
/**
* Open the delete confirmation modal for a ticket.
*/
public function confirmDeleteTicket(int $ticketId): void
{
$ticket = Ticket::query()->findOrFail($ticketId);
$this->authorize('delete', $ticket);
$this->ticketDeletionId = $ticket->id;
$this->ticketDeletionReference = $ticket->reference;
$this->confirmingTicketDeletion = true;
}
/**
* Close the delete confirmation modal.
*/
public function cancelDeleteTicket(): void
{
$this->resetTicketDeletionState();
}
/**
* Delete the confirmed ticket.
*/
public function deleteConfirmedTicket(): void
{
if ($this->ticketDeletionId === null) {
$this->resetTicketDeletionState();
return;
}
$ticket = Ticket::query()->findOrFail($this->ticketDeletionId);
$this->authorize('delete', $ticket);
$reference = $ticket->reference;
$ticket->delete();
$this->resetTicketDeletionState();
$this->resetPage();
$this->dispatch('wms:toast', [
'type' => 'success',
'title' => 'Ticket deleted',
'message' => "Ticket {$reference} was deleted successfully.",
]);
}
/**
* Reset ticket deletion modal state.
*/
private function resetTicketDeletionState(): void
{
$this->confirmingTicketDeletion = false;
$this->ticketDeletionId = null;
$this->ticketDeletionReference = null;
}
}