intial ticket fix partial delete fix
This commit is contained in:
@@ -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;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user