From a87c9762c9d1a2bcb2ff288d93835a76077acd47 Mon Sep 17 00:00:00 2001 From: Mark Gregory Date: Wed, 17 Jun 2026 13:15:55 +0100 Subject: [PATCH] ui updates for ticket layout --- Modules/Helpdesk/Livewire/KanbanBoard.php | 4 + Modules/Helpdesk/Livewire/TicketShow.php | 34 ++++ .../views/livewire/kanban-board.blade.php | 11 +- .../views/livewire/ticket-show.blade.php | 186 ++++++++++-------- .../Tests/Feature/KanbanBoardTest.php | 4 +- .../Tests/Feature/TicketConversationTest.php | 34 ++++ Modules/Helpdesk/changelog.yaml | 11 ++ Modules/Helpdesk/module.json | 2 +- 8 files changed, 202 insertions(+), 84 deletions(-) diff --git a/Modules/Helpdesk/Livewire/KanbanBoard.php b/Modules/Helpdesk/Livewire/KanbanBoard.php index ebddf76f..9326c1a3 100644 --- a/Modules/Helpdesk/Livewire/KanbanBoard.php +++ b/Modules/Helpdesk/Livewire/KanbanBoard.php @@ -55,9 +55,12 @@ final class KanbanBoard extends Component Auth::user() ); + $this->board_id = $board?->id; + $message = 'Ticket '.$ticket->reference.' moved from '.$oldStatusName.' to '.$status->name.'.'; session()->flash('success', $message); $this->dispatch('wms:toast', type: 'success', title: 'Ticket moved', message: $message); + $this->dispatch('helpdesk-kanban-ticket-moved', ticketId: (int) $ticket->id, statusId: (int) $status->id); } /** @@ -95,6 +98,7 @@ final class KanbanBoard extends Component $message = 'Ticket '.$fresh->reference.' moved from '.$oldBoardName.' to '.$board->name.'.'; session()->flash('success', $message); $this->dispatch('wms:toast', type: 'success', title: 'Board changed', message: $message); + $this->dispatch('helpdesk-kanban-ticket-moved', ticketId: (int) $fresh->id, statusId: (int) $fresh->status_id); } /** diff --git a/Modules/Helpdesk/Livewire/TicketShow.php b/Modules/Helpdesk/Livewire/TicketShow.php index 5e0979d1..79b4d330 100644 --- a/Modules/Helpdesk/Livewire/TicketShow.php +++ b/Modules/Helpdesk/Livewire/TicketShow.php @@ -24,6 +24,7 @@ use Modules\Helpdesk\Models\Priority; use Modules\Helpdesk\Models\Status; use Modules\Helpdesk\Models\Ticket; use Modules\Helpdesk\Services\CannedResponseRenderer; +use Modules\Helpdesk\Services\AttachmentService; use Modules\Helpdesk\Services\ChecklistService; use Modules\Helpdesk\Services\SlaService; use Modules\Helpdesk\Services\TicketService; @@ -43,6 +44,9 @@ final class TicketShow extends Component /** @var array */ public array $attachments = []; + /** @var array */ + public array $supportingFiles = []; + public ?int $status_id = null; public ?int $priority_id = null; @@ -259,6 +263,36 @@ final class TicketShow extends Component $this->dispatch('helpdesk-agent-updated', agentId: $this->agent_id); } + /** + * Persist one or more supporting files directly against an existing ticket. + * + * This is intentionally separate from comment attachments so users can add + * evidence to an already-created ticket without posting another response. + */ + public function saveSupportingFiles(AttachmentService $attachments): void + { + $this->authorize('comment', $this->ticket); + + $maxUploadKilobytes = (int) config('helpdesk.max_upload_kb', 10240); + $allowedMimes = implode(',', config('helpdesk.allowed_mimes', ['jpg', 'jpeg', 'png', 'pdf', 'txt', 'log', 'zip'])); + + $this->validate([ + 'supportingFiles' => ['required', 'array', 'min:1'], + 'supportingFiles.*' => ['file', 'max:'.$maxUploadKilobytes, 'mimes:'.$allowedMimes], + ]); + + $user = Auth::user(); + abort_if($user === null, 403); + + $attachments->storeMany($this->ticket, $this->supportingFiles, (int) $user->id); + + $this->reset('supportingFiles'); + $this->ticket = $this->freshTicket($this->ticket); + + session()->flash('ticket-supporting-files-added', 'Supporting files attached.'); + $this->dispatch('helpdesk-supporting-files-added'); + } + public function render(): View { return view('helpdesk::livewire.ticket-show', [ diff --git a/Modules/Helpdesk/Resources/views/livewire/kanban-board.blade.php b/Modules/Helpdesk/Resources/views/livewire/kanban-board.blade.php index 95e146ec..21fc396f 100644 --- a/Modules/Helpdesk/Resources/views/livewire/kanban-board.blade.php +++ b/Modules/Helpdesk/Resources/views/livewire/kanban-board.blade.php @@ -254,11 +254,11 @@ This board is being initialised with the default workflow statuses. Refresh the page if the columns do not appear immediately. @else -
+
@foreach ($statuses as $status) @php($tickets = $ticketsByStatus[$status->id] ?? collect()) -
+
@@ -281,6 +281,7 @@ data-helpdesk-kanban-ticket data-ticket-id="{{ $ticket->id }}" dusk="kanban-ticket-{{ $ticket->id }}" + wire:key="helpdesk-kanban-ticket-{{ $ticket->id }}-{{ $ticket->status_id }}-{{ optional($ticket->updated_at)->timestamp ?? 0 }}" >
@@ -409,7 +410,9 @@ if (!ticketId || !statusId) return; - $wire.moveTicket(ticketId, statusId); + $wire.moveTicket(ticketId, statusId).then(function () { + initialiseHelpdeskKanban(); + }); }); }); }; @@ -417,6 +420,8 @@ initialiseHelpdeskKanban(); document.addEventListener('livewire:navigated', initialiseHelpdeskKanban); document.addEventListener('livewire:updated', initialiseHelpdeskKanban); + document.addEventListener('livewire:update', initialiseHelpdeskKanban); + document.addEventListener('helpdesk-kanban-ticket-moved', initialiseHelpdeskKanban); @endscript
diff --git a/Modules/Helpdesk/Resources/views/livewire/ticket-show.blade.php b/Modules/Helpdesk/Resources/views/livewire/ticket-show.blade.php index 6a7b8be6..b223fa5c 100644 --- a/Modules/Helpdesk/Resources/views/livewire/ticket-show.blade.php +++ b/Modules/Helpdesk/Resources/views/livewire/ticket-show.blade.php @@ -307,42 +307,114 @@
- @if ($ticket->attachments->isNotEmpty()) -
- -
- - - -
-

