improvements

This commit is contained in:
Mark Gregory
2026-08-26 09:04:25 +01:00
parent 5844aeb621
commit 53a11ae0c7
13 changed files with 479 additions and 36 deletions
@@ -138,7 +138,7 @@
<div class="flex items-center gap-2"><i class="fa-solid fa-user w-3"
aria-hidden="true"></i> {{ $ticket->owner?->name ?? 'Unknown' }}</div>
<div class="flex items-center gap-2"><i class="fa-solid fa-user-gear w-3"
aria-hidden="true"></i> {{ $ticket->agent?->name ?? 'Unassigned' }}
aria-hidden="true"></i> {{ $ticket->agent_name ?? 'Unassigned' }}
</div>
@if ($ticket->project)
<div class="flex items-center gap-2"><i
@@ -15,6 +15,19 @@
<label><input type="checkbox" name="helpdesk_admin" value="1" @checked(old('helpdesk_admin', $user->helpdesk_admin ?? false))> <span><strong>Administrator</strong><small>Full Helpdesk, settings and user administration.</small></span></label>
</div>
<div>
<h2 class="mb-3 text-lg font-semibold">Custom roles</h2>
<div class="hd-role-options">
@foreach($roles as $roleOption)
<label>
<input type="checkbox" name="roles[]" value="{{ $roleOption->id }}"
@checked(in_array($roleOption->id, old('roles', isset($user) ? $user->roles->pluck('id')->all() : [])))>
<span><strong>{{ $roleOption->name }}</strong><small>{{ $roleOption->description ?: $roleOption->slug }}</small></span>
</label>
@endforeach
</div>
</div>
<div class="flex justify-end"><button class="hd-action hd-action-green" type="submit"><i class="fa-solid fa-floppy-disk"></i> Create user</button></div></form>
</div>
</x-layouts::app>
@@ -16,6 +16,19 @@
<label><input type="checkbox" name="helpdesk_admin" value="1" @checked(old('helpdesk_admin', $user->helpdesk_admin ?? false))> <span><strong>Administrator</strong><small>Full Helpdesk, settings and user administration.</small></span></label>
</div>
<div>
<h2 class="mb-3 text-lg font-semibold">Custom roles</h2>
<div class="hd-role-options">
@foreach($roles as $roleOption)
<label>
<input type="checkbox" name="roles[]" value="{{ $roleOption->id }}"
@checked(in_array($roleOption->id, old('roles', isset($user) ? $user->roles->pluck('id')->all() : [])))>
<span><strong>{{ $roleOption->name }}</strong><small>{{ $roleOption->description ?: $roleOption->slug }}</small></span>
</label>
@endforeach
</div>
</div>
<div class="flex flex-wrap justify-between gap-3"><div></div><button class="hd-action hd-action-blue" type="submit"><i class="fa-solid fa-floppy-disk"></i> Save changes</button></div></form>
@if(auth()->id() !== $user->id)<form method="POST" action="{{ route('user-management.destroy', $user) }}" onsubmit="return confirm('Delete this user?')">@csrf @method('DELETE')<button class="hd-action hd-action-red" type="submit">Delete user</button></form>@endif
</div>
@@ -0,0 +1,15 @@
<x-layouts::app :title="$permission->exists ? __('Edit Permission') : __('Create Permission')">
<div class="hd-page-shell space-y-5">
<section class="hd-page-hero"><div><div class="hd-eyebrow">Administration</div><h1>{{ $permission->exists ? 'Edit permission' : 'Create permission' }}</h1><p>Define a reusable permission for application roles.</p></div><a class="hd-action" href="{{ route('user-management.roles') }}">Back</a></section>
@if($errors->any())<div class="hd-alert hd-alert-danger"><ul>@foreach($errors->all() as $error)<li>{{ $error }}</li>@endforeach</ul></div>@endif
<form method="POST" action="{{ $permission->exists ? route('user-management.permissions.update', $permission) : route('user-management.permissions.store') }}" class="hd-panel p-6 space-y-6">
@csrf @if($permission->exists) @method('PUT') @endif
<div class="hd-form-grid">
<label class="hd-field"><span>Name</span><input name="name" value="{{ old('name', $permission->name) }}" required></label>
<label class="hd-field"><span>Slug</span><input name="slug" value="{{ old('slug', $permission->slug) }}" placeholder="e.g. helpdesk.manage"></label>
</div>
<label class="hd-field"><span>Description</span><textarea name="description">{{ old('description', $permission->description) }}</textarea></label>
<div class="flex justify-end"><button class="hd-action hd-action-green" type="submit">Save permission</button></div>
</form>
</div>
</x-layouts::app>
@@ -0,0 +1,20 @@
<x-layouts::app :title="$role->exists ? __('Edit Role') : __('Create Role')">
<div class="hd-page-shell space-y-5">
<section class="hd-page-hero"><div><div class="hd-eyebrow">Administration</div><h1>{{ $role->exists ? 'Edit role' : 'Create role' }}</h1><p>Define the role and the permissions it grants.</p></div><a class="hd-action" href="{{ route('user-management.roles') }}">Back</a></section>
@if($errors->any())<div class="hd-alert hd-alert-danger"><ul>@foreach($errors->all() as $error)<li>{{ $error }}</li>@endforeach</ul></div>@endif
<form method="POST" action="{{ $role->exists ? route('user-management.roles.update', $role) : route('user-management.roles.store') }}" class="hd-panel p-6 space-y-6">
@csrf @if($role->exists) @method('PUT') @endif
<div class="hd-form-grid">
<label class="hd-field"><span>Name</span><input name="name" value="{{ old('name', $role->name) }}" required></label>
<label class="hd-field"><span>Slug</span><input name="slug" value="{{ old('slug', $role->slug) }}" placeholder="auto-generated"></label>
</div>
<label class="hd-field"><span>Description</span><textarea name="description">{{ old('description', $role->description) }}</textarea></label>
<div><h2 class="mb-3 text-lg font-semibold">Permissions</h2><div class="hd-role-options">
@foreach($permissions as $permission)
<label><input type="checkbox" name="permissions[]" value="{{ $permission->id }}" @checked(in_array($permission->id, old('permissions', $role->exists ? $role->permissions->pluck('id')->all() : [])))><span><strong>{{ $permission->name }}</strong><small>{{ $permission->slug }}</small></span></label>
@endforeach
</div></div>
<div class="flex justify-end"><button class="hd-action hd-action-blue" type="submit">Save role</button></div>
</form>
</div>
</x-layouts::app>
@@ -1,10 +1,69 @@
<x-layouts::app :title="__('Roles & Permissions')">
<div class="hd-page-shell space-y-5">
<section class="hd-page-hero"><div><div class="hd-eyebrow">Administration</div><h1>Roles & permissions</h1><p>Helpdesk uses three clear access levels.</p></div></section>
<div class="grid gap-4 lg:grid-cols-3">
<article class="hd-role-card hd-role-card-admin"><i class="fa-solid fa-shield-halved"></i><h2>Administrator</h2><strong>{{ $counts['admins'] }}</strong><p>Full tickets, settings, documentation and user management access.</p></article>
<article class="hd-role-card hd-role-card-agent"><i class="fa-solid fa-headset"></i><h2>Agent</h2><strong>{{ $counts['agents'] }}</strong><p>Can work tickets, Kanban workflow and support operations.</p></article>
<article class="hd-role-card"><i class="fa-solid fa-user"></i><h2>User</h2><strong>{{ $counts['users'] }}</strong><p>Standard authenticated requester access.</p></article>
</div>
<section class="hd-page-hero">
<div>
<div class="hd-eyebrow">Administration</div>
<h1>Roles & permissions</h1>
<p>Create roles, define permissions and assign permissions to roles.</p>
</div>
<div class="flex flex-wrap gap-2">
<a class="hd-action hd-action-blue" href="{{ route('user-management.roles.create') }}"><i class="fa-solid fa-plus"></i> New role</a>
<a class="hd-action hd-action-green" href="{{ route('user-management.permissions.create') }}"><i class="fa-solid fa-key"></i> New permission</a>
</div>
</section>
@if(session('status'))<div class="hd-alert hd-alert-success">{{ session('status') }}</div>@endif
@if($errors->any())<div class="hd-alert hd-alert-danger"><ul>@foreach($errors->all() as $error)<li>{{ $error }}</li>@endforeach</ul></div>@endif
<section class="hd-panel overflow-x-auto">
<div class="p-5 border-b border-zinc-700"><h2 class="text-xl font-semibold">Roles</h2></div>
<table class="w-full min-w-[760px]">
<thead><tr><th>Name</th><th>Slug</th><th>Users</th><th>Permissions</th><th class="text-right">Actions</th></tr></thead>
<tbody>
@forelse($roles as $role)
<tr>
<td><strong>{{ $role->name }}</strong>@if($role->is_system) <span class="hd-badge">System</span>@endif</td>
<td><code>{{ $role->slug }}</code></td>
<td>{{ $role->users_count }}</td>
<td>{{ $role->permissions_count }}</td>
<td><div class="flex justify-end gap-2">
<a class="hd-action hd-action-blue" href="{{ route('user-management.roles.edit', $role) }}">Edit</a>
@unless($role->is_system)
<form method="POST" action="{{ route('user-management.roles.destroy', $role) }}" onsubmit="return confirm('Delete this role?')">@csrf @method('DELETE')
<button class="hd-action hd-action-red" type="submit">Delete</button>
</form>
@endunless
</div></td>
</tr>
@empty
<tr><td colspan="5" class="p-5">No roles created.</td></tr>
@endforelse
</tbody>
</table>
</section>
<section class="hd-panel overflow-x-auto">
<div class="p-5 border-b border-zinc-700"><h2 class="text-xl font-semibold">Permissions</h2></div>
<table class="w-full min-w-[760px]">
<thead><tr><th>Name</th><th>Slug</th><th>Roles</th><th class="text-right">Actions</th></tr></thead>
<tbody>
@forelse($permissions as $permission)
<tr>
<td><strong>{{ $permission->name }}</strong></td>
<td><code>{{ $permission->slug }}</code></td>
<td>{{ $permission->roles_count }}</td>
<td><div class="flex justify-end gap-2">
<a class="hd-action hd-action-blue" href="{{ route('user-management.permissions.edit', $permission) }}">Edit</a>
<form method="POST" action="{{ route('user-management.permissions.destroy', $permission) }}" onsubmit="return confirm('Delete this permission?')">@csrf @method('DELETE')
<button class="hd-action hd-action-red" type="submit">Delete</button>
</form>
</div></td>
</tr>
@empty
<tr><td colspan="4" class="p-5">No permissions created.</td></tr>
@endforelse
</tbody>
</table>
</section>
</div>
</x-layouts::app>