Aded documentation module

This commit is contained in:
Mark Gregory
2026-06-12 15:32:09 +01:00
parent a2c68bc4dc
commit 1c9ed1a537
18 changed files with 418 additions and 85 deletions
@@ -30,17 +30,6 @@ final class HelpdeskDatabaseSeeder extends Seeder
$this->seedTeamsAndProjects();
$this->seedKanbanBoards();
$this->seedWorkflowTemplates();
DB::table('helpdesk_kanban_boards')->updateOrInsert(
['slug' => 'default'],
[
'name' => 'Default Helpdesk Board',
'description' => 'Standard support workflow board.',
'is_default' => true,
'sort_order' => 1,
'created_at' => now(),
'updated_at' => now(),
]
);
}
/**
@@ -136,6 +125,8 @@ final class HelpdeskDatabaseSeeder extends Seeder
*/
private function seedKanbanBoards(): void
{
KanbanBoard::query()->where('is_default', true)->update(['is_default' => false]);
$board = KanbanBoard::query()->updateOrCreate(
['slug' => 'standard-support'],
[
+5 -1
View File
@@ -62,7 +62,11 @@ final class KanbanBoard extends Component
->get();
$board = $boards->firstWhere('id', $this->board_id) ?? $boards->first();
$statuses = $board?->statuses ?? Status::query()->orderBy('sort_order')->orderBy('name')->get();
$statuses = $board?->statuses ?? collect();
if ($statuses->isEmpty()) {
$statuses = Status::query()->orderBy('sort_order')->orderBy('name')->get();
}
return view('helpdesk::livewire.kanban-board', [
'boards' => $boards,
@@ -11,6 +11,7 @@ use Illuminate\Support\Str;
use Livewire\Component;
use Modules\Helpdesk\Models\Category;
use Modules\Helpdesk\Models\GitRepository;
use Modules\Helpdesk\Models\KanbanBoard;
use Modules\Helpdesk\Models\Priority;
use Modules\Helpdesk\Models\Project;
use Modules\Helpdesk\Models\Status;
@@ -42,6 +43,9 @@ final class SettingsManager extends Component
/** @var array<string, mixed> */
public array $workflowForm = ['id' => null, 'name' => '', 'event' => 'ticket.created', 'subject' => '', 'html_body' => '', 'text_body' => '', 'to_role' => 'requester', 'cc' => '', 'bcc' => '', 'is_active' => true];
/** @var array<string, mixed> */
public array $boardForm = ['id' => null, 'name' => '', 'slug' => '', 'description' => '', 'is_default' => false, 'sort_order' => 0, 'status_ids' => []];
public function saveStatus(): void
{
$data = $this->validate([
@@ -241,6 +245,65 @@ final class SettingsManager extends Component
$this->repositoryForm = ['id' => null, 'company_id' => null, 'project_id' => null, 'name' => '', 'provider' => 'git', 'remote_url' => '', 'default_branch' => 'main', 'webhook_secret' => ''];
}
public function saveBoard(): void
{
$data = $this->validate([
'boardForm.name' => ['required', 'string', 'max:160'],
'boardForm.slug' => ['nullable', 'string', 'max:180'],
'boardForm.description' => ['nullable', 'string'],
'boardForm.is_default' => ['boolean'],
'boardForm.sort_order' => ['required', 'integer', 'min:0'],
'boardForm.status_ids' => ['required', 'array', 'min:1'],
'boardForm.status_ids.*' => ['integer', 'exists:helpdesk_statuses,id'],
])['boardForm'];
$statusIds = collect($data['status_ids'])
->map(static fn (mixed $id): int => (int) $id)
->filter()
->unique()
->values();
unset($data['status_ids']);
$data['slug'] = $this->slug($data['slug'] ?: $data['name']);
if ((bool) $data['is_default']) {
KanbanBoard::query()->where('is_default', true)->update(['is_default' => false]);
}
$board = KanbanBoard::query()->updateOrCreate(['id' => $this->boardForm['id']], $data);
$sync = [];
foreach ($statusIds as $index => $statusId) {
$sync[$statusId] = ['sort_order' => ($index + 1) * 10];
}
$board->statuses()->sync($sync);
$this->resetBoardForm();
$this->section = 'boards';
session()->flash('success', 'Kanban board saved.');
}
public function editBoard(int $id): void
{
$board = KanbanBoard::query()->with('statuses')->findOrFail($id);
$this->boardForm = $board->only(['id', 'name', 'slug', 'description', 'is_default', 'sort_order']);
$this->boardForm['status_ids'] = $board->statuses->pluck('id')->map(static fn (mixed $id): int => (int) $id)->all();
$this->section = 'boards';
}
public function deleteBoard(int $id): void
{
KanbanBoard::query()->findOrFail($id)->delete();
session()->flash('success', 'Kanban board deleted.');
}
public function resetBoardForm(): void
{
$this->boardForm = ['id' => null, 'name' => '', 'slug' => '', 'description' => '', 'is_default' => false, 'sort_order' => 0, 'status_ids' => []];
}
public function saveWorkflowTemplate(): void
{
$data = $this->validate([
@@ -287,6 +350,7 @@ final class SettingsManager extends Component
'teams' => Team::query()->withCount(['projects', 'tickets'])->orderBy('name')->get(),
'projects' => Project::query()->with(['team'])->withCount('tickets')->orderBy('title')->get(),
'repositories' => GitRepository::query()->with(['project'])->withCount('commits')->orderBy('name')->get(),
'boards' => KanbanBoard::query()->with('statuses')->withCount('statuses')->orderBy('sort_order')->orderBy('name')->get(),
'workflowTemplates' => WorkflowTemplate::query()->orderBy('event')->orderBy('name')->get(),
])->layout('layouts.app');
}
+17 -23
View File
@@ -73,6 +73,7 @@ final class TicketShow extends Component
$this->reset(['commentBody', 'internal', 'attachments']);
$this->ticket = $this->freshTicket($this->ticket);
$this->dispatch('helpdesk-editor-reset', model: 'commentBody');
$this->dispatch('helpdesk-comment-added');
}
@@ -87,8 +88,9 @@ final class TicketShow extends Component
$tickets->comment($this->ticket, Auth::user(), $this->replyBody, $this->internal, [], $this->reply_parent_id);
$this->cancelReply();
$this->reset(['reply_parent_id', 'replyBody']);
$this->ticket = $this->freshTicket($this->ticket);
$this->dispatch('helpdesk-editor-reset', model: 'replyBody');
$this->dispatch('helpdesk-reply-added');
}
@@ -144,39 +146,31 @@ final class TicketShow extends Component
'team',
'attachments.user',
'gitCommits.repository',
'comments.attachments',
'comments.replies.attachments',
'comments.replies.replies.attachments',
]) ?? $ticket;
$comments = $ticket->comments
->merge($ticket->comments->flatMap->replies)
->merge($ticket->comments->flatMap->replies->flatMap->replies);
$comments = \Modules\Helpdesk\Models\Comment::query()
->where('ticket_id', $ticket->id)
->with(['user', 'attachments.user'])
->oldest()
->get();
$users = User::query()
->whereIn('id', $comments->pluck('user_id')->filter()->unique())
->get()
->keyBy('id');
$this->attachCommentUsers($ticket->comments, $users);
$ticket->setRelation('comments', $this->buildCommentTree($comments->groupBy('parent_id')));
return $ticket;
}
/**
* Attach loaded users to comment hierarchy without triggering lazy loading.
* Build an unlimited nested comment tree from a flat eager-loaded collection.
*
* @param Collection<int, mixed> $comments
* @param Collection<int, User> $users
* @param Collection<int|string, Collection<int, mixed>> $grouped
* @return Collection<int, mixed>
*/
private function attachCommentUsers(Collection $comments, Collection $users): void
private function buildCommentTree(Collection $grouped, ?int $parentId = null): Collection
{
foreach ($comments as $comment) {
$comment->setRelation('user', $users->get($comment->user_id));
return $grouped->get($parentId, collect())->map(function ($comment) use ($grouped) {
$comment->setRelation('replies', $this->buildCommentTree($grouped, (int) $comment->id));
if ($comment->relationLoaded('replies')) {
$this->attachCommentUsers($comment->replies, $users);
}
}
return $comment;
})->values();
}
}
+3 -1
View File
@@ -28,7 +28,9 @@ final class TicketPolicy
public function update(User $user, Ticket $ticket): bool
{
return (bool) ($user->helpdesk_admin ?? false) || (int) $ticket->agent_id === (int) $user->id;
return (bool) ($user->helpdesk_admin ?? false)
|| (bool) ($user->helpdesk_agent ?? false)
|| (int) $ticket->agent_id === (int) $user->id;
}
public function comment(User $user, Ticket $ticket): bool
@@ -12,6 +12,7 @@
<div
{{ $attributes->whereDoesntStartWith('wire:model')->merge(['class' => 'space-y-2']) }}
x-on:helpdesk-editor-reset.window="if ($event.detail.model === model) clear()"
x-data="{
model: @js($model),
value: @js($initialValue),
@@ -26,6 +27,13 @@
document.execCommand(action, false, value);
this.sync();
},
clear() {
this.value = '';
this.$refs.editor.innerHTML = '';
if (this.model) {
this.$wire.set(this.model, '', false);
}
},
init() {
this.$refs.editor.innerHTML = this.value || '';
}
@@ -10,7 +10,7 @@
<td class="px-4 py-3 font-mono text-xs text-zinc-500">{{ $item->slug }}</td>
<td class="px-4 py-3"><flux:badge color="{{ $item->color }}">{{ $item->color }}</flux:badge></td>
<td class="px-4 py-3 text-zinc-500">{{ $item->tickets_count ?? 0 }}</td>
<td class="px-4 py-3 text-right"><flux:button size="sm" wire:click="{{ $edit }}({{ $item->id }})" variant="ghost">Edit</flux:button><flux:button size="sm" wire:click="{{ $delete }}({{ $item->id }})" variant="danger">Delete</flux:button></td>
<td class="px-4 py-3 text-right"><flux:button size="sm" wire:click="{{ $edit }}({{ $item->id }})" variant="primary">Edit</flux:button><flux:button size="sm" wire:click="{{ $delete }}({{ $item->id }})" variant="danger">Delete</flux:button></td>
</tr>
@empty
<tr><td colspan="5" class="px-4 py-10 text-center text-zinc-500">No records yet.</td></tr>
@@ -1 +1 @@
<div class="overflow-x-auto"><table class="min-w-full divide-y divide-zinc-200 text-sm dark:divide-zinc-700"><thead class="bg-zinc-50 text-left text-xs font-semibold uppercase tracking-wide text-zinc-500 dark:bg-zinc-800 dark:text-zinc-300"><tr><th class="px-4 py-3">Project</th><th class="px-4 py-3">Team</th><th class="px-4 py-3">Slug</th><th class="px-4 py-3">Colour</th><th class="px-4 py-3">Tickets</th><th class="px-4 py-3 text-right">Actions</th></tr></thead><tbody class="divide-y divide-zinc-100 dark:divide-zinc-800">@forelse ($items as $item)<tr><td class="px-4 py-3 font-medium text-zinc-900 dark:text-zinc-100">{{ $item->title }}</td><td class="px-4 py-3 text-zinc-500">{{ $item->team?->name ?? 'No team' }}</td><td class="px-4 py-3 font-mono text-xs text-zinc-500">{{ $item->slug }}</td><td class="px-4 py-3"><flux:badge color="{{ $item->color }}">{{ $item->color }}</flux:badge></td><td class="px-4 py-3 text-zinc-500">{{ $item->tickets_count }}</td><td class="px-4 py-3 text-right"><flux:button size="sm" wire:click="editProject({{ $item->id }})" variant="ghost">Edit</flux:button><flux:button size="sm" wire:click="deleteProject({{ $item->id }})" variant="danger">Delete</flux:button></td></tr>@empty<tr><td colspan="6" class="px-4 py-10 text-center text-zinc-500">No projects yet.</td></tr>@endforelse</tbody></table></div>
<div class="overflow-x-auto"><table class="min-w-full divide-y divide-zinc-200 text-sm dark:divide-zinc-700"><thead class="bg-zinc-50 text-left text-xs font-semibold uppercase tracking-wide text-zinc-500 dark:bg-zinc-800 dark:text-zinc-300"><tr><th class="px-4 py-3">Project</th><th class="px-4 py-3">Team</th><th class="px-4 py-3">Slug</th><th class="px-4 py-3">Colour</th><th class="px-4 py-3">Tickets</th><th class="px-4 py-3 text-right">Actions</th></tr></thead><tbody class="divide-y divide-zinc-100 dark:divide-zinc-800">@forelse ($items as $item)<tr><td class="px-4 py-3 font-medium text-zinc-900 dark:text-zinc-100">{{ $item->title }}</td><td class="px-4 py-3 text-zinc-500">{{ $item->team?->name ?? 'No team' }}</td><td class="px-4 py-3 font-mono text-xs text-zinc-500">{{ $item->slug }}</td><td class="px-4 py-3"><flux:badge color="{{ $item->color }}">{{ $item->color }}</flux:badge></td><td class="px-4 py-3 text-zinc-500">{{ $item->tickets_count }}</td><td class="px-4 py-3 text-right"><flux:button size="sm" wire:click="editProject({{ $item->id }})" variant="primary">Edit</flux:button><flux:button size="sm" wire:click="deleteProject({{ $item->id }})" variant="danger">Delete</flux:button></td></tr>@empty<tr><td colspan="6" class="px-4 py-10 text-center text-zinc-500">No projects yet.</td></tr>@endforelse</tbody></table></div>
@@ -21,7 +21,7 @@
<td class="px-4 py-3 text-zinc-600 dark:text-zinc-300">{{ $item->default_branch }}</td>
<td class="px-4 py-3"><flux:badge color="zinc">{{ $item->commits_count }}</flux:badge></td>
<td class="px-4 py-3 text-right">
<flux:button size="sm" variant="ghost" wire:click="editRepository({{ $item->id }})">Edit</flux:button>
<flux:button size="sm" variant="primary" wire:click="editRepository({{ $item->id }})">Edit</flux:button>
<flux:button size="sm" variant="danger" wire:click="deleteRepository({{ $item->id }})" wire:confirm="Delete this repository?">Delete</flux:button>
</td>
</tr>
@@ -1 +1 @@
<div class="overflow-x-auto"><table class="min-w-full divide-y divide-zinc-200 text-sm dark:divide-zinc-700"><thead class="bg-zinc-50 text-left text-xs font-semibold uppercase tracking-wide text-zinc-500 dark:bg-zinc-800 dark:text-zinc-300"><tr><th class="px-4 py-3">Team</th><th class="px-4 py-3">Slug</th><th class="px-4 py-3">Colour</th><th class="px-4 py-3">Projects</th><th class="px-4 py-3">Tickets</th><th class="px-4 py-3 text-right">Actions</th></tr></thead><tbody class="divide-y divide-zinc-100 dark:divide-zinc-800">@forelse ($items as $item)<tr><td class="px-4 py-3 font-medium text-zinc-900 dark:text-zinc-100">{{ $item->name }}</td><td class="px-4 py-3 font-mono text-xs text-zinc-500">{{ $item->slug }}</td><td class="px-4 py-3"><flux:badge color="{{ $item->color }}">{{ $item->color }}</flux:badge></td><td class="px-4 py-3 text-zinc-500">{{ $item->projects_count }}</td><td class="px-4 py-3 text-zinc-500">{{ $item->tickets_count }}</td><td class="px-4 py-3 text-right"><flux:button size="sm" wire:click="editTeam({{ $item->id }})" variant="ghost">Edit</flux:button><flux:button size="sm" wire:click="deleteTeam({{ $item->id }})" variant="danger">Delete</flux:button></td></tr>@empty<tr><td colspan="6" class="px-4 py-10 text-center text-zinc-500">No teams yet.</td></tr>@endforelse</tbody></table></div>
<div class="overflow-x-auto"><table class="min-w-full divide-y divide-zinc-200 text-sm dark:divide-zinc-700"><thead class="bg-zinc-50 text-left text-xs font-semibold uppercase tracking-wide text-zinc-500 dark:bg-zinc-800 dark:text-zinc-300"><tr><th class="px-4 py-3">Team</th><th class="px-4 py-3">Slug</th><th class="px-4 py-3">Colour</th><th class="px-4 py-3">Projects</th><th class="px-4 py-3">Tickets</th><th class="px-4 py-3 text-right">Actions</th></tr></thead><tbody class="divide-y divide-zinc-100 dark:divide-zinc-800">@forelse ($items as $item)<tr><td class="px-4 py-3 font-medium text-zinc-900 dark:text-zinc-100">{{ $item->name }}</td><td class="px-4 py-3 font-mono text-xs text-zinc-500">{{ $item->slug }}</td><td class="px-4 py-3"><flux:badge color="{{ $item->color }}">{{ $item->color }}</flux:badge></td><td class="px-4 py-3 text-zinc-500">{{ $item->projects_count }}</td><td class="px-4 py-3 text-zinc-500">{{ $item->tickets_count }}</td><td class="px-4 py-3 text-right"><flux:button size="sm" wire:click="editTeam({{ $item->id }})" variant="primary">Edit</flux:button><flux:button size="sm" wire:click="deleteTeam({{ $item->id }})" variant="danger">Delete</flux:button></td></tr>@empty<tr><td colspan="6" class="px-4 py-10 text-center text-zinc-500">No teams yet.</td></tr>@endforelse</tbody></table></div>
@@ -1,4 +1,4 @@
<div class="mx-auto max-w-[1800px] space-y-6" dusk="helpdesk-kanban-board">
<div class="mx-auto max-w-[1800px] space-y-6" dusk="helpdesk-kanban-board" data-helpdesk-kanban-root>
<div class="overflow-hidden rounded-3xl border border-zinc-200 bg-white shadow-sm dark:border-zinc-700 dark:bg-zinc-900">
<div class="bg-gradient-to-br from-slate-950 via-slate-900 to-blue-950 px-6 py-7 text-white">
<div class="flex flex-col gap-4 lg:flex-row lg:items-center lg:justify-between">
@@ -36,11 +36,11 @@
</select>
</div>
<div class="flex gap-4 overflow-x-auto pb-4" data-helpdesk-kanban-board>
<div class="flex gap-4 overflow-x-auto pb-4">
@foreach ($statuses as $status)
@php($tickets = $ticketsByStatus[$status->id] ?? collect())
<section class="flex min-h-[640px] w-[330px] shrink-0 flex-col overflow-hidden rounded-2xl border border-zinc-200 bg-zinc-100 shadow-sm dark:border-zinc-700 dark:bg-zinc-950" dusk="kanban-column-{{ $status->slug }}">
<section class="flex min-h-[640px] w-[330px] shrink-0 flex-col overflow-hidden rounded-2xl border border-zinc-200 bg-zinc-100 shadow-sm dark:border-zinc-700 dark:bg-zinc-950" dusk="kanban-column-{{ $status->slug }}" wire:key="kanban-column-{{ $status->id }}">
<header class="border-b border-zinc-200 bg-white px-4 py-4 dark:border-zinc-800 dark:bg-zinc-900">
<div class="flex items-start justify-between gap-3">
<div>
@@ -52,16 +52,18 @@
</header>
<div
class="helpdesk-kanban-column min-h-[560px] flex-1 space-y-3 p-3"
class="helpdesk-kanban-column min-h-[560px] flex-1 space-y-3 p-3 transition data-[drop-ready=true]:bg-blue-50 dark:data-[drop-ready=true]:bg-blue-950/30"
data-helpdesk-kanban-column
data-status-id="{{ $status->id }}"
>
@forelse ($tickets as $ticket)
<article
class="group cursor-grab rounded-2xl border border-zinc-200 bg-white p-4 shadow-sm transition hover:-translate-y-0.5 hover:shadow-md active:cursor-grabbing dark:border-zinc-800 dark:bg-zinc-900"
draggable="true"
data-helpdesk-kanban-ticket
data-ticket-id="{{ $ticket->id }}"
dusk="kanban-ticket-{{ $ticket->id }}"
wire:key="kanban-ticket-{{ $ticket->id }}"
>
<div class="flex items-start justify-between gap-3">
<div class="min-w-0">
@@ -106,55 +108,83 @@
@script
<script>
const initialiseHelpdeskKanban = function () {
const boot = function () {
if (!window.Sortable) {
const initialiseHelpdeskNativeKanban = function () {
document.querySelectorAll('[data-helpdesk-kanban-root]').forEach(function (root) {
if (root.dataset.nativeKanbanReady === '1') {
return;
}
document.querySelectorAll('[data-helpdesk-kanban-column]').forEach(function (column) {
if (column.dataset.sortableReady === '1') {
root.dataset.nativeKanbanReady = '1';
root.addEventListener('dragstart', function (event) {
const card = event.target.closest('[data-helpdesk-kanban-ticket]');
if (!card || event.target.closest('a, button, input, select, textarea')) {
return;
}
column.dataset.sortableReady = '1';
event.dataTransfer.effectAllowed = 'move';
event.dataTransfer.setData('text/plain', card.dataset.ticketId);
event.dataTransfer.setData('application/x-helpdesk-ticket', card.dataset.ticketId);
card.classList.add('opacity-50', 'ring-2', 'ring-blue-400');
});
new window.Sortable(column, {
group: 'helpdesk-kanban',
animation: 180,
ghostClass: 'opacity-50',
chosenClass: 'ring-2 ring-blue-400',
dragClass: 'rotate-1',
draggable: '[data-helpdesk-kanban-ticket]',
filter: 'a, button, input, select, textarea',
preventOnFilter: false,
onEnd: function (event) {
const ticketId = event.item.dataset.ticketId;
const statusId = event.to.dataset.statusId;
root.addEventListener('dragend', function (event) {
const card = event.target.closest('[data-helpdesk-kanban-ticket]');
if (!ticketId || !statusId) {
return;
}
if (card) {
card.classList.remove('opacity-50', 'ring-2', 'ring-blue-400');
}
$wire.moveTicket(ticketId, statusId);
},
root.querySelectorAll('[data-helpdesk-kanban-column]').forEach(function (column) {
column.dataset.dropReady = 'false';
});
});
};
if (!window.Sortable) {
const script = document.createElement('script');
script.src = 'https://cdn.jsdelivr.net/npm/sortablejs@1.15.2/Sortable.min.js';
script.onload = boot;
document.head.appendChild(script);
return;
}
root.addEventListener('dragover', function (event) {
const column = event.target.closest('[data-helpdesk-kanban-column]');
boot();
if (!column) {
return;
}
event.preventDefault();
event.dataTransfer.dropEffect = 'move';
column.dataset.dropReady = 'true';
});
root.addEventListener('dragleave', function (event) {
const column = event.target.closest('[data-helpdesk-kanban-column]');
if (column && !column.contains(event.relatedTarget)) {
column.dataset.dropReady = 'false';
}
});
root.addEventListener('drop', function (event) {
const column = event.target.closest('[data-helpdesk-kanban-column]');
if (!column) {
return;
}
event.preventDefault();
column.dataset.dropReady = 'false';
const ticketId = event.dataTransfer.getData('application/x-helpdesk-ticket') || event.dataTransfer.getData('text/plain');
const statusId = column.dataset.statusId;
if (!ticketId || !statusId) {
return;
}
$wire.moveTicket(ticketId, statusId);
});
});
};
initialiseHelpdeskKanban();
document.addEventListener('livewire:navigated', initialiseHelpdeskKanban);
initialiseHelpdeskNativeKanban();
document.addEventListener('livewire:navigated', initialiseHelpdeskNativeKanban);
</script>
@endscript
</div>
@@ -20,17 +20,18 @@
<flux:callout variant="success" icon="check-circle">{{ session('success') }}</flux:callout>
@endif
<div class="grid gap-3 md:grid-cols-7">
<div class="grid gap-3 md:grid-cols-8">
@foreach ([
'statuses' => ['label' => 'Statuses', 'count' => $statuses->count()],
'priorities' => ['label' => 'Priorities', 'count' => $priorities->count()],
'categories' => ['label' => 'Categories', 'count' => $categories->count()],
'teams' => ['label' => 'Teams', 'count' => $teams->count()],
'projects' => ['label' => 'Projects', 'count' => $projects->count()],
'boards' => ['label' => 'Boards', 'count' => $boards->count()],
'git' => ['label' => 'Git', 'count' => $repositories->count()],
'workflow' => ['label' => 'Workflow', 'count' => $workflowTemplates->count()],
] as $key => $item)
<button type="button" wire:click="$set('section', '{{ $key }}')" class="rounded-2xl border px-4 py-3 text-left shadow-sm transition {{ $section === $key ? 'border-blue-500 bg-blue-50 text-blue-900 dark:border-blue-400 dark:bg-blue-950 dark:text-blue-100' : 'border-zinc-200 bg-white text-zinc-700 hover:bg-zinc-50 dark:border-zinc-700 dark:bg-zinc-900 dark:text-zinc-200 dark:hover:bg-zinc-800' }}">
<button type="button" wire:click="$set('section', '{{ $key }}')" class="rounded-2xl border px-4 py-3 text-left shadow-sm transition {{ $section === $key ? ($key === 'statuses' ? 'border-emerald-500 bg-gradient-to-br from-emerald-50 to-blue-50 text-emerald-950 dark:border-emerald-400 dark:from-emerald-950 dark:to-blue-950 dark:text-emerald-100' : 'border-blue-500 bg-blue-50 text-blue-900 dark:border-blue-400 dark:bg-blue-950 dark:text-blue-100') : 'border-zinc-200 bg-white text-zinc-700 hover:bg-zinc-50 dark:border-zinc-700 dark:bg-zinc-900 dark:text-zinc-200 dark:hover:bg-zinc-800' }}">
<div class="text-xs font-semibold uppercase tracking-wide opacity-70">{{ $item['label'] }}</div>
<div class="mt-1 text-2xl font-semibold">{{ $item['count'] }}</div>
</button>
@@ -117,6 +118,78 @@
</x-helpdesk::settings-section>
@endif
@if ($section === 'boards')
<x-helpdesk::settings-section title="Kanban Boards" description="Create configurable workflow boards and choose which statuses appear as draggable columns.">
<x-slot:form>
<form wire:submit="saveBoard" class="grid gap-4 md:grid-cols-6">
<flux:input wire:model="boardForm.name" label="Name" />
<flux:input wire:model="boardForm.slug" label="Slug" placeholder="auto-generated" />
<flux:input wire:model="boardForm.sort_order" label="Sort" type="number" min="0" />
<label class="flex items-end gap-2 pb-2 text-sm text-zinc-700 dark:text-zinc-200">
<input type="checkbox" wire:model="boardForm.is_default" class="rounded border-zinc-300"> Default board
</label>
<div class="md:col-span-6">
<flux:textarea wire:model="boardForm.description" label="Description" rows="3" />
</div>
<div class="md:col-span-6">
<label class="mb-2 block text-sm font-semibold text-zinc-700 dark:text-zinc-200">Board columns <span class="text-red-600">*</span></label>
<div class="grid gap-2 rounded-2xl border border-zinc-200 bg-zinc-50 p-3 dark:border-zinc-700 dark:bg-zinc-950 md:grid-cols-3">
@foreach ($statuses as $status)
<label class="flex items-center gap-2 rounded-xl border border-zinc-200 bg-white px-3 py-2 text-sm text-zinc-700 shadow-sm dark:border-zinc-700 dark:bg-zinc-900 dark:text-zinc-200">
<input type="checkbox" wire:model="boardForm.status_ids" value="{{ $status->id }}" class="rounded border-zinc-300">
<span class="inline-flex h-3 w-3 rounded-full" style="background-color: {{ \Modules\Helpdesk\Support\Color::css($status->color) }}"></span>
{{ $status->name }}
</label>
@endforeach
</div>
@error('boardForm.status_ids') <p class="mt-2 text-sm text-red-600">{{ $message }}</p> @enderror
</div>
<div class="md:col-span-6 flex gap-2">
<flux:button type="submit" variant="primary">Save board</flux:button>
<flux:button type="button" wire:click="resetBoardForm" variant="ghost">Reset</flux:button>
</div>
</form>
</x-slot:form>
<div class="overflow-hidden rounded-2xl border border-zinc-200 bg-white dark:border-zinc-700 dark:bg-zinc-900">
<table class="min-w-full divide-y divide-zinc-200 text-sm dark:divide-zinc-700">
<thead class="bg-zinc-50 text-left text-xs font-semibold uppercase tracking-wide text-zinc-500 dark:bg-zinc-800 dark:text-zinc-300">
<tr>
<th class="px-4 py-3">Board</th>
<th class="px-4 py-3">Slug</th>
<th class="px-4 py-3">Columns</th>
<th class="px-4 py-3">Default</th>
<th class="px-4 py-3 text-right">Actions</th>
</tr>
</thead>
<tbody class="divide-y divide-zinc-100 dark:divide-zinc-800">
@forelse ($boards as $boardItem)
<tr>
<td class="px-4 py-3 font-medium text-zinc-900 dark:text-zinc-100">{{ $boardItem->name }}</td>
<td class="px-4 py-3 font-mono text-xs text-zinc-500">{{ $boardItem->slug }}</td>
<td class="px-4 py-3 text-zinc-600 dark:text-zinc-300">
<div class="flex flex-wrap gap-1">
@foreach ($boardItem->statuses as $status)
<flux:badge color="{{ $status->color }}">{{ $status->name }}</flux:badge>
@endforeach
</div>
</td>
<td class="px-4 py-3"><flux:badge color="{{ $boardItem->is_default ? 'emerald' : 'zinc' }}">{{ $boardItem->is_default ? 'Default' : 'No' }}</flux:badge></td>
<td class="px-4 py-3 text-right">
<flux:button size="sm" variant="primary" wire:click="editBoard({{ $boardItem->id }})">Edit</flux:button>
<flux:button size="sm" variant="danger" wire:click="deleteBoard({{ $boardItem->id }})" wire:confirm="Delete this Kanban board?">Delete</flux:button>
</td>
</tr>
@empty
<tr><td colspan="5" class="px-4 py-8 text-center text-zinc-500">No Kanban boards yet.</td></tr>
@endforelse
</tbody>
</table>
</div>
</x-helpdesk::settings-section>
@endif
@if ($section === 'git')
<x-helpdesk::settings-section title="Git repositories" description="Configure repositories that can be linked to projects and tickets. Commits can then be stored against tickets for traceability.">
<x-slot:form>
@@ -206,7 +279,7 @@
<td class="px-4 py-3 text-zinc-600 dark:text-zinc-300">{{ $template->to_role }}</td>
<td class="px-4 py-3"><flux:badge color="{{ $template->is_active ? 'emerald' : 'zinc' }}">{{ $template->is_active ? 'Active' : 'Inactive' }}</flux:badge></td>
<td class="px-4 py-3 text-right">
<flux:button size="sm" variant="ghost" wire:click="editWorkflowTemplate({{ $template->id }})">Edit</flux:button>
<flux:button size="sm" variant="primary" wire:click="editWorkflowTemplate({{ $template->id }})">Edit</flux:button>
<flux:button size="sm" variant="danger" wire:click="deleteWorkflowTemplate({{ $template->id }})" wire:confirm="Delete this workflow message?">Delete</flux:button>
</td>
</tr>
@@ -0,0 +1,126 @@
<div class="space-y-6" dusk="helpdesk-ticket-edit">
@include('helpdesk::partials.page-header', [
'eyebrow' => 'Helpdesk',
'title' => 'Edit Ticket',
'subtitle' => 'Update assignment, status, priority, category, team, project, due date and ticket details.',
])
<form wire:submit.prevent="save" class="space-y-6">
<div class="overflow-hidden rounded-2xl border border-zinc-200 bg-white shadow-sm dark:border-zinc-700 dark:bg-zinc-900">
<div class="border-b border-zinc-200 bg-zinc-50 px-6 py-4 dark:border-zinc-700 dark:bg-zinc-900/80">
<div class="flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between">
<div>
<h2 class="text-lg font-semibold text-zinc-900 dark:text-zinc-100">{{ $ticket->reference }}</h2>
<p class="mt-1 text-sm text-zinc-500 dark:text-zinc-400">Fields marked <span class="font-semibold text-red-600">*</span> are mandatory.</p>
</div>
<div class="flex flex-wrap gap-2">
<a href="{{ route('helpdesk.tickets.show', $ticket) }}" wire:navigate class="inline-flex items-center rounded-xl bg-blue-600 px-4 py-2 text-sm font-semibold text-white shadow-sm hover:bg-blue-700">
<i class="fa-solid fa-arrow-left mr-2" aria-hidden="true"></i> Back
</a>
</div>
</div>
</div>
<div class="grid gap-6 p-6 lg:grid-cols-2">
<div class="lg:col-span-2">
<label class="block text-sm font-semibold text-zinc-700 dark:text-zinc-200" for="subject">Subject <span class="text-red-600">*</span></label>
<input id="subject" type="text" wire:model.defer="subject" class="mt-2 block w-full rounded-xl border-zinc-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-100" data-dusk="ticket-edit-subject">
@error('subject') <p class="mt-2 text-sm text-red-600">{{ $message }}</p> @enderror
</div>
@if($companies->isNotEmpty())
<div>
<label class="block text-sm font-semibold text-zinc-700 dark:text-zinc-200" for="company_id">Company</label>
<select id="company_id" wire:model.defer="company_id" data-helpdesk-select class="mt-2 block w-full rounded-xl border-zinc-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-100">
<option value="">Global / no company</option>
@foreach ($companies as $company)
<option value="{{ $company->id }}">{{ $company->name }}</option>
@endforeach
</select>
@error('company_id') <p class="mt-2 text-sm text-red-600">{{ $message }}</p> @enderror
</div>
@endif
<div>
<label class="block text-sm font-semibold text-zinc-700 dark:text-zinc-200" for="agent_id">Assigned agent</label>
<select id="agent_id" wire:model.defer="agent_id" data-helpdesk-select class="mt-2 block w-full rounded-xl border-zinc-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-100" data-dusk="ticket-edit-agent">
<option value="">Unassigned</option>
@foreach ($agents as $agent)
<option value="{{ $agent->id }}">{{ $agent->name }} — {{ $agent->email }}</option>
@endforeach
</select>
@error('agent_id') <p class="mt-2 text-sm text-red-600">{{ $message }}</p> @enderror
</div>
<div>
<label class="block text-sm font-semibold text-zinc-700 dark:text-zinc-200" for="status_id">Status <span class="text-red-600">*</span></label>
<select id="status_id" wire:model.defer="status_id" data-helpdesk-select class="mt-2 block w-full rounded-xl border-zinc-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-100" data-dusk="ticket-edit-status">
@foreach ($statuses as $status)
<option value="{{ $status->id }}">{{ $status->name }}</option>
@endforeach
</select>
@error('status_id') <p class="mt-2 text-sm text-red-600">{{ $message }}</p> @enderror
</div>
<div>
<label class="block text-sm font-semibold text-zinc-700 dark:text-zinc-200" for="priority_id">Priority <span class="text-red-600">*</span></label>
<select id="priority_id" wire:model.defer="priority_id" data-helpdesk-select class="mt-2 block w-full rounded-xl border-zinc-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-100" data-dusk="ticket-edit-priority">
@foreach ($priorities as $priority)
<option value="{{ $priority->id }}">{{ $priority->name }}</option>
@endforeach
</select>
@error('priority_id') <p class="mt-2 text-sm text-red-600">{{ $message }}</p> @enderror
</div>
<div>
<label class="block text-sm font-semibold text-zinc-700 dark:text-zinc-200" for="category_id">Category</label>
<select id="category_id" wire:model.defer="category_id" data-helpdesk-select class="mt-2 block w-full rounded-xl border-zinc-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-100">
<option value="">No category</option>
@foreach ($categories as $category)
<option value="{{ $category->id }}">{{ $category->name }}</option>
@endforeach
</select>
@error('category_id') <p class="mt-2 text-sm text-red-600">{{ $message }}</p> @enderror
</div>
<div>
<label class="block text-sm font-semibold text-zinc-700 dark:text-zinc-200" for="project_id">Project</label>
<select id="project_id" wire:model.defer="project_id" data-helpdesk-select class="mt-2 block w-full rounded-xl border-zinc-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-100">
<option value="">No project</option>
@foreach ($projects as $project)
<option value="{{ $project->id }}">{{ $project->title }}</option>
@endforeach
</select>
@error('project_id') <p class="mt-2 text-sm text-red-600">{{ $message }}</p> @enderror
</div>
<div>
<label class="block text-sm font-semibold text-zinc-700 dark:text-zinc-200" for="team_id">Team</label>
<select id="team_id" wire:model.defer="team_id" data-helpdesk-select class="mt-2 block w-full rounded-xl border-zinc-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-100">
<option value="">No team</option>
@foreach ($teams as $team)
<option value="{{ $team->id }}">{{ $team->name }}</option>
@endforeach
</select>
@error('team_id') <p class="mt-2 text-sm text-red-600">{{ $message }}</p> @enderror
</div>
<div>
<label class="block text-sm font-semibold text-zinc-700 dark:text-zinc-200" for="due_at">Due date</label>
<input id="due_at" type="date" wire:model.defer="due_at" class="mt-2 block w-full rounded-xl border-zinc-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-100">
@error('due_at') <p class="mt-2 text-sm text-red-600">{{ $message }}</p> @enderror
</div>
<div class="lg:col-span-2">
<x-helpdesk::html-editor dusk="ticket-edit-body-editor" wire:model="body" label="Details *" rows="12" placeholder="Update the ticket details, current issue, expected outcome and useful context..." />
</div>
</div>
<div class="flex flex-wrap items-center justify-end gap-3 border-t border-zinc-200 px-6 py-4 dark:border-zinc-700">
<a href="{{ route('helpdesk.tickets.show', $ticket) }}" wire:navigate class="rounded-xl border border-zinc-300 px-4 py-2 text-sm font-semibold text-zinc-700 hover:bg-zinc-50 dark:border-zinc-700 dark:text-zinc-200 dark:hover:bg-zinc-800">Cancel</a>
<button type="submit" class="rounded-xl bg-emerald-600 px-5 py-2 text-sm font-semibold text-white shadow-sm hover:bg-emerald-700" data-dusk="ticket-edit-submit">Save Ticket</button>
</div>
</div>
</form>
@include('helpdesk::partials.select2-loader')
</div>
@@ -74,7 +74,7 @@
</div>
<div class="mt-5 flex justify-end">
<flux:button dusk="post-comment" type="submit" variant="primary" icon="chat-bubble-left-right" wire:loading.attr="disabled">
<flux:button dusk="post-comment" type="submit" variant="primary" icon="chat-bubble-left-right" class="!bg-emerald-600 !text-white hover:!bg-emerald-700" wire:loading.attr="disabled">
<span wire:loading.remove>Post reply</span>
<span wire:loading>Posting...</span>
</flux:button>
@@ -44,11 +44,11 @@
@if (($reply_parent_id ?? null) === $comment->id)
<form wire:submit="addReply" class="mt-4 rounded-xl border border-blue-200 bg-blue-50 p-4 dark:border-blue-900 dark:bg-blue-950/40">
<x-helpdesk::html-editor wire:model="replyBody" label="Reply" rows="4" placeholder="Write a reply..." />
<x-helpdesk::html-editor wire:key="reply-editor-{{ $comment->id }}" wire:model="replyBody" label="Reply" rows="4" placeholder="Write a reply..." />
<div class="mt-4 flex justify-end gap-2">
<flux:button type="button" wire:click="cancelReply" variant="ghost">Cancel</flux:button>
<flux:button type="submit" variant="primary">Post reply</flux:button>
<flux:button type="submit" variant="primary" class="!bg-emerald-600 !text-white hover:!bg-emerald-700">Post reply</flux:button>
</div>
</form>
@endif
@@ -0,0 +1,30 @@
@script
<script>
const initialiseHelpdeskSelect2 = function () {
if (!window.jQuery || !window.jQuery.fn || !window.jQuery.fn.select2) {
return;
}
window.jQuery('[data-helpdesk-select2], [data-helpdesk-select]').each(function () {
const element = window.jQuery(this);
if (element.data('select2')) {
return;
}
element.select2({
width: '100%',
theme: 'default'
});
element.on('change', function () {
this.dispatchEvent(new Event('input', { bubbles: true }));
this.dispatchEvent(new Event('change', { bubbles: true }));
});
});
};
initialiseHelpdeskSelect2();
document.addEventListener('livewire:navigated', initialiseHelpdeskSelect2);
</script>
@endscript
+11
View File
@@ -53,3 +53,14 @@ versions:
- Improved Helpdesk settings styling, blue edit actions, and a dedicated Kanban Boards CRUD section.
- Marked mandatory ticket fields and enhanced create/edit ticket forms with Select2-capable dropdowns.
- Kept module.json version in sync with changelog.yaml.
"1.1.2":
changed:
- Restored ticket editing with a full Livewire edit view for assignment, status, priority, category, project, team, due date and details.
- Replaced the Kanban board drag behaviour with dependency-free native HTML5 drag and drop so cards move without external SortableJS.
- Added Kanban board CRUD to Helpdesk settings with status-column selection and default board support.
- Made Helpdesk settings edit actions blue and improved the statuses selector card styling.
- Added reusable Select2 progressive enhancement for Helpdesk dropdowns while preserving native Livewire behaviour when Select2 is unavailable.
- Made ticket reply buttons green and reset reply editors after posting.
- Rebuilt ticket comment loading as an unlimited nested tree with eager-loaded users and attachments.
- Kept module.json version in sync with changelog.yaml.
+1 -1
View File
@@ -13,5 +13,5 @@
"Modules\\Helpdesk\\Providers\\HelpdeskServiceProvider"
],
"files": [],
"version": "1.0.9"
"version": "1.1.2"
}