diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseCommentController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseCommentController.php index be6bcab07..3a77434d2 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseCommentController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseCommentController.php @@ -84,7 +84,7 @@ class AccompanyingCourseCommentController extends AbstractController } if (isset($commentEdited)) { - $this->denyAccessUnlessGranted(AccompanyingPeriodCommentVoter::EDIT, $commentEdited); + $this->denyAccessUnlessGranted(AccompanyingPeriodVoter::EDIT, $commentEdited->getAccompanyingPeriod()); } else { throw new LogicException('at this step, commentEdited should be set'); } @@ -135,7 +135,7 @@ class AccompanyingCourseCommentController extends AbstractController */ public function deleteAction(AccompanyingPeriod\Comment $comment, Request $request): Response { - $this->denyAccessUnlessGranted(AccompanyingPeriodCommentVoter::DELETE, $comment); + $this->denyAccessUnlessGranted(AccompanyingPeriodVoter::EDIT, $comment->getAccompanyingPeriod()); $form = $this->createForm(FormType::class, []); $form->add('submit', SubmitType::class, ['label' => 'Confirm']); @@ -186,6 +186,24 @@ class AccompanyingCourseCommentController extends AbstractController ]); } + /** + * @Route("/{_locale}/parcours/comment/{id}/unpin", name="chill_person_accompanying_period_comment_unpin") + */ + public function unpinComment(AccompanyingPeriod\Comment $comment): Response + { + $this->denyAccessUnlessGranted(AccompanyingPeriodVoter::EDIT, $comment->getAccompanyingPeriod()); + + $comment->getAccompanyingPeriod()->setPinnedComment(null); + + $this->getDoctrine()->getManager()->flush(); + + $this->addFlash('success', $this->translator->trans('accompanying_course.comment is unpinned')); + + return $this->redirectToRoute('chill_person_accompanying_period_comment_list', [ + 'accompanying_period_id' => $comment->getAccompanyingPeriod()->getId(), + ]); + } + private function createCommentForm(AccompanyingPeriod\Comment $comment, string $step): FormInterface { return $this->formFactory->createNamed($step, AccompanyingCourseCommentType::class, $comment); diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/Comment/index.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/Comment/index.html.twig index d5ece68a9..47238fa9d 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/Comment/index.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/Comment/index.html.twig @@ -8,6 +8,17 @@ {% macro recordAction(comment, isPinned) %} {% if isPinned is defined and isPinned == true %} +
  • +
    + +
    +
  • {% else %}
  • @@ -17,7 +28,7 @@
  • {% endif %} - {% if is_granted('CHILL_PERSON_ACCOMPANYING_PERIOD_COMMENT_EDIT', comment) %} + {% if is_granted('CHILL_PERSON_ACCOMPANYING_PERIOD_UPDATE', comment.accompanyingPeriod) %}
  • {% endif %} - {% if is_granted('CHILL_PERSON_ACCOMPANYING_PERIOD_COMMENT_DELETE', comment) %} + {% if is_granted('CHILL_PERSON_ACCOMPANYING_PERIOD_UPDATE', comment.accompanyingPeriod) %}
  • diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 2a4077e1c..985804f6c 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -465,12 +465,14 @@ fix it: Compléter accompanying_course: administrative_location: Localisation administrative comment is pinned: Le commentaire est épinglé + comment is unpinned: Le commentaire est désépinglé # Accompanying Course comments Accompanying Course Comment: Commentaire Accompanying Course Comment list: Commentaires du parcours pinned: épinglé Pin comment: Épingler +Unpin comment: Désépingler Post a new comment: Poster un nouveau commentaire Write a new comment: Écrire un nouveau commentaire Edit a comment: Modifier le commentaire