diff --git a/src/Controller/Admin/Feedback/ApproveController.php b/src/Controller/Admin/Feedback/ApproveController.php new file mode 100644 index 0000000..caf607c --- /dev/null +++ b/src/Controller/Admin/Feedback/ApproveController.php @@ -0,0 +1,53 @@ +generateUrl('app_admin_feedback_approve', ['uuid' => $feedback->getUuid()]); + $form = $this->createForm(FeedbackApproveType::class, $feedback, ['action' => $action, 'ajax_submit' => true]); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $feedback->setStatus(Feedback::STATUS_PUBLISHED); + $this->entityManager->flush(); + + $this->addFlash('success', 'Das Feedback wurde freigegeben'); + $this->logger->info('Approve feedback', [ + 'feedback_uuid' => $feedback->getUuid(), + ]); + + $returnUrl = $this->generateUrl('app_admin_index'); + $response->setCloseAndRedirect($returnUrl); + } else { + $response->setContent($this->renderView('admin/feedback/approve.html.twig', [ + 'feedback' => $feedback, + 'form' => $form->createView(), + ])); + } + + return $this->json($response); + } +} \ No newline at end of file diff --git a/src/Form/FeedbackApproveType.php b/src/Form/FeedbackApproveType.php new file mode 100644 index 0000000..4bc8179 --- /dev/null +++ b/src/Form/FeedbackApproveType.php @@ -0,0 +1,39 @@ +add('comment', TextareaType::class, [ + 'label' => 'Kommentar (öffentlich)', + 'required' => false, + 'attr' => [ + 'rows' => 5, + ], + ]) + ->add('commentInternal', TextareaType::class, [ + 'label' => 'Kommentar (intern)', + 'required' => false, + 'attr' => [ + 'rows' => 5, + ], + ]) + ; + } + + public function configureOptions(OptionsResolver $resolver): void + { + $resolver->setDefaults([ + 'data_class' => Feedback::class, + ]); + } +} \ No newline at end of file diff --git a/templates/admin/feedback/approve.html.twig b/templates/admin/feedback/approve.html.twig new file mode 100644 index 0000000..79ac795 --- /dev/null +++ b/templates/admin/feedback/approve.html.twig @@ -0,0 +1,10 @@ +{{ form_start(form) }} +
+ {{ form_row(form.comment) }} + {{ form_row(form.commentInternal) }} +
+ +{{ form_rest(form) }} +{{ form_end(form) }} \ No newline at end of file diff --git a/templates/admin/index.html.twig b/templates/admin/index.html.twig index 7780974..6cf7128 100644 --- a/templates/admin/index.html.twig +++ b/templates/admin/index.html.twig @@ -120,14 +120,20 @@