Initial scaffold : Laravel 12 + PostgreSQL + auth + domaine métier (étapes 1-5)
- Laravel 12 sur PHP 8.5, Breeze (Blade/Tailwind/Alpine.js) - Docker Compose dev (PostgreSQL 18 + Redis) et prod (stack complète + nginx) - Migrations et models : lieux, sections, dépôts, source_types/fields, sources, relevés - Colonne JSONB data sur releves avec colonnes générées indexées (nom, prenom, date_evenement) - Index GIN pour la recherche fulltext - Enums : UserRole, SourceStatus (avec transitions), CalendarType, FieldType - RoleMiddleware (alias `role`) + helpers isAdmin/isSectionManager sur User - CRUD Lieux (arbre hiérarchique, calcul nom_long en cascade) - CRUD admin : Sections (+ gestion membres), Dépôts, Types de sources (+ champs dynamiques, drag & drop) - CRUD Sources : visibilité filtrée par rôle, assignation membres, workflow de statut Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
<div class="space-y-5">
|
||||
<div>
|
||||
<label for="nom" class="block text-sm font-medium text-gray-700">Nom <span class="text-red-500">*</span></label>
|
||||
<input type="text" id="nom" name="nom" value="{{ old('nom', $depot?->nom) }}" required
|
||||
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500">
|
||||
@error('nom') <p class="mt-1 text-sm text-red-600">{{ $message }}</p> @enderror
|
||||
</div>
|
||||
<div>
|
||||
<label for="description" class="block text-sm font-medium text-gray-700">Description</label>
|
||||
<textarea id="description" name="description" rows="3"
|
||||
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500">{{ old('description', $depot?->description) }}</textarea>
|
||||
</div>
|
||||
<div>
|
||||
<label for="adresse_postale" class="block text-sm font-medium text-gray-700">Adresse postale</label>
|
||||
<input type="text" id="adresse_postale" name="adresse_postale" value="{{ old('adresse_postale', $depot?->adresse_postale) }}"
|
||||
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500">
|
||||
</div>
|
||||
<div>
|
||||
<label for="url" class="block text-sm font-medium text-gray-700">Site internet</label>
|
||||
<input type="url" id="url" name="url" value="{{ old('url', $depot?->url) }}"
|
||||
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500">
|
||||
@error('url') <p class="mt-1 text-sm text-red-600">{{ $message }}</p> @enderror
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,15 @@
|
||||
<x-app-layout>
|
||||
<x-slot name="header"><h2 class="text-xl font-semibold text-gray-800">Nouveau dépôt</h2></x-slot>
|
||||
<div class="py-8 max-w-2xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<div class="bg-white shadow rounded-lg p-6">
|
||||
<form method="POST" action="{{ route('admin.depots.store') }}">
|
||||
@csrf
|
||||
@include('admin.depots._form', ['depot' => null])
|
||||
<div class="mt-6 flex gap-4">
|
||||
<button type="submit" class="px-5 py-2 bg-indigo-600 text-white rounded-md hover:bg-indigo-700">Créer</button>
|
||||
<a href="{{ route('admin.depots.index') }}" class="text-sm text-gray-500 self-center hover:text-gray-700">Annuler</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</x-app-layout>
|
||||
@@ -0,0 +1,15 @@
|
||||
<x-app-layout>
|
||||
<x-slot name="header"><h2 class="text-xl font-semibold text-gray-800">Modifier : {{ $depot->nom }}</h2></x-slot>
|
||||
<div class="py-8 max-w-2xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<div class="bg-white shadow rounded-lg p-6">
|
||||
<form method="POST" action="{{ route('admin.depots.update', $depot) }}">
|
||||
@csrf @method('PUT')
|
||||
@include('admin.depots._form', ['depot' => $depot])
|
||||
<div class="mt-6 flex gap-4">
|
||||
<button type="submit" class="px-5 py-2 bg-indigo-600 text-white rounded-md hover:bg-indigo-700">Enregistrer</button>
|
||||
<a href="{{ route('admin.depots.show', $depot) }}" class="text-sm text-gray-500 self-center hover:text-gray-700">Annuler</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</x-app-layout>
|
||||
@@ -0,0 +1,50 @@
|
||||
<x-app-layout>
|
||||
<x-slot name="header">
|
||||
<div class="flex items-center justify-between">
|
||||
<h2 class="text-xl font-semibold text-gray-800">Dépôts d'archives</h2>
|
||||
<a href="{{ route('admin.depots.create') }}" class="px-4 py-2 bg-indigo-600 text-white text-sm rounded-md hover:bg-indigo-700">+ Nouveau dépôt</a>
|
||||
</div>
|
||||
</x-slot>
|
||||
<div class="py-8 max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
@if(session('success')) <div class="mb-4 p-4 bg-green-50 border border-green-200 text-green-800 rounded-md">{{ session('success') }}</div> @endif
|
||||
@if(session('error')) <div class="mb-4 p-4 bg-red-50 border border-red-200 text-red-800 rounded-md">{{ session('error') }}</div> @endif
|
||||
<div class="bg-white shadow rounded-lg overflow-hidden">
|
||||
<table class="min-w-full divide-y divide-gray-200">
|
||||
<thead class="bg-gray-50">
|
||||
<tr>
|
||||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Nom</th>
|
||||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Sources</th>
|
||||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Site</th>
|
||||
<th class="px-6 py-3"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-gray-200">
|
||||
@forelse($depots as $depot)
|
||||
<tr class="hover:bg-gray-50">
|
||||
<td class="px-6 py-4 font-medium">
|
||||
<a href="{{ route('admin.depots.show', $depot) }}" class="text-indigo-600 hover:underline">{{ $depot->nom }}</a>
|
||||
</td>
|
||||
<td class="px-6 py-4 text-sm text-gray-500">{{ $depot->sources_count }}</td>
|
||||
<td class="px-6 py-4 text-sm text-gray-500">
|
||||
@if($depot->url) <a href="{{ $depot->url }}" target="_blank" class="text-indigo-600 hover:underline truncate max-w-xs block">{{ $depot->url }}</a>
|
||||
@else —
|
||||
@endif
|
||||
</td>
|
||||
<td class="px-6 py-4 text-right text-sm space-x-3">
|
||||
<a href="{{ route('admin.depots.edit', $depot) }}" class="text-gray-600 hover:text-indigo-600">Modifier</a>
|
||||
<form method="POST" action="{{ route('admin.depots.destroy', $depot) }}" class="inline"
|
||||
x-data @submit.prevent="if(confirm('Supprimer ce dépôt ?')) $el.submit()">
|
||||
@csrf @method('DELETE')
|
||||
<button type="submit" class="text-red-500 hover:text-red-700">Supprimer</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr><td colspan="4" class="px-6 py-10 text-center text-gray-400">Aucun dépôt.</td></tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
@if($depots->hasPages()) <div class="px-6 py-4 border-t">{{ $depots->links() }}</div> @endif
|
||||
</div>
|
||||
</div>
|
||||
</x-app-layout>
|
||||
@@ -0,0 +1,34 @@
|
||||
<x-app-layout>
|
||||
<x-slot name="header">
|
||||
<div class="flex items-center justify-between">
|
||||
<h2 class="text-xl font-semibold text-gray-800">{{ $depot->nom }}</h2>
|
||||
<a href="{{ route('admin.depots.edit', $depot) }}" class="px-4 py-2 bg-indigo-600 text-white text-sm rounded-md hover:bg-indigo-700">Modifier</a>
|
||||
</div>
|
||||
</x-slot>
|
||||
<div class="py-8 max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 space-y-6">
|
||||
<div class="bg-white shadow rounded-lg divide-y divide-gray-100 text-sm">
|
||||
@if($depot->description)
|
||||
<div class="px-6 py-4 grid grid-cols-3 gap-4"><dt class="font-medium text-gray-500">Description</dt><dd class="col-span-2">{{ $depot->description }}</dd></div>
|
||||
@endif
|
||||
@if($depot->adresse_postale)
|
||||
<div class="px-6 py-4 grid grid-cols-3 gap-4"><dt class="font-medium text-gray-500">Adresse</dt><dd class="col-span-2">{{ $depot->adresse_postale }}</dd></div>
|
||||
@endif
|
||||
@if($depot->url)
|
||||
<div class="px-6 py-4 grid grid-cols-3 gap-4"><dt class="font-medium text-gray-500">Site</dt><dd class="col-span-2"><a href="{{ $depot->url }}" target="_blank" class="text-indigo-600 hover:underline">{{ $depot->url }}</a></dd></div>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
@if($depot->sources->isNotEmpty())
|
||||
<div class="bg-white shadow rounded-lg overflow-hidden">
|
||||
<div class="px-6 py-4 border-b font-medium text-gray-900">Sources ({{ $depot->sources->count() }})</div>
|
||||
<ul class="divide-y divide-gray-100">
|
||||
@foreach($depot->sources as $source)
|
||||
<li class="px-6 py-3 text-sm text-gray-700">{{ $source->nom }}</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<a href="{{ route('admin.depots.index') }}" class="text-sm text-indigo-600 hover:underline">← Retour</a>
|
||||
</div>
|
||||
</x-app-layout>
|
||||
@@ -0,0 +1,41 @@
|
||||
<div class="space-y-5">
|
||||
<div>
|
||||
<label for="nom" class="block text-sm font-medium text-gray-700">Nom <span class="text-red-500">*</span></label>
|
||||
<input type="text" id="nom" name="nom" value="{{ old('nom', $section?->nom) }}" required
|
||||
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 @error('nom') border-red-500 @enderror">
|
||||
@error('nom') <p class="mt-1 text-sm text-red-600">{{ $message }}</p> @enderror
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="lieu_id" class="block text-sm font-medium text-gray-700">Lieu de rattachement</label>
|
||||
<select id="lieu_id" name="lieu_id"
|
||||
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500">
|
||||
<option value="">— Aucun —</option>
|
||||
@foreach($lieux as $lieu)
|
||||
<option value="{{ $lieu->id }}" {{ old('lieu_id', $section?->lieu_id) == $lieu->id ? 'selected' : '' }}>
|
||||
{{ $lieu->nom_long ?? $lieu->nom }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="adresse" class="block text-sm font-medium text-gray-700">Adresse</label>
|
||||
<input type="text" id="adresse" name="adresse" value="{{ old('adresse', $section?->adresse) }}"
|
||||
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="email_contact" class="block text-sm font-medium text-gray-700">Email de contact</label>
|
||||
<input type="email" id="email_contact" name="email_contact" value="{{ old('email_contact', $section?->email_contact) }}"
|
||||
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 @error('email_contact') border-red-500 @enderror">
|
||||
@error('email_contact') <p class="mt-1 text-sm text-red-600">{{ $message }}</p> @enderror
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="url" class="block text-sm font-medium text-gray-700">Site internet</label>
|
||||
<input type="url" id="url" name="url" value="{{ old('url', $section?->url) }}"
|
||||
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 @error('url') border-red-500 @enderror">
|
||||
@error('url') <p class="mt-1 text-sm text-red-600">{{ $message }}</p> @enderror
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,15 @@
|
||||
<x-app-layout>
|
||||
<x-slot name="header"><h2 class="text-xl font-semibold text-gray-800">Nouvelle section</h2></x-slot>
|
||||
<div class="py-8 max-w-2xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<div class="bg-white shadow rounded-lg p-6">
|
||||
<form method="POST" action="{{ route('admin.sections.store') }}">
|
||||
@csrf
|
||||
@include('admin.sections._form', ['section' => null])
|
||||
<div class="mt-6 flex gap-4">
|
||||
<button type="submit" class="px-5 py-2 bg-indigo-600 text-white rounded-md hover:bg-indigo-700">Créer</button>
|
||||
<a href="{{ route('admin.sections.index') }}" class="text-sm text-gray-500 hover:text-gray-700 self-center">Annuler</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</x-app-layout>
|
||||
@@ -0,0 +1,15 @@
|
||||
<x-app-layout>
|
||||
<x-slot name="header"><h2 class="text-xl font-semibold text-gray-800">Modifier : {{ $section->nom }}</h2></x-slot>
|
||||
<div class="py-8 max-w-2xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<div class="bg-white shadow rounded-lg p-6">
|
||||
<form method="POST" action="{{ route('admin.sections.update', $section) }}">
|
||||
@csrf @method('PUT')
|
||||
@include('admin.sections._form', ['section' => $section])
|
||||
<div class="mt-6 flex gap-4">
|
||||
<button type="submit" class="px-5 py-2 bg-indigo-600 text-white rounded-md hover:bg-indigo-700">Enregistrer</button>
|
||||
<a href="{{ route('admin.sections.show', $section) }}" class="text-sm text-gray-500 hover:text-gray-700 self-center">Annuler</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</x-app-layout>
|
||||
@@ -0,0 +1,52 @@
|
||||
<x-app-layout>
|
||||
<x-slot name="header">
|
||||
<div class="flex items-center justify-between">
|
||||
<h2 class="text-xl font-semibold text-gray-800">Sections locales</h2>
|
||||
<a href="{{ route('admin.sections.create') }}"
|
||||
class="px-4 py-2 bg-indigo-600 text-white text-sm rounded-md hover:bg-indigo-700">+ Nouvelle section</a>
|
||||
</div>
|
||||
</x-slot>
|
||||
|
||||
<div class="py-8 max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
@if(session('success'))
|
||||
<div class="mb-4 p-4 bg-green-50 border border-green-200 text-green-800 rounded-md">{{ session('success') }}</div>
|
||||
@endif
|
||||
|
||||
<div class="bg-white shadow rounded-lg overflow-hidden">
|
||||
<table class="min-w-full divide-y divide-gray-200">
|
||||
<thead class="bg-gray-50">
|
||||
<tr>
|
||||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Nom</th>
|
||||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Lieu</th>
|
||||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Contact</th>
|
||||
<th class="px-6 py-3"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-gray-200">
|
||||
@forelse($sections as $section)
|
||||
<tr class="hover:bg-gray-50">
|
||||
<td class="px-6 py-4 font-medium">
|
||||
<a href="{{ route('admin.sections.show', $section) }}" class="text-indigo-600 hover:underline">{{ $section->nom }}</a>
|
||||
</td>
|
||||
<td class="px-6 py-4 text-sm text-gray-500">{{ $section->lieu?->nom ?? '—' }}</td>
|
||||
<td class="px-6 py-4 text-sm text-gray-500">{{ $section->email_contact ?? '—' }}</td>
|
||||
<td class="px-6 py-4 text-right text-sm space-x-3">
|
||||
<a href="{{ route('admin.sections.edit', $section) }}" class="text-gray-600 hover:text-indigo-600">Modifier</a>
|
||||
<form method="POST" action="{{ route('admin.sections.destroy', $section) }}" class="inline"
|
||||
x-data @submit.prevent="if(confirm('Supprimer cette section ?')) $el.submit()">
|
||||
@csrf @method('DELETE')
|
||||
<button type="submit" class="text-red-500 hover:text-red-700">Supprimer</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr><td colspan="4" class="px-6 py-10 text-center text-gray-400">Aucune section.</td></tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
@if($sections->hasPages())
|
||||
<div class="px-6 py-4 border-t">{{ $sections->links() }}</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</x-app-layout>
|
||||
@@ -0,0 +1,91 @@
|
||||
<x-app-layout>
|
||||
<x-slot name="header">
|
||||
<div class="flex items-center justify-between">
|
||||
<h2 class="text-xl font-semibold text-gray-800">{{ $section->nom }}</h2>
|
||||
<a href="{{ route('admin.sections.edit', $section) }}"
|
||||
class="px-4 py-2 bg-indigo-600 text-white text-sm rounded-md hover:bg-indigo-700">Modifier</a>
|
||||
</div>
|
||||
</x-slot>
|
||||
|
||||
<div class="py-8 max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 space-y-6">
|
||||
@foreach(['success','error'] as $flash)
|
||||
@if(session($flash))
|
||||
<div class="p-4 rounded-md {{ $flash === 'success' ? 'bg-green-50 border border-green-200 text-green-800' : 'bg-red-50 border border-red-200 text-red-800' }}">
|
||||
{{ session($flash) }}
|
||||
</div>
|
||||
@endif
|
||||
@endforeach
|
||||
|
||||
{{-- Fiche --}}
|
||||
<div class="bg-white shadow rounded-lg divide-y divide-gray-100 text-sm">
|
||||
@foreach([['Lieu', $section->lieu?->nom_long ?? '—'], ['Adresse', $section->adresse ?? '—'], ['Email', $section->email_contact ?? '—'], ['Site', $section->url ?? '—']] as [$label, $val])
|
||||
<div class="px-6 py-4 grid grid-cols-3 gap-4">
|
||||
<dt class="font-medium text-gray-500">{{ $label }}</dt>
|
||||
<dd class="col-span-2 text-gray-900">{{ $val }}</dd>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
|
||||
{{-- Membres --}}
|
||||
<div class="bg-white shadow rounded-lg overflow-hidden">
|
||||
<div class="px-6 py-4 border-b border-gray-200 font-medium text-gray-900">
|
||||
Membres ({{ $section->membres->count() }})
|
||||
</div>
|
||||
@if($section->membres->isNotEmpty())
|
||||
<table class="min-w-full divide-y divide-gray-200 text-sm">
|
||||
<thead class="bg-gray-50">
|
||||
<tr>
|
||||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Nom</th>
|
||||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Email</th>
|
||||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Rôle dans la section</th>
|
||||
<th class="px-6 py-3"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-gray-200">
|
||||
@foreach($section->membres as $membre)
|
||||
<tr>
|
||||
<td class="px-6 py-3">{{ $membre->name }}</td>
|
||||
<td class="px-6 py-3 text-gray-500">{{ $membre->email }}</td>
|
||||
<td class="px-6 py-3">
|
||||
{{ $membre->pivot->role_in_section === 'section_manager' ? 'Responsable' : 'Membre' }}
|
||||
</td>
|
||||
<td class="px-6 py-3 text-right">
|
||||
<form method="POST" action="{{ route('admin.sections.membres.remove', [$section, $membre]) }}"
|
||||
x-data @submit.prevent="if(confirm('Retirer ce membre ?')) $el.submit()">
|
||||
@csrf @method('DELETE')
|
||||
<button type="submit" class="text-red-500 hover:text-red-700 text-sm">Retirer</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
@endif
|
||||
|
||||
{{-- Ajouter un membre --}}
|
||||
<div class="px-6 py-4 bg-gray-50 border-t border-gray-200">
|
||||
<form method="POST" action="{{ route('admin.sections.membres.add', $section) }}" class="flex gap-3 items-end">
|
||||
@csrf
|
||||
<div class="flex-1">
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">Utilisateur</label>
|
||||
<select name="user_id" class="block w-full rounded-md border-gray-300 shadow-sm text-sm focus:border-indigo-500 focus:ring-indigo-500">
|
||||
@foreach($users as $user)
|
||||
<option value="{{ $user->id }}">{{ $user->name }} ({{ $user->email }})</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">Rôle</label>
|
||||
<select name="role_in_section" class="block w-full rounded-md border-gray-300 shadow-sm text-sm focus:border-indigo-500 focus:ring-indigo-500">
|
||||
<option value="member">Membre</option>
|
||||
<option value="section_manager">Responsable</option>
|
||||
</select>
|
||||
</div>
|
||||
<button type="submit" class="px-4 py-2 bg-indigo-600 text-white text-sm rounded-md hover:bg-indigo-700">Ajouter</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<a href="{{ route('admin.sections.index') }}" class="text-sm text-indigo-600 hover:underline">← Retour</a>
|
||||
</div>
|
||||
</x-app-layout>
|
||||
@@ -0,0 +1,27 @@
|
||||
<x-app-layout>
|
||||
<x-slot name="header"><h2 class="text-xl font-semibold text-gray-800">Nouveau type de source</h2></x-slot>
|
||||
<div class="py-8 max-w-2xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<div class="bg-white shadow rounded-lg p-6">
|
||||
<form method="POST" action="{{ route('admin.source-types.store') }}">
|
||||
@csrf
|
||||
<div class="space-y-5">
|
||||
<div>
|
||||
<label for="nom" class="block text-sm font-medium text-gray-700">Nom <span class="text-red-500">*</span></label>
|
||||
<input type="text" id="nom" name="nom" value="{{ old('nom') }}" required
|
||||
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500">
|
||||
@error('nom') <p class="mt-1 text-sm text-red-600">{{ $message }}</p> @enderror
|
||||
</div>
|
||||
<div>
|
||||
<label for="description" class="block text-sm font-medium text-gray-700">Description</label>
|
||||
<textarea id="description" name="description" rows="3"
|
||||
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500">{{ old('description') }}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-6 flex gap-4">
|
||||
<button type="submit" class="px-5 py-2 bg-indigo-600 text-white rounded-md hover:bg-indigo-700">Créer et définir les champs</button>
|
||||
<a href="{{ route('admin.source-types.index') }}" class="text-sm text-gray-500 self-center hover:text-gray-700">Annuler</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</x-app-layout>
|
||||
@@ -0,0 +1,26 @@
|
||||
<x-app-layout>
|
||||
<x-slot name="header"><h2 class="text-xl font-semibold text-gray-800">Modifier : {{ $sourceType->nom }}</h2></x-slot>
|
||||
<div class="py-8 max-w-2xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<div class="bg-white shadow rounded-lg p-6">
|
||||
<form method="POST" action="{{ route('admin.source-types.update', $sourceType) }}">
|
||||
@csrf @method('PUT')
|
||||
<div class="space-y-5">
|
||||
<div>
|
||||
<label for="nom" class="block text-sm font-medium text-gray-700">Nom <span class="text-red-500">*</span></label>
|
||||
<input type="text" id="nom" name="nom" value="{{ old('nom', $sourceType->nom) }}" required
|
||||
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500">
|
||||
</div>
|
||||
<div>
|
||||
<label for="description" class="block text-sm font-medium text-gray-700">Description</label>
|
||||
<textarea id="description" name="description" rows="3"
|
||||
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500">{{ old('description', $sourceType->description) }}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-6 flex gap-4">
|
||||
<button type="submit" class="px-5 py-2 bg-indigo-600 text-white rounded-md hover:bg-indigo-700">Enregistrer</button>
|
||||
<a href="{{ route('admin.source-types.show', $sourceType) }}" class="text-sm text-gray-500 self-center hover:text-gray-700">Annuler</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</x-app-layout>
|
||||
@@ -0,0 +1,46 @@
|
||||
<x-app-layout>
|
||||
<x-slot name="header">
|
||||
<div class="flex items-center justify-between">
|
||||
<h2 class="text-xl font-semibold text-gray-800">Types de sources</h2>
|
||||
<a href="{{ route('admin.source-types.create') }}" class="px-4 py-2 bg-indigo-600 text-white text-sm rounded-md hover:bg-indigo-700">+ Nouveau type</a>
|
||||
</div>
|
||||
</x-slot>
|
||||
<div class="py-8 max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
@if(session('success')) <div class="mb-4 p-4 bg-green-50 border border-green-200 text-green-800 rounded-md">{{ session('success') }}</div> @endif
|
||||
@if(session('error')) <div class="mb-4 p-4 bg-red-50 border border-red-200 text-red-800 rounded-md">{{ session('error') }}</div> @endif
|
||||
<div class="bg-white shadow rounded-lg overflow-hidden">
|
||||
<table class="min-w-full divide-y divide-gray-200">
|
||||
<thead class="bg-gray-50">
|
||||
<tr>
|
||||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Nom</th>
|
||||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Champs</th>
|
||||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Sources liées</th>
|
||||
<th class="px-6 py-3"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-gray-200">
|
||||
@forelse($sourceTypes as $st)
|
||||
<tr class="hover:bg-gray-50">
|
||||
<td class="px-6 py-4 font-medium">
|
||||
<a href="{{ route('admin.source-types.show', $st) }}" class="text-indigo-600 hover:underline">{{ $st->nom }}</a>
|
||||
</td>
|
||||
<td class="px-6 py-4 text-sm text-gray-500">{{ $st->fields_count ?? '—' }}</td>
|
||||
<td class="px-6 py-4 text-sm text-gray-500">{{ $st->sources_count }}</td>
|
||||
<td class="px-6 py-4 text-right text-sm space-x-3">
|
||||
<a href="{{ route('admin.source-types.edit', $st) }}" class="text-gray-600 hover:text-indigo-600">Modifier</a>
|
||||
<form method="POST" action="{{ route('admin.source-types.destroy', $st) }}" class="inline"
|
||||
x-data @submit.prevent="if(confirm('Supprimer ce type ?')) $el.submit()">
|
||||
@csrf @method('DELETE')
|
||||
<button type="submit" class="text-red-500 hover:text-red-700">Supprimer</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr><td colspan="4" class="px-6 py-10 text-center text-gray-400">Aucun type de source.</td></tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
@if($sourceTypes->hasPages()) <div class="px-6 py-4 border-t">{{ $sourceTypes->links() }}</div> @endif
|
||||
</div>
|
||||
</div>
|
||||
</x-app-layout>
|
||||
@@ -0,0 +1,147 @@
|
||||
<x-app-layout>
|
||||
<x-slot name="header">
|
||||
<div class="flex items-center justify-between">
|
||||
<h2 class="text-xl font-semibold text-gray-800">{{ $sourceType->nom }}</h2>
|
||||
<a href="{{ route('admin.source-types.edit', $sourceType) }}" class="px-4 py-2 bg-indigo-600 text-white text-sm rounded-md hover:bg-indigo-700">Modifier</a>
|
||||
</div>
|
||||
</x-slot>
|
||||
|
||||
<div class="py-8 max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 space-y-6">
|
||||
@foreach(['success','error'] as $flash)
|
||||
@if(session($flash))
|
||||
<div class="p-4 rounded-md {{ $flash === 'success' ? 'bg-green-50 border border-green-200 text-green-800' : 'bg-red-50 border border-red-200 text-red-800' }}">
|
||||
{{ session($flash) }}
|
||||
</div>
|
||||
@endif
|
||||
@endforeach
|
||||
|
||||
@if($sourceType->description)
|
||||
<div class="bg-white shadow rounded-lg px-6 py-4 text-sm text-gray-700">{{ $sourceType->description }}</div>
|
||||
@endif
|
||||
|
||||
{{-- Champs existants --}}
|
||||
<div class="bg-white shadow rounded-lg overflow-hidden">
|
||||
<div class="px-6 py-4 border-b border-gray-200 flex items-center justify-between">
|
||||
<h3 class="font-medium text-gray-900">Champs ({{ $sourceType->fields->count() }})</h3>
|
||||
<span class="text-xs text-gray-400">Glisser-déposer pour réordonner</span>
|
||||
</div>
|
||||
|
||||
@if($sourceType->fields->isNotEmpty())
|
||||
<form method="POST" action="{{ route('admin.source-types.fields.reorder', $sourceType) }}" id="reorder-form">
|
||||
@csrf
|
||||
</form>
|
||||
|
||||
<ul id="fields-list" class="divide-y divide-gray-100">
|
||||
@foreach($sourceType->fields as $field)
|
||||
<li class="px-6 py-3 flex items-center gap-4" data-id="{{ $field->id }}">
|
||||
<span class="cursor-move text-gray-300 hover:text-gray-500 select-none">⠿</span>
|
||||
<div class="flex-1 grid grid-cols-4 gap-3 text-sm">
|
||||
<span class="font-mono text-indigo-700">{{ $field->name }}</span>
|
||||
<span class="text-gray-700">{{ $field->label }}</span>
|
||||
<span class="text-gray-500">{{ $field->type->value }}</span>
|
||||
<span class="text-gray-400">{{ $field->required ? 'Obligatoire' : 'Optionnel' }}</span>
|
||||
</div>
|
||||
<div class="flex gap-2">
|
||||
<button type="button"
|
||||
x-data="{ open: false }"
|
||||
@click="open = !open"
|
||||
class="text-xs text-gray-500 hover:text-indigo-600">Modifier</button>
|
||||
<form method="POST" action="{{ route('admin.source-types.fields.destroy', [$sourceType, $field]) }}"
|
||||
x-data @submit.prevent="if(confirm('Supprimer ce champ ?')) $el.submit()">
|
||||
@csrf @method('DELETE')
|
||||
<button type="submit" class="text-xs text-red-500 hover:text-red-700">Supprimer</button>
|
||||
</form>
|
||||
</div>
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
@else
|
||||
<p class="px-6 py-8 text-center text-gray-400 text-sm">Aucun champ défini. Ajoutez-en ci-dessous.</p>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
{{-- Ajouter un champ --}}
|
||||
<div class="bg-white shadow rounded-lg p-6">
|
||||
<h3 class="font-medium text-gray-900 mb-4">Ajouter un champ</h3>
|
||||
<form method="POST" action="{{ route('admin.source-types.fields.store', $sourceType) }}">
|
||||
@csrf
|
||||
<div class="grid grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">Nom technique <span class="text-red-500">*</span></label>
|
||||
<input type="text" name="name" value="{{ old('name') }}" required
|
||||
placeholder="ex: nom_pere"
|
||||
class="block w-full rounded-md border-gray-300 shadow-sm text-sm focus:border-indigo-500 focus:ring-indigo-500 @error('name') border-red-500 @enderror">
|
||||
@error('name') <p class="mt-1 text-xs text-red-600">{{ $message }}</p> @enderror
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">Libellé affiché <span class="text-red-500">*</span></label>
|
||||
<input type="text" name="label" value="{{ old('label') }}" required
|
||||
placeholder="ex: Nom du père"
|
||||
class="block w-full rounded-md border-gray-300 shadow-sm text-sm focus:border-indigo-500 focus:ring-indigo-500 @error('label') border-red-500 @enderror">
|
||||
@error('label') <p class="mt-1 text-xs text-red-600">{{ $message }}</p> @enderror
|
||||
</div>
|
||||
<div x-data="{ type: '{{ old('type', 'text') }}' }">
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">Type <span class="text-red-500">*</span></label>
|
||||
<select name="type" x-model="type"
|
||||
class="block w-full rounded-md border-gray-300 shadow-sm text-sm focus:border-indigo-500 focus:ring-indigo-500">
|
||||
@foreach(\App\Enums\FieldType::cases() as $ft)
|
||||
<option value="{{ $ft->value }}" {{ old('type') === $ft->value ? 'selected' : '' }}>{{ $ft->value }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
|
||||
{{-- Options pour type=select --}}
|
||||
<div x-show="type === 'select'" x-cloak class="mt-3">
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">Options (une par ligne)</label>
|
||||
<textarea name="options_raw" rows="3" placeholder="Option A Option B Option C"
|
||||
class="block w-full rounded-md border-gray-300 shadow-sm text-sm focus:border-indigo-500 focus:ring-indigo-500">{{ old('options_raw') }}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-end">
|
||||
<label class="flex items-center gap-2 text-sm text-gray-700">
|
||||
<input type="checkbox" name="required" value="1" {{ old('required') ? 'checked' : '' }}
|
||||
class="rounded border-gray-300 text-indigo-600 focus:ring-indigo-500">
|
||||
Champ obligatoire
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-4">
|
||||
<button type="submit" class="px-4 py-2 bg-indigo-600 text-white text-sm rounded-md hover:bg-indigo-700">
|
||||
Ajouter le champ
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<a href="{{ route('admin.source-types.index') }}" class="text-sm text-indigo-600 hover:underline">← Retour</a>
|
||||
</div>
|
||||
|
||||
{{-- Drag & drop reorder --}}
|
||||
@if($sourceType->fields->isNotEmpty())
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const list = document.getElementById('fields-list');
|
||||
const form = document.getElementById('reorder-form');
|
||||
if (!list || !form) return;
|
||||
|
||||
let dragged = null;
|
||||
|
||||
list.querySelectorAll('li').forEach(li => {
|
||||
li.setAttribute('draggable', true);
|
||||
li.addEventListener('dragstart', () => { dragged = li; li.classList.add('opacity-50'); });
|
||||
li.addEventListener('dragend', () => {
|
||||
li.classList.remove('opacity-50');
|
||||
// Soumettre le nouvel ordre
|
||||
const ids = [...list.querySelectorAll('li')].map(el => el.dataset.id);
|
||||
ids.forEach(id => {
|
||||
const input = document.createElement('input');
|
||||
input.type = 'hidden'; input.name = 'ids[]'; input.value = id;
|
||||
form.appendChild(input);
|
||||
});
|
||||
form.submit();
|
||||
});
|
||||
li.addEventListener('dragover', e => { e.preventDefault(); const rect = li.getBoundingClientRect(); const mid = rect.top + rect.height / 2; list.insertBefore(dragged, e.clientY < mid ? li : li.nextSibling); });
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endif
|
||||
</x-app-layout>
|
||||
Reference in New Issue
Block a user