feat: additional assignment agnostic teamer feedback by admins
This commit is contained in:
1 parent
82ff3bdf23
commit
3e908f03cb
9 files changed
+371
-8
No files matched your search
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\Admin\Autocomplete;
|
||||
|
||||
use App\Repository\TeamerRepository;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||
|
||||
class TeamerController extends AbstractController
|
||||
{
|
||||
public function __construct(private readonly TeamerRepository $teamerRepository)
|
||||
{}
|
||||
|
||||
#[Route('/admin/autocomplete/teamer', name: 'app_admin_autocomplete_teamer')]
|
||||
#[IsGranted('ROLE_ADMINISTRATIVE')]
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
try {
|
||||
$query = json_decode($request->getContent(), true, 512, JSON_THROW_ON_ERROR);
|
||||
$queryString = $query['search'];
|
||||
} catch (\JsonException $e) {
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
|
||||
$dates = $this->teamerRepository->getAutocompletionData($queryString);
|
||||
|
||||
return $this->json($dates);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\Admin\Feedback;
|
||||
|
||||
use App\Entity\Feedback;
|
||||
use App\Entity\User;
|
||||
use App\Form\AdminFeedbackType;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||
|
||||
class ProvideController extends AbstractController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
private readonly LoggerInterface $logger
|
||||
) {
|
||||
}
|
||||
|
||||
#[Route('/admin/feedback/provide', name: 'app_admin_feedback_provide')]
|
||||
#[IsGranted('ROLE_ADMIN')]
|
||||
public function index(Request $request): Response
|
||||
{
|
||||
$form = $this->getFeedbackForm();
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$feedback = $form->getData();
|
||||
|
||||
$this->entityManager->persist($feedback);
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->logger->info('Provided feedback', [
|
||||
'teamer' => $feedback->getTeamer()->getUuid(),
|
||||
]);
|
||||
|
||||
return $this->redirectToRoute('app_administrative_feedback_index');
|
||||
}
|
||||
|
||||
return $this->render('admin/feedback/provide.html.twig', [
|
||||
'form' => $form->createView(),
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/admin/feedback/provide/form', name: 'app_admin_feedback_provide_form')]
|
||||
#[IsGranted('ROLE_ADMIN')]
|
||||
public function form(Request $request): Response
|
||||
{
|
||||
$form = $this->getFeedbackForm();
|
||||
$form->handleRequest($request);
|
||||
|
||||
return $this->renderBlock('admin/feedback/provide.html.twig', 'feedback_form', [
|
||||
'form' => $form->createView(),
|
||||
]);
|
||||
}
|
||||
|
||||
private function getFeedbackForm(): FormInterface
|
||||
{
|
||||
/** @var User $user */
|
||||
$user = $this->getUser();
|
||||
$feedback = new Feedback($user);
|
||||
|
||||
return $this->createForm(AdminFeedbackType::class, $feedback);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user