diff --git a/public/assets/css/app.css b/public/assets/css/app.css index 4116d92289934a8735ad358ac43a6eee84c30a5f..7a13821c8e60bc048ec2a764135f9980a7d19eb6 100644 --- a/public/assets/css/app.css +++ b/public/assets/css/app.css @@ -167,6 +167,12 @@ table.label-table > tbody > tr > td { .bg-definition { background-color: #D6EADA; } +.bg-pink { + background-color: #FDF6F6; +} +.bg-dark-pink { + background-color: #FFE4E4; +} .badge.badge-milestone { line-height: 1.3; padding-top: 0; diff --git a/public/assets/images/library.png b/public/assets/images/library.png deleted file mode 100644 index 4b3b13543b8b1abb4eb9ebc5ebc99fb1a61ff1d6..0000000000000000000000000000000000000000 Binary files a/public/assets/images/library.png and /dev/null differ diff --git a/public/assets/js/app.js b/public/assets/js/app.js index d45bd65801db991972cc3f8b27d078033d2ea6e7..6713536ac5f81c33be40335af7c226e37defbf94 100644 --- a/public/assets/js/app.js +++ b/public/assets/js/app.js @@ -376,16 +376,14 @@ function initializeAjaxLinks() { } function initializeSearchHeadwords() { - // cliqk sur search => ajax pour get url entry_show dan sle bon lexique - $form = $('#searchHeadwordsForm'); $form.on('submit', function (e) { e.preventDefault(); - var $overlay = $('#overlay').show(); + if (!$('[name="searchHeadwordBox"]').val()) {return;} var $appModal = $('#bootstrap-modal'); - var search = $('#searchHeadwordBox').val(); var action = $form.attr('action'); var url = action + (action.indexOf('?') >= 0 ? '&' : '?') + $form.serialize(); + var $overlay = $('#overlay').show(); $.ajax({ type: 'GET', @@ -404,14 +402,7 @@ function initializeSearchHeadwords() { }, error: function (jqXHR, textStatus, errorThrown) { console.log(jqXHR.responseText, textStatus, errorThrown); - // $wordCreationConfirmationLink = $('headwordConfirmCreation'); - // $wordCreationConfirmationLink.data('url', $wordCreationConfirmationLink.data('url') + '?' + search); - // $wordCreationConfirmationLink.click(); - // $overlay.hide(); } }) }); - // si pas présnete => modal-form ou confirm-dialog pour demander création dans Agora - - } \ No newline at end of file diff --git a/src/Controller/HeadwordController.php b/src/Controller/HeadwordController.php index 01bccbe52bacfc8343cf9d668005b4bc84206747..703852074268ea34e069b040404d08459395b4b5 100644 --- a/src/Controller/HeadwordController.php +++ b/src/Controller/HeadwordController.php @@ -41,7 +41,7 @@ class HeadwordController extends AppBaseController */ public function search(Request $request): Response { - $search = $request->get('searchHeadwordBox'); + $search = trim($request->get('searchHeadwordBox')); $orderedLexicons = array_merge($this->getUser()->getMyLexicons(), [ $this->getZeroLexicon($this->getLanguage()), $this->getNewWordsLexicon($this->getLanguage()), diff --git a/src/Controller/IndexController.php b/src/Controller/IndexController.php index 03eebcd03422297b19844a5e094e71bf231cb22c..d0a445f1ef9db8fde834894a2e26ced648d82330 100644 --- a/src/Controller/IndexController.php +++ b/src/Controller/IndexController.php @@ -21,7 +21,13 @@ class IndexController extends AppBaseController */ public function index(WiktionaryManager $wiktionaryManager): Response { - return $this->render('home.html.twig', []); + $allEntries = $this->getZeroLexicon($this->getLanguage())->getEntries()->toArray(); + shuffle($allEntries); + $todayEntry = reset($allEntries); + + return $this->render('home.html.twig', [ + 'entry' => $todayEntry + ]); } /** diff --git a/src/Repository/LabelRepository.php b/src/Repository/LabelRepository.php index 4bcd25dbd0acc4d21e52cb533a145217c97fe54c..9d731f82d4d9dce85cbb2f09cd770384d78059de 100644 --- a/src/Repository/LabelRepository.php +++ b/src/Repository/LabelRepository.php @@ -87,7 +87,9 @@ class LabelRepository extends ServiceEntityRepository ->innerJoin('l.labelVisibilities', 'lv') ->andWhere('lv.user = :user') ->andWhere('lv.lexicon = :lexicon') + ->andWhere('l.category != :milestone OR l.user = :user') ->setParameter('user', $user) + ->setParameter('milestone', Label::LABEL_CATEGORY_MILESTONE) ->setParameter('lexicon', $lexicon) ->orderBy('l.category', 'ASC') ->addOrderBy('l.master', 'ASC') @@ -112,6 +114,8 @@ class LabelRepository extends ServiceEntityRepository { $qb = $this->createQueryBuilder('l') ->andWhere('l.master != :personal OR l.user = :user') + ->andWhere('l.category != :milestone OR l.user = :user') + ->setParameter('milestone', Label::LABEL_CATEGORY_MILESTONE) ->setParameter('personal', Label::MASTER_PERSONAL) ->setParameter('user', $user) ->orderBy('l.createdAt', 'DESC') diff --git a/src/Security/Voter/LabelVoter.php b/src/Security/Voter/LabelVoter.php index cd40bf91a44f5830e674a63af007ddf2cdc94cb3..31248e4297b05700368cd1793ddce3f105bf343f 100644 --- a/src/Security/Voter/LabelVoter.php +++ b/src/Security/Voter/LabelVoter.php @@ -55,8 +55,10 @@ class LabelVoter extends Voter private function canView(Label $label, User $user): bool { - // On ne voit que ses propres labels milestone - if ($label->isMilestone() && $label->getUser() === $user) { + // On ne voit que ses propres labels milestone ou ceux de ses groupes + if ($label->isMilestone() && + ($label->getUser() === $user || ($label->getGroup() && $label->getGroup()->getGroupMembershipFor($user)) ) + ) { return true; } diff --git a/templates/entry/_entryAttributes.html.twig b/templates/entry/_entryAttributes.html.twig new file mode 100644 index 0000000000000000000000000000000000000000..8edfe82c5a942f1c58d55a7daa9735c6252ccaf4 --- /dev/null +++ b/templates/entry/_entryAttributes.html.twig @@ -0,0 +1 @@ +<h3>{{ entry }}</h3> \ No newline at end of file diff --git a/templates/entry/show.html.twig b/templates/entry/show.html.twig index 9307b96a0a5a8335be04ee1ff643dcada7d48da1..9fb7e70596d544dc5aee9623bf32f9ca9caef53c 100644 --- a/templates/entry/show.html.twig +++ b/templates/entry/show.html.twig @@ -9,10 +9,16 @@ <div class="row justify-content-center m-lg-5 m-sm-3"> <div class="col-md-12"> - <h1 class=""> - {% if entry.lexicon.newWords %} - <a href="{{ path('app_lexicon_new_words', {id: entry.lexicon.id}) }}" class="btn btn-dark"><i class="bi bi-arrow-90deg-left"></i></a> - {% else %} + {% if entry.lexicon.newWords %} + <h1> + <a href="{{ path('app_lexicon_new_words', {id: entry.lexicon.id}) }}"> + {{ entry.lexicon|badgeXl }} {{ "Agora Des Néologismes"|trans }}</a> + </h1> + <h1 class="mt-5"> + {{ entry|capitalize }} + </h1> + {% else %} + <h1> {% if not wiktionnaryLexicon %} <a href="{{ path('app_lexicon_show', {id: entry.lexicon.id}) }}" class="btn btn-dark"><i class="bi bi-arrow-90deg-left"></i></a> {% endif %} @@ -23,8 +29,8 @@ class="ajax-link" data-method="GET" data-url="{{ path('app_headword_toggle_known', {id: entry.headword.id, userId: app.user.id, lexiconId: entry.lexicon.id}) }}"> {% if known %}<i class="fa fa-circle text-success"></i>{% else %}<i class="fa fa-circle text-warning"></i>{% endif %} </a> - {% endif %} - </h1> + </h1> + {% endif %} {% if not entry.lexicon.newWords %} {% include "entry/_lexiconsTabs.html.twig" %} diff --git a/templates/home.html.twig b/templates/home.html.twig index ff0755c6f8c5b88ab465ff66111376b14ec2726b..7128250d1a0d2ea8fd40d683332afb437a71676f 100644 --- a/templates/home.html.twig +++ b/templates/home.html.twig @@ -13,9 +13,17 @@ <br>MagicWorld </div> + <div class="text-center"> + {% if app.user.picture %} + <p><img src="{{ path('user_picture') }}" style="max-width: 120px; max-height: 120px;"></p> + {% else %} + <p>{{ app.user|badge }}</p> + {% endif %} + </div> + <div class="row align-items-start"> - <div class="col mt-5"> + <div class="col"> <h1>{{ "Mes lexiques"|trans }}</h1> <div class="card mt-3"> @@ -69,11 +77,19 @@ </div> - <div class="col"> - One of three columns + <div class="col text-center"> + <h1>{{ "Bonjour"|trans }} {{ app.user }}</h1> + + <h1 class="mt-5">{{ "Mot du jour"|trans }}</h1> + <div class="card mt-3"> + <div class="card-body bg-pink"> + {% include "entry/_entryAttributes.html.twig" %} + </div> + </div> </div> - <div class="col"> - One of three columns + + <div class="col text-center"> + <img src="{{ asset('assets/images/library.jpg') }}" style="width: 100%"> </div> </div> diff --git a/templates/label/show.html.twig b/templates/label/show.html.twig index 35ab752eaef2eff46d877a7231ddabc17985c151..96bff2bf5da0a818c591ca6e63a14e2c118c9673 100644 --- a/templates/label/show.html.twig +++ b/templates/label/show.html.twig @@ -105,9 +105,13 @@ {# "value" est utilisé par Symfo quand on soumet le form. "data-headword-id" est utilisé par la vue chooseLabel pour injecter du json dans le sliens ajax #} <input class="me-2" type="checkbox" name="form[selected_headwords][]" value="{{ headword.id }}" id="form_selected_headwords_{{ headword.id }}"/> - <a href="{{ path('app_entry_show', {id: entryZero.id}) }}"> - {{ headword.value }} - </a> + {% if entryZero %} + <a href="{{ path('app_entry_show', {id: entryZero.id}) }}"> + {{ headword.value }} + </a> + {% else %} + {{ headword.value }}{# On ne devrait jamais afficher ça, ça veut dire que le mot n'est pas dans le lexique zéro (par ex un mot de l'agora qui aurait le label) ##} + {% endif %} </td> {% for lexicon in app.user.myLexicons %} diff --git a/templates/lexicon/showNewWords.html.twig b/templates/lexicon/showNewWords.html.twig index c11f2cd8158f35f62c4a0d19ed8a9b26e53e762b..ec8234b15f69de88717d129418cc141cf9bf8f29 100644 --- a/templates/lexicon/showNewWords.html.twig +++ b/templates/lexicon/showNewWords.html.twig @@ -53,7 +53,11 @@ {% for entry in entries %} {# @var entry \App\Entity\Entry #} <tr> - <td>{{ entry }}</td> + <td> + <a href="{{ path('app_entry_show', {id: entry.id}) }}"> + {{ entry }} + </a> + </td> <td>{{ entry.createdAt|date('d/m/Y') }}</td> <td>{{ entry.createdBy }}</td> <td>