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')] #[IsGranted('ROLE_INSTRUCTOR')]
#[Route('/new', name: 'app_atelier_new', methods: ['GET', 'POST'])] #[Route('/new', name: 'app_atelier_new', methods: ['GET', 'POST'])]
public function new(Request $request, AtelierRepository $atelierRepository): Response public function new(Request $request, AtelierRepository $atelierRepository): Response

View File

@ -3,8 +3,9 @@
{% block title %}Atelier index{% endblock %} {% block title %}Atelier index{% endblock %}
{% block body %} {% block body %}
<h1>Atelier index</h1> <h1>Liste des Ateliers</h1>
{% if (ateliers | length) > 0 %}
<table class="table"> <table class="table">
<thead> <thead>
<tr> <tr>
@ -29,15 +30,12 @@
href="{{ path('app_atelier_edit', {'id': atelier.id}) }}">Modifier</a> href="{{ path('app_atelier_edit', {'id': atelier.id}) }}">Modifier</a>
{% else %} {% else %}
<button class="btn btn-outline-secondary m-1" <button class="btn btn-outline-secondary m-1"
href="{{ path('app_atelier_edit', {'id': atelier.id}) }}" disabled>Modifier</button> href="{{ path('app_atelier_edit', {'id': atelier.id}) }}" disabled>Modifier
</button>
{% endif %} {% endif %}
</div> </div>
</td> </td>
</tr> </tr>
{% else %}
<tr>
<td colspan="4">no records found</td>
</tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
@ -45,4 +43,11 @@
<div class="d-flex justify-content-center"> <div class="d-flex justify-content-center">
<a class="btn btn-primary mb-3" href="{{ path('app_atelier_new') }}">Créer atelier</a> <a class="btn btn-primary mb-3" href="{{ path('app_atelier_new') }}">Créer atelier</a>
</div> </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 %} {% endblock %}

View File

@ -16,34 +16,11 @@
{% endblock %} {% endblock %}
</head> </head>
<body> <body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark"> <header>
<div class="container-fluid"> {% block topnavbar %}
<a class="navbar-brand" href="#">CC34</a> {{ include('components/navbar.html.twig') }}
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" {% endblock %}
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"> </header>
<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>
<div class="container"> <div class="container">
<main class="pt-4"> <main class="pt-4">
{% block body %}{% endblock %} {% 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>