Ticket attachments

-

Supporting files

-

Screenshots, documents and logs linked to this ticket.

+
+
+
+
+ + + +
+

Ticket attachments

+

Supporting files

+

Attach multiple screenshots, documents, logs and evidence directly to this existing ticket.

+
+ + + + {{ $ticket->attachments->count() }} file{{ $ticket->attachments->count() === 1 ? '' : 's' }} +
- - - - {{ $ticket->attachments->count() }} file{{ $ticket->attachments->count() === 1 ? '' : 's' }} - - -
- - -
- @endif + +
+ @if (session('ticket-supporting-files-added')) +
+ {{ session('ticket-supporting-files-added') }} +
+ @endif + + @can('comment', $ticket) +
+
+
+ + + + + Attach supporting evidence + + {{ count($supportingFiles) === 0 ? 'No files selected' : count($supportingFiles).' file'.(count($supportingFiles) === 1 ? '' : 's').' selected' }} + + +
+ +
+ + + +
+
+ +
+ Preparing selected files… +
+ + @if (count($supportingFiles) > 0) +
+

Ready to attach

+
    + @foreach ($supportingFiles as $file) +
  • + {{ $file->getClientOriginalName() }} + {{ Number::fileSize((int) $file->getSize()) }} +
  • + @endforeach +
+
+ @endif + + @error('supportingFiles')
{{ $message }}
@enderror + @error('supportingFiles.*')
{{ $message }}
@enderror +
+ @endcan + + @if ($ticket->attachments->isEmpty()) +
+ No supporting files have been attached yet. +
+ @else + + @endif +
+
@@ -505,50 +577,6 @@ @endif @endcan -
- - - - - - - Attachments - Supporting files - Pin screenshots, logs and supporting documents. - - - - 0 files - - - - -
-
-
-
- - - - - Attach supporting evidence - No files attached - -
- -
- -
-
-
- @error('attachments.*')
{{ $message }}
@enderror -
-
-