dark mode supoport and new design now with delet esupport
This commit is contained in:
@@ -22,13 +22,13 @@ final class TicketIndex extends Component
|
||||
use AuthorizesRequests;
|
||||
use WithPagination;
|
||||
|
||||
public bool $deleteModalOpen = false;
|
||||
public bool $archiveModalOpen = false;
|
||||
|
||||
public ?int $pendingDeleteTicketId = null;
|
||||
public ?int $pendingArchiveTicketId = null;
|
||||
|
||||
public ?string $pendingDeleteTicketReference = null;
|
||||
public ?string $pendingArchiveTicketReference = null;
|
||||
|
||||
public ?string $pendingDeleteTicketSubject = null;
|
||||
public ?string $pendingArchiveTicketSubject = null;
|
||||
|
||||
#[Url]
|
||||
public string $search = '';
|
||||
@@ -48,54 +48,55 @@ final class TicketIndex extends Component
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the delete confirmation modal for a visible ticket.
|
||||
* Open the archive confirmation modal for a visible ticket.
|
||||
*/
|
||||
public function askToDeleteTicket(int $ticketId): void
|
||||
public function askToArchiveTicket(int $ticketId): void
|
||||
{
|
||||
$ticket = Ticket::query()
|
||||
->visibleTo(Auth::user())
|
||||
->findOrFail($ticketId);
|
||||
|
||||
$this->pendingDeleteTicketId = $ticket->id;
|
||||
$this->pendingDeleteTicketReference = $ticket->reference;
|
||||
$this->pendingDeleteTicketSubject = $ticket->subject;
|
||||
$this->deleteModalOpen = true;
|
||||
$this->pendingArchiveTicketId = $ticket->id;
|
||||
$this->pendingArchiveTicketReference = $ticket->reference;
|
||||
$this->pendingArchiveTicketSubject = $ticket->subject;
|
||||
$this->archiveModalOpen = true;
|
||||
}
|
||||
|
||||
public function cancelTicketDelete(): void
|
||||
public function cancelTicketArchive(): void
|
||||
{
|
||||
$this->resetTicketDeletionState();
|
||||
$this->resetTicketArchiveState();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the confirmed ticket.
|
||||
* Archive the confirmed ticket using Laravel soft deletes.
|
||||
*/
|
||||
public function confirmTicketDelete(): void
|
||||
public function confirmTicketArchive(): void
|
||||
{
|
||||
if ($this->pendingDeleteTicketId === null) {
|
||||
$this->resetTicketDeletionState();
|
||||
if ($this->pendingArchiveTicketId === null) {
|
||||
$this->resetTicketArchiveState();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$ticket = Ticket::query()
|
||||
->visibleTo(Auth::user())
|
||||
->findOrFail($this->pendingDeleteTicketId);
|
||||
->findOrFail($this->pendingArchiveTicketId);
|
||||
|
||||
$this->authorize('delete', $ticket);
|
||||
|
||||
$reference = $ticket->reference;
|
||||
|
||||
$ticket->forceFill(['archived_at' => now()])->save();
|
||||
$ticket->delete();
|
||||
|
||||
$this->resetTicketDeletionState();
|
||||
$this->resetTicketArchiveState();
|
||||
$this->resetPage();
|
||||
|
||||
$this->dispatch(
|
||||
'thredary:toast',
|
||||
type: 'success',
|
||||
title: 'Ticket deleted',
|
||||
message: "Ticket {$reference} was deleted successfully.",
|
||||
title: 'Ticket archived',
|
||||
message: "Ticket {$reference} was moved to the archive.",
|
||||
);
|
||||
}
|
||||
|
||||
@@ -108,12 +109,12 @@ final class TicketIndex extends Component
|
||||
])->layout('layouts.app');
|
||||
}
|
||||
|
||||
private function resetTicketDeletionState(): void
|
||||
private function resetTicketArchiveState(): void
|
||||
{
|
||||
$this->deleteModalOpen = false;
|
||||
$this->pendingDeleteTicketId = null;
|
||||
$this->pendingDeleteTicketReference = null;
|
||||
$this->pendingDeleteTicketSubject = null;
|
||||
$this->archiveModalOpen = false;
|
||||
$this->pendingArchiveTicketId = null;
|
||||
$this->pendingArchiveTicketReference = null;
|
||||
$this->pendingArchiveTicketSubject = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user