feat: integrate with htmx
This commit is contained in:
@@ -5,13 +5,13 @@ namespace App\Controller\Admin\Application;
|
||||
use App\Entity\Application;
|
||||
use App\Event\ApplicationStatusEvent;
|
||||
use App\Form\ApplicationStatusType;
|
||||
use App\Model\AjaxModalResponseDto;
|
||||
use App\Htmx\HxRedirectResponse;
|
||||
use App\Model\ApplicationStatusDto;
|
||||
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;
|
||||
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
|
||||
@@ -28,12 +28,10 @@ class StatusController extends AbstractController
|
||||
#[Route('/admin/application/status/{uuid}', name: 'app_admin_application_status')]
|
||||
#[IsGranted('ROLE_ADMINISTRATIVE')]
|
||||
#[IsGranted('STATUS', subject: 'application')]
|
||||
public function index(Application $application, Request $request): JsonResponse
|
||||
public function index(Application $application, Request $request): Response
|
||||
{
|
||||
$response = new AjaxModalResponseDto();
|
||||
$formAction = $this->generateUrl('app_admin_application_status', ['uuid' => $application->getUuid()]);
|
||||
$statusDto = new ApplicationStatusDto($application);
|
||||
$form = $this->createForm(ApplicationStatusType::class, $statusDto, ['action' => $formAction, 'ajax_submit' => true]);
|
||||
$form = $this->createForm(ApplicationStatusType::class, $statusDto);
|
||||
|
||||
$form->handleRequest($request);
|
||||
|
||||
@@ -53,15 +51,13 @@ class StatusController extends AbstractController
|
||||
'teamer' => (string) $application->getTeamer(),
|
||||
]);
|
||||
|
||||
$response->setCloseAndRedirect($this->generateUrl('app_admin_assignment_detail', [
|
||||
return new HxRedirectResponse($this->generateUrl('app_admin_assignment_detail', [
|
||||
'uuid' => $application->getAssignment()->getUuid(),
|
||||
]));
|
||||
} else {
|
||||
$response->setContent($this->renderView('admin/application/status.html.twig', [
|
||||
'form' => $form,
|
||||
]));
|
||||
}
|
||||
|
||||
return $this->json($response);
|
||||
return $this->render('admin/application/modal_status.html.twig', [
|
||||
'form' => $form->createView(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user