feat: improved layout, removed htmx-boost for simplicity
This commit is contained in:
@@ -82,8 +82,6 @@ class EditController extends AbstractController
|
||||
|
||||
$form = $this->createForm(BookingType::class, $formData, [
|
||||
'attr' => ['novalidate' => 'novalidate'],
|
||||
'hx_post' => $this->generateUrl('app_booking_edit', ['id' => $id]),
|
||||
'hx_target' => '#myep',
|
||||
]);
|
||||
|
||||
$form->handleRequest($request);
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
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('/', name: 'app_index')]
|
||||
#[IsGranted('PUBLIC_ACCESS')]
|
||||
public function index(): Response
|
||||
{
|
||||
return $this->render('index/index.html.twig');
|
||||
}
|
||||
}
|
||||
@@ -34,8 +34,6 @@ class PersonalDataController extends AbstractController
|
||||
|
||||
$personalDataForm = $this->createForm(PersonalDataType::class, $personalData, [
|
||||
'attr' => ['novalidate' => 'novalidate'],
|
||||
'hx_post' => $this->generateUrl('app_personal_data'),
|
||||
'hx_target' => '#myep',
|
||||
]);
|
||||
$personalDataForm->handleRequest($request);
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
|
||||
|
||||
class SecurityController extends AbstractController
|
||||
{
|
||||
#[Route('/login', name: 'app_login')]
|
||||
#[Route('/', name: 'app_login')]
|
||||
#[IsGranted('PUBLIC_ACCESS')]
|
||||
public function login(AuthenticationUtils $authenticationUtils): Response
|
||||
{
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\EventListener;
|
||||
|
||||
use App\Htmx\HxRedirectResponse;
|
||||
use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Component\Security\Http\Event\LogoutEvent;
|
||||
|
||||
#[AsEventListener(event: LogoutEvent::class, method: 'onLogout')]
|
||||
class LogoutListener
|
||||
{
|
||||
public function __construct(private readonly UrlGeneratorInterface $urlGenerator)
|
||||
{
|
||||
}
|
||||
|
||||
public function onLogout(LogoutEvent $event): void
|
||||
{
|
||||
$event->setResponse(new HxRedirectResponse($this->urlGenerator->generate('app_index')));
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form\Extension;
|
||||
|
||||
use Symfony\Component\Form\AbstractTypeExtension;
|
||||
use Symfony\Component\Form\Extension\Core\Type\FormType;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\Form\FormView;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class HtmxSubmitExtension extends AbstractTypeExtension
|
||||
{
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'hx_post' => null,
|
||||
'hx_target' => '#htmx-modal',
|
||||
'hx_swap' => 'outerHTML',
|
||||
'hx_indicator' => '#loading-indicator',
|
||||
'hx_trigger' => null,
|
||||
'hx_select' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
public function buildView(FormView $view, FormInterface $form, array $options): void
|
||||
{
|
||||
if (null !== $options['hx_post']) {
|
||||
$attr = [
|
||||
'hx-post' => $options['hx_post'],
|
||||
'hx-target' => $options['hx_target'],
|
||||
'hx-swap' => $options['hx_swap'],
|
||||
];
|
||||
if (null !== $options['hx_indicator']) {
|
||||
$attr['hx-indicator'] = $options['hx_indicator'];
|
||||
}
|
||||
if (null !== $options['hx_trigger']) {
|
||||
$attr['hx-trigger'] = $options['hx_trigger'];
|
||||
}
|
||||
if (null !== $options['hx_select']) {
|
||||
$attr['hx-select'] = $options['hx_select'];
|
||||
}
|
||||
$view->vars['attr'] = array_merge($view->vars['attr'], $attr);
|
||||
}
|
||||
}
|
||||
|
||||
public static function getExtendedTypes(): iterable
|
||||
{
|
||||
return [FormType::class];
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Htmx;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class HxRedirectResponse extends Response
|
||||
{
|
||||
public function __construct(string $url)
|
||||
{
|
||||
return parent::__construct(null, Response::HTTP_OK, ['HX-Redirect' => $url]);
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Htmx;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class HxTriggerResponse extends Response
|
||||
{
|
||||
public function __construct(string $content, string $trigger)
|
||||
{
|
||||
return parent::__construct($content, Response::HTTP_OK, ['HX-Trigger' => $trigger]);
|
||||
}
|
||||
}
|
||||
@@ -24,12 +24,14 @@ class MenuBuilder
|
||||
'route' => 'app_personal_data',
|
||||
'linkAttributes' => [
|
||||
'title' => 'Persönliche Daten',
|
||||
'data-action' => 'loading#toggle',
|
||||
],
|
||||
]);
|
||||
$menu->addChild('Meine Buchungen', [
|
||||
'route' => 'app_bookings',
|
||||
'linkAttributes' => [
|
||||
'title' => 'Meine Buchungen',
|
||||
'data-action' => 'loading#toggle',
|
||||
],
|
||||
'extras' => [
|
||||
'routes' => [
|
||||
@@ -41,6 +43,7 @@ class MenuBuilder
|
||||
'route' => 'app_logout',
|
||||
'linkAttributes' => [
|
||||
'title' => 'Logout',
|
||||
'data-action' => 'loading#toggle',
|
||||
],
|
||||
]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user