feat: paginate the staffing matrix preview

This commit is contained in:
fromme committed 2026-10-16 10:05:42 +02:00
1 parent c7e0ad67e6
commit d159cb212c
3 files changed
+36 -5

No files matched your search

@@ -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,
]);
}
}