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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\Admin\Teamer\Availability;
|
||||
|
||||
use App\Entity\Teamer;
|
||||
use App\Service\Teamer\AvailabilityProcessor;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||
|
||||
class IndexController extends AbstractController
|
||||
{
|
||||
#[Route('/admin/teamer/availability/{uuid}', name: 'app_admin_teamer_availability')]
|
||||
#[IsGranted('ROLE_ADMINISTRATIVE')]
|
||||
public function index(Teamer $teamer): Response
|
||||
{
|
||||
$processor = new AvailabilityProcessor();
|
||||
$availabilities = $teamer->getAvailabilities()->toArray();
|
||||
$groupedAvailabilities = $processor->groupRecords($availabilities);
|
||||
|
||||
return $this->render('admin/teamer/availability/index.html.twig', [
|
||||
'teamer' => $teamer,
|
||||
'groupedAvailabilities' => $groupedAvailabilities,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user