From 2e52a5637ed4e283332b63eca995249ccaa36b20 Mon Sep 17 00:00:00 2001 From: pfleu <fleutotp@gmail.com> Date: Mon, 12 Jun 2023 12:47:37 +0200 Subject: [PATCH] Home : Ajout lien Copie du mot du jour dans un lexique --- src/Controller/EntryController.php | 4 ++++ src/Repository/EntryRepository.php | 2 +- templates/home.html.twig | 20 +++++++++++++++++--- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/Controller/EntryController.php b/src/Controller/EntryController.php index 36f464c..de5d4c4 100644 --- a/src/Controller/EntryController.php +++ b/src/Controller/EntryController.php @@ -83,6 +83,10 @@ class EntryController extends AppBaseController $this->addFlash('danger', reset($message) ?? 'Requête terminée'); } + if ($backUrl = $request->get('backUrl')) { + return $this->redirect($backUrl); + } + return $this->redirectToRoute('app_entry_show', ['id' => $entry->getId()]); } diff --git a/src/Repository/EntryRepository.php b/src/Repository/EntryRepository.php index 309ca7f..8b90a29 100644 --- a/src/Repository/EntryRepository.php +++ b/src/Repository/EntryRepository.php @@ -129,7 +129,7 @@ class EntryRepository extends ServiceEntityRepository return $this->createQueryBuilder('e') ->andWhere('e.lexicon = :lexicon') ->setParameter('lexicon', $lexicon) - ->andWhere('e.updatedAt >= :date') + ->andWhere('e.updatedAt >= :date AND e.updatedAt != e.createdAt') ->setParameter('date', $date) ->getQuery() ->getResult() diff --git a/templates/home.html.twig b/templates/home.html.twig index 743aeb4..9d43165 100644 --- a/templates/home.html.twig +++ b/templates/home.html.twig @@ -10,7 +10,7 @@ <div class="d-inline-block text-center" id="appLinksZone"> <i class="fa fa-gamepad fa-4x"></i> - <br>MagicWorld + <br>MagicWord </div> <div class="text-center"> @@ -37,7 +37,7 @@ {% for lexicon in app.user.myLexicons %} {% if lexicon.masterGroup %} <div class=" d-flex justify-content-between align-items-start py-2"> - <a href="{{ path('app_lexicon_show', {id: app.user.lexicon.id}) }}">{{ lexicon|badge }} {{ "Lexique du groupe"|trans }} « {{ lexicon }} »</a> + <a href="{{ path('app_lexicon_show', {id: lexicon.id}) }}">{{ lexicon|badge }} {{ "Lexique du groupe"|trans }} « {{ lexicon }} »</a> <span>{{ lexicon_manager.entriesNb(lexicon) }}</span> </div> {% endif %} @@ -82,7 +82,21 @@ <div class="col"> <h1 class="text-center">{{ "Bonjour"|trans }} {{ app.user }}</h1> - <h1 class="mt-5">{{ "Mot du jour"|trans }}</h1> + <div class="mt-5 d-flex justify-content-between align-items-center"> + <h1>{{ "Mot du jour"|trans }}</h1> + {% if entry %} + <div class="dropdown me-1"> + <a title="{{ "Ajouter à un lexique"|trans }}" href="#" data-bs-toggle="dropdown" aria-expanded="false"><i class="fa fa-2x fa-plus-circle text-success"></i></a> + <ul class="dropdown-menu"> + {% for lexicon in app.user.myLexicons %} + <li><a class="dropdown-item" href="{{ path('app_entry_copy', {id: entry.id, lexiconId: lexicon.id, backUrl: path('app_lexicon_show', {id: lexicon.id})}) }}"> + {{ "Copier le mot dans le lexique"|trans }} {{ lexicon }} + </a></li> + {% endfor %} + </ul> + </div> + {% endif %} + </div> <div class="card mt-3"> <div class="card-body bg-pink"> {% if entry %} -- GitLab