feat: move teamer status editing to admins
addresses #8699yr1eh
This commit is contained in:
@@ -4,26 +4,66 @@ namespace App\Controller\Admin\Teamer;
|
||||
|
||||
use App\Entity\Teamer;
|
||||
use App\Repository\TrainingRepository;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
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 SkillsController extends AbstractController
|
||||
{
|
||||
public function __construct(private readonly TrainingRepository $trainingRepository)
|
||||
{
|
||||
public function __construct(
|
||||
private readonly TrainingRepository $trainingRepository,
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
private readonly LoggerInterface $logger,
|
||||
) {
|
||||
}
|
||||
|
||||
#[Route('/admin/teamer/skills/{uuid}', name: 'app_admin_teamer_skills')]
|
||||
#[IsGranted('ROLE_ADMIN')]
|
||||
public function index(Teamer $teamer): Response
|
||||
public function index(Teamer $teamer, Request $request): Response
|
||||
{
|
||||
$trainings = $this->trainingRepository->getList();
|
||||
|
||||
$form = $this->createStatusForm($teamer);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->addFlash('success', 'Der Status wurde aktualisiert');
|
||||
|
||||
$this->logger->info('Update teamer status to '.$teamer->getStatus(), [
|
||||
'teamer' => $teamer->getFullName(),
|
||||
]);
|
||||
|
||||
return $this->redirectToRoute('app_admin_teamer_skills', [
|
||||
'uuid' => $teamer->getUuid(),
|
||||
]);
|
||||
}
|
||||
|
||||
return $this->render('admin/teamer/skills.html.twig', [
|
||||
'teamer' => $teamer,
|
||||
'trainings' => $trainings,
|
||||
'form' => $form->createView(),
|
||||
]);
|
||||
}
|
||||
|
||||
private function createStatusForm(Teamer $teamer): FormInterface
|
||||
{
|
||||
return $this
|
||||
->createFormBuilder($teamer)
|
||||
->add('status', ChoiceType::class, [
|
||||
'label' => 'Status',
|
||||
'choices' => [
|
||||
'Neuteamer' => Teamer::STATUS_NEW,
|
||||
'Bestandsteamer' => Teamer::STATUS_EXISTING,
|
||||
],
|
||||
])
|
||||
->getForm();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,13 +61,6 @@ class TeamerJobProfileType extends AbstractType
|
||||
'expanded' => true,
|
||||
'multiple' => true,
|
||||
])
|
||||
->add('status', ChoiceType::class, [
|
||||
'label' => 'Status',
|
||||
'choices' => [
|
||||
'Neuteamer' => Teamer::STATUS_NEW,
|
||||
'Bestandsteamer' => Teamer::STATUS_EXISTING,
|
||||
],
|
||||
])
|
||||
->add('remarks', TextareaType::class, [
|
||||
'label' => 'Wünsche/Anmerkungen',
|
||||
'required' => false,
|
||||
|
||||
@@ -266,7 +266,7 @@ class AdminMenuBuilder extends AbstractMenuBuilder
|
||||
'title' => 'Stammdaten & Foto',
|
||||
],
|
||||
]);
|
||||
$menu->addChild('Jobprofile & Skills', [
|
||||
$menu->addChild('Jobprofile, Skills & Status', [
|
||||
'route' => 'app_admin_teamer_skills',
|
||||
'routeParameters' => $this->getDefaultRouteParameters('uuid'),
|
||||
'linkAttributes' => [
|
||||
|
||||
Reference in New Issue
Block a user