feat: integrate with htmx

This commit is contained in:
Björn Fromme committed 2024-02-07 10:15:59 +01:00
1 parent 4d1799ca49
commit 1e572606f8
154 files changed
+1447 -1461

No files matched your search

@@ -5,14 +5,14 @@ namespace App\Controller\Admin\Document;
use App\Entity\Upload;
use App\Event\DocumentRejectedEvent;
use App\Form\DocumentCheckType;
use App\Model\AjaxModalResponseDto;
use App\Htmx\HxRedirectResponse;
use App\Model\DocumentCheckDto;
use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\DependencyInjection\Attribute\Target;
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;
use Symfony\Component\Workflow\WorkflowInterface;
@@ -32,20 +32,10 @@ class CheckController extends AbstractController
#[Route('/admin/document/check/{uuid}', name: 'app_admin_document_check')]
#[IsGranted('ROLE_ADMINISTRATIVE')]
#[IsGranted('CHECK', subject: 'document')]
public function index(Upload $document, Request $request): JsonResponse
public function index(Upload $document, Request $request): Response
{
$response = new AjaxModalResponseDto();
$formData = new DocumentCheckDto($document);
$formAction = $this->generateUrl('app_admin_document_check', ['uuid' => $document->getUuid()]);
$form = $this->createForm(
DocumentCheckType::class,
$formData,
[
'action' => $formAction,
'ajax_submit' => true,
'document_type' => $document->getType(),
]
);
$form = $this->createForm(DocumentCheckType::class, $formData, ['document_type' => $document->getType()]);
$form->handleRequest($request);
@@ -75,16 +65,13 @@ class CheckController extends AbstractController
]);
}
$returnUrl = $this->generateUrl('app_admin_document_index');
$response->setCloseAndRedirect($returnUrl);
} else {
$response->setContent($this->renderView('admin/document/check.html.twig', [
'document' => $document,
'form' => $form,
]));
return new HxRedirectResponse($this->generateUrl('app_admin_document_index'));
}
return $this->json($response);
return $this->render('admin/document/modal_check.html.twig', [
'document' => $document,
'form' => $form->createView(),
]);
}
private function rejectDocument(Upload $document, string $comment = null): void