feat: integrate with htmx

This commit is contained in:
Björn Fromme
2024-02-07 10:15:59 +01:00
parent 4d1799ca49
commit 1e572606f8
154 changed files with 1447 additions and 1461 deletions
@@ -4,12 +4,12 @@ namespace App\Controller\Admin\System\Fee;
use App\Entity\Fee;
use App\Form\FeeType;
use App\Model\AjaxModalResponseDto;
use App\Htmx\HxRedirectResponse;
use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface;
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;
@@ -23,12 +23,9 @@ class EditController extends AbstractController
#[Route('/admin/system/fee/edit/{id}', name: 'app_admin_system_fee_edit')]
#[IsGranted('ROLE_ADMIN')]
public function index(Fee $fee, Request $request): JsonResponse
public function index(Fee $fee, Request $request): Response
{
$response = new AjaxModalResponseDto();
$action = $this->generateUrl('app_admin_system_fee_edit', ['id' => $fee->getId()]);
$form = $this->createForm(FeeType::class, $fee, ['action' => $action, 'ajax_submit' => true]);
$form = $this->createForm(FeeType::class, $fee);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
@@ -40,15 +37,11 @@ class EditController extends AbstractController
'fee_name' => $fee->getNameInternal() ?? $fee->getName(),
]);
$redirectUrl = $this->generateUrl('app_admin_system_fee_index');
$response->setCloseAndRedirect($redirectUrl);
} else {
$content = $this->renderView('admin/system/fee/form.html.twig', [
'form' => $form
]);
$response->setContent($content);
return new HxRedirectResponse($this->generateUrl('app_admin_system_fee_index'));
}
return $this->json($response);
return $this->render('admin/system/fee/modal_edit.html.twig', [
'form' => $form->createView(),
]);
}
}