major ui updates
This commit is contained in:
@@ -8,26 +8,32 @@ use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Livewire\Component;
|
||||
use Modules\Helpdesk\Models\KanbanBoard as KanbanBoardModel;
|
||||
use Modules\Helpdesk\Models\Status;
|
||||
use Modules\Helpdesk\Models\Ticket;
|
||||
use Modules\Helpdesk\Services\WorkflowNotificationService;
|
||||
|
||||
final class KanbanBoard extends Component
|
||||
{
|
||||
public ?int $board_id = null;
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$this->board_id = KanbanBoardModel::query()
|
||||
->where('is_default', true)
|
||||
->orderBy('sort_order')
|
||||
->value('id') ?: KanbanBoardModel::query()->orderBy('sort_order')->value('id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Move a ticket to another workflow status.
|
||||
*
|
||||
* @param int $ticketId
|
||||
* @param int $statusId
|
||||
* @param WorkflowNotificationService $workflow
|
||||
* @return void
|
||||
*/
|
||||
public function moveTicket(int $ticketId, int $statusId, WorkflowNotificationService $workflow): void
|
||||
public function moveTicket(int|string $ticketId, int|string $statusId, WorkflowNotificationService $workflow): void
|
||||
{
|
||||
$ticket = Ticket::query()->visibleTo(Auth::user())->findOrFail($ticketId);
|
||||
$status = Status::query()->findOrFail($statusId);
|
||||
$ticket = Ticket::query()->visibleTo(Auth::user())->findOrFail((int) $ticketId);
|
||||
$status = Status::query()->findOrFail((int) $statusId);
|
||||
|
||||
$oldStatus = $ticket->status?->name;
|
||||
$this->authorize('update', $ticket);
|
||||
|
||||
$ticket->forceFill([
|
||||
'status_id' => $status->id,
|
||||
@@ -36,8 +42,8 @@ final class KanbanBoard extends Component
|
||||
])->save();
|
||||
|
||||
$workflow->dispatch(
|
||||
$ticket->fresh(['owner', 'agent', 'status', 'priority', 'category', 'project', 'team']),
|
||||
$status->is_closed ? 'ticket_closed' : 'ticket_updated',
|
||||
$ticket->fresh(['owner', 'agent', 'status', 'priority', 'category', 'project', 'team']) ?? $ticket,
|
||||
$status->is_closed ? 'ticket.closed' : 'ticket.updated',
|
||||
Auth::user()
|
||||
);
|
||||
|
||||
@@ -46,13 +52,22 @@ final class KanbanBoard extends Component
|
||||
|
||||
/**
|
||||
* Render the Kanban board.
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
public function render(): View
|
||||
{
|
||||
$boards = KanbanBoardModel::query()
|
||||
->with('statuses')
|
||||
->orderBy('sort_order')
|
||||
->orderBy('name')
|
||||
->get();
|
||||
|
||||
$board = $boards->firstWhere('id', $this->board_id) ?? $boards->first();
|
||||
$statuses = $board?->statuses ?? Status::query()->orderBy('sort_order')->orderBy('name')->get();
|
||||
|
||||
return view('helpdesk::livewire.kanban-board', [
|
||||
'statuses' => Status::query()->orderBy('sort_order')->get(),
|
||||
'boards' => $boards,
|
||||
'board' => $board,
|
||||
'statuses' => $statuses,
|
||||
'ticketsByStatus' => $this->ticketsByStatus(),
|
||||
])->layout('layouts.app');
|
||||
}
|
||||
@@ -68,7 +83,7 @@ final class KanbanBoard extends Component
|
||||
->with(['owner', 'agent', 'status', 'priority', 'category', 'project', 'team'])
|
||||
->visibleTo(Auth::user())
|
||||
->latest('last_activity_at')
|
||||
->limit(200)
|
||||
->limit(300)
|
||||
->get()
|
||||
->groupBy('status_id')
|
||||
->all();
|
||||
|
||||
Reference in New Issue
Block a user