Răsfoiți Sursa

Editer un film

Francois DROUHARD 901 2 luni în urmă
părinte
comite
86aa68295a
5 a modificat fișierele cu 15 adăugiri și 3 ștergeri
  1. 2 0
      assets/app.js
  2. 1 0
      package.json
  3. 3 3
      src/Controller/IndexController.php
  4. 4 0
      templates/index/index.html.twig
  5. 5 0
      yarn.lock

+ 2 - 0
assets/app.js

@@ -6,3 +6,5 @@ import './bootstrap.js';
  * which should already be in your base.html.twig.
  */
 import './styles/app.scss';
+import "@fortawesome/fontawesome-free/css/all.css";
+

+ 1 - 0
package.json

@@ -2,6 +2,7 @@
     "devDependencies": {
         "@babel/core": "^7.17.0",
         "@babel/preset-env": "^7.16.0",
+        "@fortawesome/fontawesome-free": "^6.7.2",
         "@hotwired/stimulus": "^3.0.0",
         "@hotwired/turbo": "^7.1.1 || ^8.0",
         "@picocss/pico": "^2.0.6",

+ 3 - 3
src/Controller/IndexController.php

@@ -13,10 +13,10 @@ use Symfony\Component\Routing\Attribute\Route;
 
 class IndexController extends AbstractController
 {
-    #[Route('/', name: 'app_index', methods: ['GET', 'POST'])]
-    public function index(Request $request, FilmRepository $filmRepository): Response
+    #[Route('/{id?}', name: 'app_index', methods: ['GET', 'POST'], requirements: ['id' => '\d+'])]
+    public function index(Request $request, FilmRepository $filmRepository, ?Film $film = null): Response
     {
-        $film = new Film();
+        $film = $film ?? new Film();
         $form = $this->createForm(FilmType::class, $film);
         $films = $filmRepository->findAll();
 

+ 4 - 0
templates/index/index.html.twig

@@ -9,6 +9,7 @@
 <table>
     <thead>
         <tr>
+            <th>Actions</th>
             <th>Nom</th>
             <th>Realisateur</th>
             <th>Genre</th>
@@ -17,6 +18,9 @@
     <tbody>
         {% for film in films %}
         <tr>
+            <td>
+            <a href="{{ path('app_index', {'id': film.id} ) }}"><i class="fa fa-edit"></i></a>
+            </td>
             <td>{{ film.name }}</td>
             <td>{{ film.realisateur }}</td>
             <td>{{ film.genre }}</td>

+ 5 - 0
yarn.lock

@@ -788,6 +788,11 @@
   resolved "http://nexus.intra.cnaf/repository/npm-public/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz#1d572bfbbe14b7704e0ba0f39b74815b84870d70"
   integrity sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw==
 
+"@fortawesome/fontawesome-free@^6.7.2":
+  version "6.7.2"
+  resolved "http://nexus.intra.cnaf/repository/npm-public/@fortawesome/fontawesome-free/-/fontawesome-free-6.7.2.tgz#8249de9b7e22fcb3ceb5e66090c30a1d5492b81a"
+  integrity sha512-JUOtgFW6k9u4Y+xeIaEiLr3+cjoUPiAuLXoyKOJSia6Duzb7pq+A76P9ZdPDoAoxHdHzq6gE9/jKBGXlZT8FbA==
+
 "@hotwired/stimulus-webpack-helpers@^1.0.1":
   version "1.0.1"
   resolved "http://nexus.intra.cnaf/repository/npm-public/@hotwired/stimulus-webpack-helpers/-/stimulus-webpack-helpers-1.0.1.tgz#4cd74487adeca576c9865ac2b9fe5cb20cef16dd"