ui updates for ticket layout now with multipel attachments
This commit is contained in:
@@ -8,6 +8,7 @@ use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Livewire\Attributes\On;
|
||||
use Livewire\Component;
|
||||
use Modules\Helpdesk\Models\KanbanBoard as KanbanBoardModel;
|
||||
use Modules\Helpdesk\Models\Status;
|
||||
@@ -55,12 +56,13 @@ final class KanbanBoard extends Component
|
||||
Auth::user()
|
||||
);
|
||||
|
||||
$this->board_id = $board?->id;
|
||||
$this->skipRender();
|
||||
|
||||
$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);
|
||||
$this->dispatch('helpdesk-kanban-refresh');
|
||||
$this->dispatch('helpdesk-kanban-ticket-moved', ticketId: $ticket->id, statusId: $status->id);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,10 +97,13 @@ final class KanbanBoard extends Component
|
||||
$fresh = $ticket->fresh(['status', 'priority', 'category', 'project', 'team', 'board']) ?? $ticket;
|
||||
$workflow->dispatch($fresh, 'ticket.updated', Auth::user());
|
||||
|
||||
$this->skipRender();
|
||||
|
||||
$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);
|
||||
$this->dispatch('helpdesk-kanban-refresh');
|
||||
$this->dispatch('helpdesk-kanban-ticket-moved', ticketId: $fresh->id, boardId: $board->id);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -109,6 +114,17 @@ final class KanbanBoard extends Component
|
||||
$this->board_id = is_numeric($value) ? (int) $value : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh the board after a drag/drop move, board change or external ticket update.
|
||||
*/
|
||||
#[On('helpdesk-kanban-refresh')]
|
||||
#[On('ticket-updated')]
|
||||
#[On('ticket-moved')]
|
||||
public function refreshBoard(): void
|
||||
{
|
||||
// Livewire will re-run render(), which reloads all board columns from the database.
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the Kanban board.
|
||||
*/
|
||||
|
||||
@@ -108,6 +108,7 @@ final class TicketEdit extends Component
|
||||
|
||||
$this->validate();
|
||||
$this->validate([
|
||||
'attachments' => 'array',
|
||||
'attachments.*' => 'file|max:'.config('helpdesk.max_upload_kb', 10240).'|mimes:'.implode(',', config('helpdesk.allowed_mimes', ['jpg', 'jpeg', 'png', 'pdf', 'txt', 'log', 'zip'])),
|
||||
'tag_ids.*' => 'integer|exists:helpdesk_tags,id',
|
||||
]);
|
||||
@@ -274,8 +275,9 @@ final class TicketEdit extends Component
|
||||
continue;
|
||||
}
|
||||
|
||||
$path = $upload->store('helpdesk/tickets/'.$this->ticket->id, 'public');
|
||||
$this->ticket->attachments()->create($this->attachmentPayload($upload, $path));
|
||||
$disk = (string) config('helpdesk.disk', 'local');
|
||||
$path = $upload->store('tickets/'.$this->ticket->id, $disk);
|
||||
$this->ticket->attachments()->create($this->attachmentPayload($upload, $path, $disk));
|
||||
}
|
||||
|
||||
$this->attachments = [];
|
||||
@@ -287,14 +289,14 @@ final class TicketEdit extends Component
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function attachmentPayload(TemporaryUploadedFile $upload, string $path): array
|
||||
private function attachmentPayload(TemporaryUploadedFile $upload, string $path, string $disk): array
|
||||
{
|
||||
$table = 'helpdesk_attachments';
|
||||
$payload = [];
|
||||
$columns = [
|
||||
'user_id' => Auth::id(),
|
||||
'uploaded_by_id' => Auth::id(),
|
||||
'disk' => 'public',
|
||||
'disk' => $disk,
|
||||
'path' => $path,
|
||||
'file_path' => $path,
|
||||
'filename' => basename($path),
|
||||
|
||||
Reference in New Issue
Block a user