From 5fead5b467be07492e1a009319e666b6100bb728 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Tue, 4 Jan 2022 11:18:56 +0100 Subject: [PATCH 1/5] fix translation, disable throw exception --- .../Controller/AccompanyingCourseCommentController.php | 7 ++++--- .../views/AccompanyingCourse/comment_list.html.twig | 2 +- src/Bundle/ChillPersonBundle/translations/messages.fr.yml | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseCommentController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseCommentController.php index 65e83cdbc..c71be5f94 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseCommentController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseCommentController.php @@ -55,9 +55,10 @@ class AccompanyingCourseCommentController extends AbstractController } } - if (null === $editForm) { - throw new NotFoundHttpException('Unable to find an edit form.'); - } + dump($editForm); + //if (null === $editForm) { + // throw new NotFoundHttpException('Unable to find an edit form.'); + //} if ($request->getMethod() === Request::METHOD_POST) { $currentForm = $editForm->handleRequest($request); diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/comment_list.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/comment_list.html.twig index 9fc9a1c77..a45aef6bb 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/comment_list.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/comment_list.html.twig @@ -20,7 +20,7 @@
  • {% endif %} diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index f461e5bec..c05500205 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -412,6 +412,7 @@ fix it: Compléter Accompanying Course Comment: Commentaire Accompanying Course Comment list: Commentaires du parcours pinned: épinglé +Pin comment: Épingler Post a new comment: Poster un nouveau commentaire Write a new comment: Écrire un nouveau commentaire Edit a comment: Modifier le commentaire From 68ea0a1086051bf4f645daa19c4b1a46c610463e Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Tue, 4 Jan 2022 12:07:37 +0100 Subject: [PATCH 2/5] wip delete comment --- .../AccompanyingCourseCommentController.php | 38 ++++++++++++++++++- .../confirm_delete_comment.html.twig | 16 ++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/confirm_delete_comment.html.twig diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseCommentController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseCommentController.php index c71be5f94..55bb936b0 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseCommentController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseCommentController.php @@ -16,6 +16,7 @@ use Chill\PersonBundle\Form\AccompanyingCourseCommentType; use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Form\Extension\Core\Type\HiddenType; +use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\FormInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -27,7 +28,7 @@ use function array_key_exists; class AccompanyingCourseCommentController extends AbstractController { /** - * Comments page of Accompanying Course section. + * Page of comments in Accompanying Course section. * * @Route("/{_locale}/parcours/{accompanying_period_id}/comments", name="chill_person_accompanying_period_comment_list") * @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"}) @@ -101,4 +102,39 @@ class AccompanyingCourseCommentController extends AbstractController return $form; } + + ////////////// building + /** + * Delete an existing comment + * + * @Route( + * "/{_locale}/parcours/{accompanying_period_id}/comment/{comment_id}/delete", + * name="chill_person_accompanying_period_comment_delete" + * ) + * @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"}) + * @ParamConverter("comment", options={"id": "comment_id"}) + */ + public function deleteAction(AccompanyingPeriod $accompanyingCourse, AccompanyingPeriod\Comment $comment, Request $request) + { + $form = $this->createDeleteForm($comment->getId(), $accompanyingCourse); + + return $this->render('@ChillPerson/AccompanyingCourse/confirm_delete_comment.html.twig', [ + 'comment' => $comment, + 'delete_form' => $form->createView(), + 'accompanyingCourse' => $accompanyingCourse, + ]); + } + + private function createDeleteForm(int $id, ?AccompanyingPeriod $accompanyingCourse): FormInterface + { + $form = $this->createForm($type); + + return $this->createFormBuilder() + ->setAction($this->generateUrl('chill_person_accompanying_period_comment_delete', $params)) + ->setMethod('DELETE') + ->add('submit', SubmitType::class, ['label' => 'Delete']) + ->getForm(); + } + + //// end } diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/confirm_delete_comment.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/confirm_delete_comment.html.twig new file mode 100644 index 000000000..fd5259c70 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/confirm_delete_comment.html.twig @@ -0,0 +1,16 @@ +{% extends "@ChillPerson/Person/layout.html.twig" %} + +{% set person = activity.person %} + +{% block title 'Remove comment'|trans %} + +{% block personcontent %} + {{ include('@ChillMain/Util/confirmation_template.html.twig', + { + 'title' : 'Remove comment'|trans, + 'confirm_question' : 'Are you sure you want to remove comment ?'|trans, + 'cancel_route' : 'chill_activity_activity_list', + 'cancel_parameters' : { 'person_id' : activity.person.id, 'id' : activity.id }, + 'form' : delete_form + } ) }} +{% endblock %} From a54cc70fd63ffa326db6b24e5a954ae7ed297629 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Fri, 7 Jan 2022 12:34:14 +0100 Subject: [PATCH 3/5] temporary disable previous commit --- .../AccompanyingCourseCommentController.php | 69 ++++++++++--------- .../confirm_delete_comment.html.twig | 4 ++ 2 files changed, 39 insertions(+), 34 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseCommentController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseCommentController.php index 55bb936b0..c0481c854 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseCommentController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseCommentController.php @@ -103,38 +103,39 @@ class AccompanyingCourseCommentController extends AbstractController return $form; } - ////////////// building - /** - * Delete an existing comment - * - * @Route( - * "/{_locale}/parcours/{accompanying_period_id}/comment/{comment_id}/delete", - * name="chill_person_accompanying_period_comment_delete" - * ) - * @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"}) - * @ParamConverter("comment", options={"id": "comment_id"}) - */ - public function deleteAction(AccompanyingPeriod $accompanyingCourse, AccompanyingPeriod\Comment $comment, Request $request) - { - $form = $this->createDeleteForm($comment->getId(), $accompanyingCourse); - - return $this->render('@ChillPerson/AccompanyingCourse/confirm_delete_comment.html.twig', [ - 'comment' => $comment, - 'delete_form' => $form->createView(), - 'accompanyingCourse' => $accompanyingCourse, - ]); - } - - private function createDeleteForm(int $id, ?AccompanyingPeriod $accompanyingCourse): FormInterface - { - $form = $this->createForm($type); - - return $this->createFormBuilder() - ->setAction($this->generateUrl('chill_person_accompanying_period_comment_delete', $params)) - ->setMethod('DELETE') - ->add('submit', SubmitType::class, ['label' => 'Delete']) - ->getForm(); - } - - //// end +////////////// building +/// +// /** +// * Delete an existing comment +// * +// * @Route( +// * "/{_locale}/parcours/{accompanying_period_id}/comment/{comment_id}/delete", +// * name="chill_person_accompanying_period_comment_delete" +// * ) +// * @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"}) +// * @ParamConverter("comment", options={"id": "comment_id"}) +// */ +// public function deleteAction(AccompanyingPeriod $accompanyingCourse, AccompanyingPeriod\Comment $comment, Request $request) +// { +// $form = $this->createDeleteForm($comment->getId(), $accompanyingCourse); +// +// return $this->render('@ChillPerson/AccompanyingCourse/confirm_delete_comment.html.twig', [ +// 'comment' => $comment, +// 'delete_form' => $form->createView(), +// 'accompanyingCourse' => $accompanyingCourse, +// ]); +// } +// +// private function createDeleteForm(int $id, ?AccompanyingPeriod $accompanyingCourse): FormInterface +// { +// $form = $this->createForm($type); +// +// return $this->createFormBuilder() +// ->setAction($this->generateUrl('chill_person_accompanying_period_comment_delete', $params)) +// ->setMethod('DELETE') +// ->add('submit', SubmitType::class, ['label' => 'Delete']) +// ->getForm(); +// } +// +//// end } diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/confirm_delete_comment.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/confirm_delete_comment.html.twig index fd5259c70..ecef5e271 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/confirm_delete_comment.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/confirm_delete_comment.html.twig @@ -1,3 +1,5 @@ +{# WIP + {% extends "@ChillPerson/Person/layout.html.twig" %} {% set person = activity.person %} @@ -14,3 +16,5 @@ 'form' : delete_form } ) }} {% endblock %} + +#} From be4b8a94f050562aca0ce1037fa3edc66e344b46 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Fri, 7 Jan 2022 12:35:01 +0100 Subject: [PATCH 4/5] AccompanyingCourse comments: move and rename files --- .../Controller/AccompanyingCourseCommentController.php | 4 ++-- .../confirm_delete.html.twig} | 0 .../{comment_list.html.twig => Comment/index.html.twig} | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/{confirm_delete_comment.html.twig => Comment/confirm_delete.html.twig} (100%) rename src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/{comment_list.html.twig => Comment/index.html.twig} (100%) diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseCommentController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseCommentController.php index c0481c854..06f0aa2b0 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseCommentController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseCommentController.php @@ -84,7 +84,7 @@ class AccompanyingCourseCommentController extends AbstractController ]); } - return $this->render('@ChillPerson/AccompanyingCourse/comment_list.html.twig', [ + return $this->render('@ChillPerson/AccompanyingCourse/Comment/index.html.twig', [ 'accompanyingCourse' => $accompanyingCourse, 'form' => $form->createView(), 'edit_form' => null !== $editForm ? $editForm->createView() : null, @@ -119,7 +119,7 @@ class AccompanyingCourseCommentController extends AbstractController // { // $form = $this->createDeleteForm($comment->getId(), $accompanyingCourse); // -// return $this->render('@ChillPerson/AccompanyingCourse/confirm_delete_comment.html.twig', [ +// return $this->render('@ChillPerson/AccompanyingCourse/Comment/confirm_delete.html.twig', [ // 'comment' => $comment, // 'delete_form' => $form->createView(), // 'accompanyingCourse' => $accompanyingCourse, diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/confirm_delete_comment.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/Comment/confirm_delete.html.twig similarity index 100% rename from src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/confirm_delete_comment.html.twig rename to src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/Comment/confirm_delete.html.twig diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/comment_list.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/Comment/index.html.twig similarity index 100% rename from src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/comment_list.html.twig rename to src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/Comment/index.html.twig From c60d46c68b24a33361793ca58cea50d45af4fedd Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Fri, 7 Jan 2022 12:51:03 +0100 Subject: [PATCH 5/5] put macro show_comment in a separate template --- .../Comment/index.html.twig | 41 ++----------------- .../Comment/macro_showItem.html.twig | 36 ++++++++++++++++ 2 files changed, 39 insertions(+), 38 deletions(-) create mode 100644 src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/Comment/macro_showItem.html.twig 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 a45aef6bb..56dda187e 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/Comment/index.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/Comment/index.html.twig @@ -4,42 +4,7 @@ {{ 'Accompanying Course Comment list'|trans }} {% endblock %} -{% macro show_comment(comment, options) %} -
    -
    -
    - {% if options.pinned is defined %} - - {% endif %} - - {{ 'by'|trans }}{{ comment.creator }}{{ ', ' ~ 'on'|trans ~ ' ' ~ comment.createdAt|format_date('long') }}
    - {{ 'Last updated on'|trans ~ ' ' ~ comment.updatedAt|format_datetime('long', 'short') }} -
    -
      - {% if options.pinned is not defined %} -
    • - -
    • - {% endif %} -
    • - -
    • -
    • - -
    • -
    -
    -
    -
    {{ comment.content|chill_markdown_to_html }}
    -
    -
    -{% endmacro %} +{% import '@ChillPerson/AccompanyingCourse/Comment/macro_showItem.html.twig' as macro %} {% macro form_comment(type, form) %} {% if type == 'edit' %} @@ -73,14 +38,14 @@ {% if commentEditId == accompanyingCourse.pinnedComment.id %} {{ _self.form_comment('edit', edit_form) }} {% else %} - {{ _self.show_comment(accompanyingCourse.pinnedComment, {'pinned': 'true'}) }} + {{ macro.show_comment(accompanyingCourse.pinnedComment, {'pinned': 'true'}) }} {% endif %} {% endif %} {% for c in accompanyingCourse.comments %} {% if commentEditId == c.id %} {{ _self.form_comment('edit', edit_form) }} {% else %} - {{ _self.show_comment(c) }} + {{ macro.show_comment(c) }} {% endif %} {% endfor %} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/Comment/macro_showItem.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/Comment/macro_showItem.html.twig new file mode 100644 index 000000000..82309300e --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/Comment/macro_showItem.html.twig @@ -0,0 +1,36 @@ +{% macro show_comment(comment, options) %} +
    +
    +
    + {% if options.pinned is defined %} + + {% endif %} + + {{ 'by'|trans }}{{ comment.creator }}{{ ', ' ~ 'on'|trans ~ ' ' ~ comment.createdAt|format_date('long') }}
    + {{ 'Last updated on'|trans ~ ' ' ~ comment.updatedAt|format_datetime('long', 'short') }} +
    +
      + {% if options.pinned is not defined %} +
    • + +
    • + {% endif %} +
    • + +
    • +
    • + +
    • +
    +
    +
    +
    {{ comment.content|chill_markdown_to_html }}
    +
    +
    +{% endmacro %}