feat: integrate with htmx
This commit is contained in:
1 parent
4d1799ca49
commit
1e572606f8
154 files changed
+1447
-1461
No files matched your search
@@ -5,6 +5,7 @@ namespace App\Controller\Admin\Teamer\Availability;
|
||||
use App\Controller\Traits\ReturnUrlTrait;
|
||||
use App\Entity\Availability;
|
||||
use App\Entity\Teamer;
|
||||
use App\Htmx\HxRedirectResponse;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Bridge\Doctrine\Attribute\MapEntity;
|
||||
@@ -33,24 +34,30 @@ class DeleteController extends AbstractController
|
||||
Availability $availability,
|
||||
Request $request
|
||||
): Response {
|
||||
if (null === $availability->getOwner()) {
|
||||
$teamer->removeAvailability($availability);
|
||||
} elseif ($teamer === $availability->getOwner()) {
|
||||
$this->entityManager->remove($availability);
|
||||
if (true === $request->isMethod('POST')) {
|
||||
if (null === $availability->getOwner()) {
|
||||
$teamer->removeAvailability($availability);
|
||||
} elseif ($teamer === $availability->getOwner()) {
|
||||
$this->entityManager->remove($availability);
|
||||
}
|
||||
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->addFlash('success', 'Der Zeitraum wurde entfernt/gelöscht.');
|
||||
$this->logger->info('Delete teamer availability', [
|
||||
'availability_id' => $availability->getId(),
|
||||
'availability_range' => (string) $availability,
|
||||
'teamer_id' => $teamer->getId(),
|
||||
'teamer_name' => (string) $teamer,
|
||||
]);
|
||||
|
||||
$redirectUrl = $this->getReturnUrl($request, 'app_admin_teamer_profile', ['uuid' => $teamer->getUuid()]);
|
||||
|
||||
return new HxRedirectResponse($redirectUrl);
|
||||
}
|
||||
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->addFlash('success', 'Der Zeitraum wurde entfernt/gelöscht.');
|
||||
$this->logger->info('Delete teamer availability', [
|
||||
'availability_id' => $availability->getId(),
|
||||
'availability_range' => (string) $availability,
|
||||
'teamer_id' => $teamer->getId(),
|
||||
'teamer_name' => (string) $teamer,
|
||||
return $this->render('admin/teamer/availability/modal_delete.html.twig', [
|
||||
'availability' => $availability,
|
||||
]);
|
||||
|
||||
$redirectUrl = $this->getReturnUrl($request, 'app_admin_teamer_profile', ['uuid' => $teamer->getUuid()]);
|
||||
|
||||
return $this->redirect($redirectUrl);
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\Admin\Teamer;
|
||||
namespace App\Controller\Admin\Teamer\Availability;
|
||||
|
||||
use App\Entity\Teamer;
|
||||
use App\Service\Teamer\AvailabilityProcessor;
|
||||
@@ -9,7 +9,7 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||
|
||||
class AvailabilityController extends AbstractController
|
||||
class IndexController extends AbstractController
|
||||
{
|
||||
#[Route('/admin/teamer/availability/{uuid}', name: 'app_admin_teamer_availability')]
|
||||
#[IsGranted('ROLE_ADMINISTRATIVE')]
|
||||
@@ -19,7 +19,7 @@ class AvailabilityController extends AbstractController
|
||||
$availabilities = $teamer->getAvailabilities()->toArray();
|
||||
$groupedAvailabilities = $processor->groupRecords($availabilities);
|
||||
|
||||
return $this->render('admin/teamer/availability.html.twig', [
|
||||
return $this->render('admin/teamer/availability/index.html.twig', [
|
||||
'teamer' => $teamer,
|
||||
'groupedAvailabilities' => $groupedAvailabilities,
|
||||
]);
|
||||
@@ -3,10 +3,9 @@
|
||||
namespace App\Controller\Admin\Teamer;
|
||||
|
||||
use App\Entity\Teamer;
|
||||
use App\Model\AjaxModalResponseDto;
|
||||
use App\Repository\DispositionRepository;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
|
||||
class InfoController extends AbstractController
|
||||
@@ -15,16 +14,13 @@ class InfoController extends AbstractController
|
||||
{}
|
||||
|
||||
#[Route('/admin/teamer/info/{uuid}', name: 'app_admin_teamer_info')]
|
||||
public function index(Teamer $teamer): JsonResponse
|
||||
public function index(Teamer $teamer): Response
|
||||
{
|
||||
$recentDispositions = $this->dispositionRepository->findRecentDispositionsByTeamer($teamer);
|
||||
|
||||
$response = new AjaxModalResponseDto();
|
||||
$response->setContent($this->renderView('admin/teamer/info.html.twig', [
|
||||
return $this->render('admin/teamer/modal_info.html.twig', [
|
||||
'teamer' => $teamer,
|
||||
'recentDispositions' => $recentDispositions,
|
||||
]));
|
||||
|
||||
return $this->json($response);
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -6,14 +6,13 @@ use App\Entity\Teamer;
|
||||
use App\Entity\Training;
|
||||
use App\Entity\TrainingAttendance;
|
||||
use App\Form\AbbreviatedDateType;
|
||||
use App\Form\FeeType;
|
||||
use App\Model\AjaxModalResponseDto;
|
||||
use App\Htmx\HxRedirectResponse;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Bridge\Doctrine\Attribute\MapEntity;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||
|
||||
@@ -33,13 +32,7 @@ class CreateController extends AbstractController
|
||||
#[MapEntity(mapping: ['teamer_id' => 'id'])]
|
||||
Teamer $teamer,
|
||||
Request $request
|
||||
): JsonResponse {
|
||||
$response = new AjaxModalResponseDto();
|
||||
$action = $this->generateUrl('app_admin_teamer_skills_training_attendance_create', [
|
||||
'training_id' => $training->getId(),
|
||||
'teamer_id' => $teamer->getId(),
|
||||
]);
|
||||
|
||||
): Response {
|
||||
$attendance = new TrainingAttendance();
|
||||
$attendance
|
||||
->setTeamer($teamer)
|
||||
@@ -47,7 +40,7 @@ class CreateController extends AbstractController
|
||||
;
|
||||
|
||||
$form = $this
|
||||
->createFormBuilder($attendance, ['action' => $action, 'ajax_submit' => true])
|
||||
->createFormBuilder($attendance)
|
||||
->add('date', AbbreviatedDateType::class, [
|
||||
'label' => 'Datum',
|
||||
])
|
||||
@@ -69,14 +62,12 @@ class CreateController extends AbstractController
|
||||
]);
|
||||
|
||||
$redirectUrl = $this->generateUrl('app_admin_teamer_skills', ['uuid' => $teamer->getUuid()]);
|
||||
$response->setCloseAndRedirect($redirectUrl);
|
||||
} else {
|
||||
$content = $this->renderView('admin/teamer/training_attendance/create.html.twig', [
|
||||
'form' => $form
|
||||
]);
|
||||
$response->setContent($content);
|
||||
|
||||
return new HxRedirectResponse($redirectUrl);
|
||||
}
|
||||
|
||||
return $this->json($response);
|
||||
return $this->render('admin/teamer/training_attendance/modal_create.html.twig', [
|
||||
'form' => $form->createView(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,11 @@
|
||||
namespace App\Controller\Admin\Teamer\TrainingAttendance;
|
||||
|
||||
use App\Entity\TrainingAttendance;
|
||||
use App\Htmx\HxRedirectResponse;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||
@@ -18,24 +20,32 @@ class DeleteController extends AbstractController
|
||||
) {
|
||||
}
|
||||
|
||||
#[Route('/admin/teamer/skills/training-attendance/delete/{uuid}', name: 'app_admin_teamer_skills_training_attendance_delete', methods: ['POST'])]
|
||||
#[Route('/admin/teamer/skills/training-attendance/delete/{uuid}', name: 'app_admin_teamer_skills_training_attendance_delete')]
|
||||
#[IsGranted('ROLE_ADMIN')]
|
||||
public function index(TrainingAttendance $attendance): Response
|
||||
public function index(TrainingAttendance $attendance, Request $request): Response
|
||||
{
|
||||
$teamer = $attendance->getTeamer();
|
||||
if (true === $request->isMethod('POST')) {
|
||||
$teamer = $attendance->getTeamer();
|
||||
|
||||
$this->entityManager->remove($attendance);
|
||||
$this->entityManager->flush();
|
||||
$this->entityManager->remove($attendance);
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->addFlash('success', 'Die Teilnahme an der Fortbilundg wurde gelöscht');
|
||||
$this->logger->info('Delete training attendance', [
|
||||
'attendance_id' => $attendance->getId(),
|
||||
'teamer_id' => $teamer->getId(),
|
||||
'teamer_name' => (string) $teamer,
|
||||
'training_id' => $attendance->getTraining()->getId(),
|
||||
'training_name' => $attendance->getTraining()->getName(),
|
||||
$this->addFlash('success', 'Die Teilnahme an der Fortbilundg wurde gelöscht');
|
||||
$this->logger->info('Delete training attendance', [
|
||||
'attendance_id' => $attendance->getId(),
|
||||
'teamer_id' => $teamer->getId(),
|
||||
'teamer_name' => (string) $teamer,
|
||||
'training_id' => $attendance->getTraining()->getId(),
|
||||
'training_name' => $attendance->getTraining()->getName(),
|
||||
]);
|
||||
|
||||
return new HxRedirectResponse($this->generateUrl('app_admin_teamer_skills', [
|
||||
'uuid' => $teamer->getUuid(),
|
||||
]));
|
||||
}
|
||||
|
||||
return $this->render('admin/teamer/training_attendance/modal_delete.html.twig', [
|
||||
'attendance' => $attendance,
|
||||
]);
|
||||
|
||||
return $this->redirectToRoute('app_admin_teamer_skills', ['uuid' => $teamer->getUuid()]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user