From 68ea0a1086051bf4f645daa19c4b1a46c610463e Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Tue, 4 Jan 2022 12:07:37 +0100 Subject: [PATCH] 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 %}