Merge pull request #13 in WFCC/cc34 from 11-mes-ateliers-et-refracto-navbar to master

* commit 'c0357d6947a05725571b370bb86a9e626c2fa556':
  Modification mise en page liste ateliers quand il n'y a pas encore d'ateliers
  Ajout d'un bouton Mes Ateliers dans la navbar
  Ajout d'une route byme aux ateliers pour voir les ateliers créé par l'utilisateur
  Deplacement de navbar dans son propre fichier
This commit is contained in:
Serra Aymeric 2023-02-09 10:04:27 +01:00
commit abc71ef25b
4 changed files with 90 additions and 66 deletions

View File

@ -23,6 +23,16 @@ class AtelierController extends AbstractController
]);
}
#[IsGranted('ROLE_INSTRUCTOR')]
#[Route('/byme', name: 'app_atelier_by_me', methods: ['GET'])]
public function index_created_by_user(AtelierRepository $atelierRepository, MarkdownAtelier $markdown): Response
{
$ateliers = $atelierRepository->findBy(['instructeur' => $this->getUser()]);
return $this->render('atelier/index.html.twig', [
'ateliers' => $markdown->parseArray($ateliers),
]);
}
#[IsGranted('ROLE_INSTRUCTOR')]
#[Route('/new', name: 'app_atelier_new', methods: ['GET', 'POST'])]
public function new(Request $request, AtelierRepository $atelierRepository): Response

View File

@ -3,46 +3,51 @@
{% block title %}Atelier index{% endblock %}
{% block body %}
<h1>Atelier index</h1>
<h1>Liste des Ateliers</h1>
<table class="table">
<thead>
<tr>
<th scope="row">Id</th>
<th scope="col">Nom</th>
<th class="" scope="col">Description</th>
<th scope="col">Actions</th>
</tr>
</thead>
<tbody>
{% for atelier in ateliers %}
{% if (ateliers | length) > 0 %}
<table class="table">
<thead>
<tr>
<td>{{ atelier.id }}</td>
<td>{{ atelier.nom }}</td>
<td>{{ atelier.description | raw }}</td>
<td>
<div class="d-flex flex-row align-content-end">
<a class="btn btn-outline-primary m-1"
href="{{ path('app_atelier_show', {'id': atelier.id}) }}">Afficher</a>
{% if app.user and app.user == atelier.instructeur %}
<th scope="row">Id</th>
<th scope="col">Nom</th>
<th class="" scope="col">Description</th>
<th scope="col">Actions</th>
</tr>
</thead>
<tbody>
{% for atelier in ateliers %}
<tr>
<td>{{ atelier.id }}</td>
<td>{{ atelier.nom }}</td>
<td>{{ atelier.description | raw }}</td>
<td>
<div class="d-flex flex-row align-content-end">
<a class="btn btn-outline-primary m-1"
href="{{ path('app_atelier_edit', {'id': atelier.id}) }}">Modifier</a>
{% else %}
<button class="btn btn-outline-secondary m-1"
href="{{ path('app_atelier_edit', {'id': atelier.id}) }}" disabled>Modifier</button>
{% endif %}
</div>
</td>
</tr>
{% else %}
<tr>
<td colspan="4">no records found</td>
</tr>
{% endfor %}
</tbody>
</table>
href="{{ path('app_atelier_show', {'id': atelier.id}) }}">Afficher</a>
{% if app.user and app.user == atelier.instructeur %}
<a class="btn btn-outline-primary m-1"
href="{{ path('app_atelier_edit', {'id': atelier.id}) }}">Modifier</a>
{% else %}
<button class="btn btn-outline-secondary m-1"
href="{{ path('app_atelier_edit', {'id': atelier.id}) }}" disabled>Modifier
</button>
{% endif %}
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<div class="d-flex justify-content-center">
<a class="btn btn-primary mb-3" href="{{ path('app_atelier_new') }}">Créer atelier</a>
</div>
<div class="d-flex justify-content-center">
<a class="btn btn-primary mb-3" href="{{ path('app_atelier_new') }}">Créer atelier</a>
</div>
{% else %}
<div class="alert alert-info" role="alert">
Il n'y a pas encore d'ateliers. Vous pouvez commencer par <a class="alert-link"
href="{{ path('app_atelier_new') }}">en créer
un !</a>
</div>
{% endif %}
{% endblock %}

View File

@ -16,34 +16,11 @@
{% endblock %}
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container-fluid">
<a class="navbar-brand" href="#">CC34</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="{{ path('app_index') }}">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ path('app_atelier_index') }}">Atelier</a>
</li>
</ul>
</div>
{% if app.user %}
<div class="me-2">
<span class="navbar-text">{{ app.user.nom }} {{ app.user.prenom }}</span>
</div>
<a class="btn btn-secondary" href="{{ path('app_logout') }}">Se déconnecter</a>
{% elseif not app.user %}
<a class="btn btn-success" href="{{ path('app_login') }}">Se connecter</a>
{% endif %}
</div>
</nav>
<header>
{% block topnavbar %}
{{ include('components/navbar.html.twig') }}
{% endblock %}
</header>
<div class="container">
<main class="pt-4">
{% block body %}{% endblock %}

View File

@ -0,0 +1,32 @@
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container-fluid">
<a class="navbar-brand" href="#">CC34</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="{{ path('app_index') }}">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ path('app_atelier_index') }}">Atelier</a>
</li>
{% if app.user %}
<li class="nav-item">
<a class="nav-link" href="{{ path('app_atelier_by_me') }}">Mes Ateliers</a>
</li>
{% endif %}
</ul>
</div>
{% if app.user %}
<div class="me-2">
<span class="navbar-text">{{ app.user.nom }} {{ app.user.prenom }}</span>
</div>
<a class="btn btn-secondary" href="{{ path('app_logout') }}">Se déconnecter</a>
{% elseif not app.user %}
<a class="btn btn-success" href="{{ path('app_login') }}">Se connecter</a>
{% endif %}
</div>
</nav>