update button & navbar
continuous-integration/drone/push Build is failing Details

Bastien OLLIER 3 weeks ago
parent 6a6a135891
commit d6806f09a8

@ -34,16 +34,13 @@ class PostController extends AbstractController
]); ]);
} }
#[Route('/post', name: 'app_post_index', methods: ['GET'])] #[Route('/posts', name: 'app_post_index', methods: ['GET'])]
public function table(PostRepository $repository): Response public function table(PostRepository $repository): Response
{ {
$posts = $repository->findAll(); return $this->redirectToRoute('app_posts', [], Response::HTTP_SEE_OTHER);
return $this->render('post/table.html.twig', [
'posts' => $posts,
]);
} }
#[Route('/post/new', name: 'app_post_new', methods: ['GET', 'POST'])] #[Route('/posts/new', name: 'app_post_new', methods: ['GET', 'POST'])]
#[IsGranted('ROLE_USER')] #[IsGranted('ROLE_USER')]
public function new(Request $request, EntityManagerInterface $entityManager): Response public function new(Request $request, EntityManagerInterface $entityManager): Response
{ {
@ -64,7 +61,7 @@ class PostController extends AbstractController
]); ]);
} }
#[Route('/post/{id}', name: 'app_post_show', methods: ['GET'])] #[Route('/posts/{id}', name: 'app_post_show', methods: ['GET'])]
public function show(Post $post): Response public function show(Post $post): Response
{ {
$form = $this->createForm(CommentType::class, new Comment(), [ $form = $this->createForm(CommentType::class, new Comment(), [
@ -76,7 +73,7 @@ class PostController extends AbstractController
]); ]);
} }
#[Route('/post/{id}/edit', name: 'app_post_edit', methods: ['GET', 'POST'])] #[Route('/posts/{id}/edit', name: 'app_post_edit', methods: ['GET', 'POST'])]
#[IsGranted('ROLE_USER')] #[IsGranted('ROLE_USER')]
public function edit(Request $request, Post $post, EntityManagerInterface $entityManager): Response public function edit(Request $request, Post $post, EntityManagerInterface $entityManager): Response
{ {
@ -95,7 +92,7 @@ class PostController extends AbstractController
]); ]);
} }
#[Route('/post/{id}', name: 'app_post_delete', methods: ['POST'])] #[Route('/posts/{id}', name: 'app_post_delete', methods: ['POST'])]
#[IsGranted('ROLE_USER')] #[IsGranted('ROLE_USER')]
public function delete(Request $request, Post $post, EntityManagerInterface $entityManager): Response public function delete(Request $request, Post $post, EntityManagerInterface $entityManager): Response
{ {
@ -107,7 +104,7 @@ class PostController extends AbstractController
return $this->redirectToRoute('app_posts', [], Response::HTTP_SEE_OTHER); return $this->redirectToRoute('app_posts', [], Response::HTTP_SEE_OTHER);
} }
#[Route('/post/{id}/comment', name: 'app_post_comment', methods: ['POST'])] #[Route('/posts/{id}/comment', name: 'app_post_comment', methods: ['POST'])]
public function publishComment(Request $request, Post $post, EntityManagerInterface $entityManager, #[CurrentUser] User $user): Response public function publishComment(Request $request, Post $post, EntityManagerInterface $entityManager, #[CurrentUser] User $user): Response
{ {
$comment = new Comment(); $comment = new Comment();

@ -18,7 +18,7 @@ class SpeciesController extends AbstractController
#[Route('/', name: 'app_species_index', methods: ['GET'])] #[Route('/', name: 'app_species_index', methods: ['GET'])]
public function table(SpeciesRepository $speciesRepository): Response public function table(SpeciesRepository $speciesRepository): Response
{ {
return $this->render('species/table.html.twig', [ return $this->render('species/index.html.twig', [
'species' => $speciesRepository->findAll(), 'species' => $speciesRepository->findAll(),
]); ]);
} }

@ -15,7 +15,29 @@
<body data-turbo="false"> <body data-turbo="false">
<nav class="navbar navbar-expand-lg bg-body-tertiary"> <nav class="navbar navbar-expand-lg bg-body-tertiary">
<div class="container-fluid"> <div class="container-fluid">
<a class="navbar-brand" href="{{ path('app_species_index') }}">Herbarium</a> <a class="navbar-brand" href="{{ path('app_posts') }}">Herbarium</a>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="{{ path('app_posts') }}">Posts</a>
</li>
{% if app.user %}
<li class="nav-item">
<a class="nav-link" href="{{ path('app_post_new') }}">New post</a>
</li>
{% endif %}
<li class="nav-item">
<a class="nav-link" href="{{ path('app_species_index') }}">Species</a>
</li>
{% if app.user %}
<li class="nav-item">
<a class="nav-link" href="{{ path('app_species_new') }}">New species</a>
</li>
{% endif %}
</ul>
</div>
{% if app.user %} {% if app.user %}
<a class="nav-link" href="{{ path('app_logout') }}">{{ app.user.email }} - Déconnexion</a> <a class="nav-link" href="{{ path('app_logout') }}">{{ app.user.email }} - Déconnexion</a>
{% else %} {% else %}

@ -7,7 +7,7 @@
{{ include('post/_form.html.twig', {'button_label': 'Update'}) }} {{ include('post/_form.html.twig', {'button_label': 'Update'}) }}
<a href="{{ path('app_post_index') }}">back to list</a> <a class="btn btn-warning mb-4 mt-4" href="{{ path('app_post_index') }}">back to list</a>
{{ include('post/_delete_form.html.twig') }} {{ include('post/_delete_form.html.twig') }}
{% endblock %} {% endblock %}

@ -6,6 +6,8 @@
<h1>Create new Post</h1> <h1>Create new Post</h1>
{{ include('post/_form.html.twig') }} {{ include('post/_form.html.twig') }}
<a class="btn btn-warning mb-4 mt-4" href="{{ path('app_post_index') }}">back to list</a>
<a href="{{ path('app_post_index') }}">back to list</a>
{% endblock %} {% endblock %}

@ -44,9 +44,10 @@
</tbody> </tbody>
</table> </table>
<a href="{{ path('app_post_index') }}">back to list</a> <a class="btn btn-warning mb-4 mt-4" href="{{ path('app_post_index') }}">back to list</a>
<a class="btn btn-success mb-4 mt-4" href="{{ path('app_post_edit', {'id': post.id}) }}">edit</a>
<a href="{{ path('app_post_edit', {'id': post.id}) }}">edit</a>
{{ include('post/_delete_form.html.twig') }} {{ include('post/_delete_form.html.twig') }}

@ -30,7 +30,7 @@
<td>{{ post.commentary }}</td> <td>{{ post.commentary }}</td>
<td> <td>
<a href="{{ path('app_post_show', {'id': post.id}) }}">show</a> <a href="{{ path('app_post_show', {'id': post.id}) }}">show</a>
<a href="{{ path('app_post_edit', {'id': post.id}) }}">edit</a> <a class="btn btn-success mb-4 mt-4" href="{{ path('app_post_edit', {'id': post.id}) }}">edit</a>
</td> </td>
</tr> </tr>
{% else %} {% else %}

@ -7,7 +7,8 @@
{{ include('species/_form.html.twig', {'button_label': 'Update'}) }} {{ include('species/_form.html.twig', {'button_label': 'Update'}) }}
<a href="{{ path('app_species_index') }}">back to list</a> <a class="btn btn-warning mb-4 mt-4" href="{{ path('app_species_index') }}">back to list</a>
{{ include('species/_delete_form.html.twig') }} {{ include('species/_delete_form.html.twig') }}
{% endblock %} {% endblock %}

@ -7,5 +7,6 @@
{{ include('species/_form.html.twig') }} {{ include('species/_form.html.twig') }}
<a href="{{ path('app_species_index') }}">back to list</a> <a class="btn btn-warning mb-4 mt-4" href="{{ path('app_species_index') }}">back to list</a>
{% endblock %} {% endblock %}

@ -27,9 +27,10 @@
</div> </div>
{% endfor %} {% endfor %}
<a href="{{ path('app_species_index') }}">back to list</a> <a class="btn btn-warning mb-4 mt-4" href="{{ path('app_species_index') }}">back to list</a>
<a class="btn btn-success mb-4 mt-4" href="{{ path('app_species_edit', {'id': species.id}) }}">edit</a>
<a href="{{ path('app_species_edit', {'id': species.id}) }}">edit</a>
{{ include('species/_delete_form.html.twig') }} {{ include('species/_delete_form.html.twig') }}
</div> </div>

Loading…
Cancel
Save