diff --git a/src/Controller/Admin/System/StaffingRule/PreviewController.php b/src/Controller/Admin/System/StaffingRule/PreviewController.php index a9025ee..0cd17f7 100644 --- a/src/Controller/Admin/System/StaffingRule/PreviewController.php +++ b/src/Controller/Admin/System/StaffingRule/PreviewController.php @@ -4,20 +4,24 @@ namespace App\Controller\Admin\System\StaffingRule; use App\Service\Assignment\StaffingConfigurationException; use App\Service\Export\StaffingPreviewExporter; +use Knp\Component\Pager\PaginatorInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Security\Http\Attribute\IsGranted; class PreviewController extends AbstractController { - public function __construct(private readonly StaffingPreviewExporter $previewExporter) - { + public function __construct( + private readonly StaffingPreviewExporter $previewExporter, + private readonly PaginatorInterface $paginator, + ) { } #[Route('/admin/system/staffing-rule/preview', name: 'app_admin_system_staffing_rule_preview')] #[IsGranted('ROLE_TEAM_ADMIN')] - public function index(): Response + public function index(Request $request): Response { try { $rows = $this->previewExporter->rows(); @@ -27,8 +31,16 @@ class PreviewController extends AbstractController return $this->redirectToRoute('app_admin_system_staffing_rule_index'); } + // The candidates are a computed list, not a query: page the finished rows. The Excel + // export stays the full list. + $pagination = $this->paginator->paginate( + $rows, + $request->query->getInt('page', 1), + $request->query->getInt('limit', 50), + ); + return $this->render('admin/system/staffing_rule/preview.html.twig', [ - 'rows' => $rows, + 'pagination' => $pagination, ]); } } diff --git a/templates/admin/system/staffing_rule/preview.html.twig b/templates/admin/system/staffing_rule/preview.html.twig index d64ecb7..9e7987c 100644 --- a/templates/admin/system/staffing_rule/preview.html.twig +++ b/templates/admin/system/staffing_rule/preview.html.twig @@ -33,7 +33,7 @@
- {% for row in rows %} + {% for row in pagination %}