Feat: Implement availabilities

This commit is contained in:
Björn Fromme
2023-10-03 17:42:10 +02:00
parent cc9700a558
commit 25a016a02b
35 changed files with 827 additions and 422 deletions
@@ -4,11 +4,12 @@ namespace App\Controller\Admin\System\Fee;
use App\Entity\Fee;
use App\Form\FeeType;
use App\Model\AjaxModalResponseDto;
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\Annotation\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
@@ -22,10 +23,13 @@ class CreateController extends AbstractController
#[Route('/admin/system/fee/create', name: 'app_admin_system_fee_create')]
#[IsGranted('ROLE_ADMIN')]
public function index(Request $request): Response
public function index(Request $request): JsonResponse
{
$response = new AjaxModalResponseDto();
$action = $this->generateUrl('app_admin_system_fee_create');
$fee = new Fee();
$form = $this->createForm(FeeType::class, $fee);
$form = $this->createForm(FeeType::class, $fee, ['action' => $action, 'ajax_submit' => true]);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
@@ -37,11 +41,15 @@ class CreateController extends AbstractController
'fee' => $fee->getName(),
]);
return $this->redirectToRoute('app_admin_system_fee_index');
$redirectUrl = $this->generateUrl('app_admin_system_fee_index');
$response->setCloseAndRedirect($redirectUrl);
} else {
$content = $this->renderView('admin/system/fee/create.html.twig', [
'form' => $form
]);
$response->setContent($content);
}
return $this->render('admin/system/fee/create.html.twig', [
'form' => $form
]);
return $this->json($response);
}
}