Initial commit: CABM-IT (ItGlue-style MSP documentation platform)
Laravel 13 + Livewire/Volt app for managing client organizations, documents, passwords, flexible assets, virtual machines, contacts, domains, todos, shortcuts, and role-based user administration.
This commit is contained in:
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Organization;
|
||||
use App\Models\Shortcut;
|
||||
use Livewire\Component;
|
||||
|
||||
new class extends Component
|
||||
{
|
||||
public Organization $organization;
|
||||
|
||||
public function delete(int $shortcutId): void
|
||||
{
|
||||
$shortcut = Shortcut::findOrFail($shortcutId);
|
||||
|
||||
abort_unless($shortcut->organization_id === $this->organization->id || $shortcut->isGlobal(), 404);
|
||||
|
||||
if ($shortcut->isGlobal()) {
|
||||
abort_unless(auth()->user()->hasRole('Administrateur'), 403);
|
||||
}
|
||||
|
||||
$shortcut->delete();
|
||||
|
||||
session()->flash('status', "Raccourci « {$shortcut->label} » supprimé.");
|
||||
}
|
||||
|
||||
public function with(): array
|
||||
{
|
||||
return [
|
||||
'globalShortcuts' => Shortcut::whereNull('organization_id')->orderBy('label')->get(),
|
||||
'orgShortcuts' => $this->organization->shortcuts()->orderBy('label')->get(),
|
||||
];
|
||||
}
|
||||
};
|
||||
?>
|
||||
|
||||
<div>
|
||||
<div class="mb-6 flex items-center justify-between">
|
||||
<div>
|
||||
<p class="text-sm text-slate-500">{{ $organization->name }}</p>
|
||||
<h1 class="text-2xl font-semibold text-slate-900">Raccourcis</h1>
|
||||
</div>
|
||||
<div class="flex gap-2">
|
||||
@role('Administrateur')
|
||||
<a href="{{ route('organizations.shortcuts.create', [$organization, 'global' => true]) }}"
|
||||
class="rounded border border-slate-300 px-4 py-2 text-sm font-medium text-slate-700 hover:bg-slate-50">
|
||||
+ Raccourci global
|
||||
</a>
|
||||
@endrole
|
||||
<a href="{{ route('organizations.shortcuts.create', $organization) }}"
|
||||
class="rounded bg-slate-900 px-4 py-2 text-sm font-medium text-white hover:bg-slate-700">
|
||||
+ Raccourci de l'organisation
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 gap-6 lg:grid-cols-2">
|
||||
<div>
|
||||
<h2 class="mb-3 text-sm font-semibold uppercase tracking-wide text-slate-500">Globaux (toutes organisations)</h2>
|
||||
<div class="overflow-hidden rounded border border-slate-200 bg-white">
|
||||
<ul class="divide-y divide-slate-100">
|
||||
@forelse ($globalShortcuts as $shortcut)
|
||||
<li class="flex items-center justify-between gap-3 px-4 py-3 text-sm">
|
||||
<a href="{{ $shortcut->url }}" target="_blank" rel="noopener" class="flex min-w-0 items-center gap-2 text-slate-900 hover:underline">
|
||||
<span>{{ $shortcut->icon ?: '🔗' }}</span>
|
||||
<span class="truncate">{{ $shortcut->label }}</span>
|
||||
</a>
|
||||
@role('Administrateur')
|
||||
<div class="flex shrink-0 items-center gap-3 text-xs">
|
||||
<a href="{{ route('organizations.shortcuts.edit', [$organization, $shortcut]) }}" class="text-slate-500 hover:text-slate-900">Modifier</a>
|
||||
<button type="button" wire:click="delete({{ $shortcut->id }})"
|
||||
wire:confirm="Supprimer ce raccourci global ? Il disparaîtra pour toutes les organisations."
|
||||
class="text-red-500 hover:text-red-700">
|
||||
Supprimer
|
||||
</button>
|
||||
</div>
|
||||
@endrole
|
||||
</li>
|
||||
@empty
|
||||
<li class="px-4 py-6 text-center text-sm text-slate-400">Aucun raccourci global.</li>
|
||||
@endforelse
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h2 class="mb-3 text-sm font-semibold uppercase tracking-wide text-slate-500">Propres à {{ $organization->name }}</h2>
|
||||
<div class="overflow-hidden rounded border border-slate-200 bg-white">
|
||||
<ul class="divide-y divide-slate-100">
|
||||
@forelse ($orgShortcuts as $shortcut)
|
||||
<li class="flex items-center justify-between gap-3 px-4 py-3 text-sm">
|
||||
<a href="{{ $shortcut->url }}" target="_blank" rel="noopener" class="flex min-w-0 items-center gap-2 text-slate-900 hover:underline">
|
||||
<span>{{ $shortcut->icon ?: '🔗' }}</span>
|
||||
<span class="truncate">{{ $shortcut->label }}</span>
|
||||
</a>
|
||||
<div class="flex shrink-0 items-center gap-3 text-xs">
|
||||
<a href="{{ route('organizations.shortcuts.edit', [$organization, $shortcut]) }}" class="text-slate-500 hover:text-slate-900">Modifier</a>
|
||||
<button type="button" wire:click="delete({{ $shortcut->id }})"
|
||||
wire:confirm="Supprimer ce raccourci ?"
|
||||
class="text-red-500 hover:text-red-700">
|
||||
Supprimer
|
||||
</button>
|
||||
</div>
|
||||
</li>
|
||||
@empty
|
||||
<li class="px-4 py-6 text-center text-sm text-slate-400">Aucun raccourci pour cette organisation.</li>
|
||||
@endforelse
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user