Layout of saved export page

This commit is contained in:
2025-04-14 10:59:31 +02:00
parent 9f12b42961
commit 3d9b9ea672
8 changed files with 143 additions and 61 deletions

View File

@@ -18,6 +18,7 @@ use Chill\MainBundle\Export\ExportInterface;
use Chill\MainBundle\Export\ExportManager;
use Chill\MainBundle\Export\GroupedExportInterface;
use Chill\MainBundle\Form\SavedExportType;
use Chill\MainBundle\Repository\ExportGenerationRepository;
use Chill\MainBundle\Repository\SavedExportRepositoryInterface;
use Chill\MainBundle\Security\Authorization\ExportGenerationVoter;
use Chill\MainBundle\Security\Authorization\SavedExportVoter;
@@ -46,6 +47,7 @@ final readonly class SavedExportController
private Security $security,
private TranslatorInterface $translator,
private UrlGeneratorInterface $urlGenerator,
private ExportGenerationRepository $exportGenerationRepository,
) {}
#[Route(path: '/{_locale}/exports/saved/{id}/delete', name: 'chill_main_export_saved_delete')]
@@ -172,7 +174,10 @@ final readonly class SavedExportController
throw new AccessDeniedHttpException();
}
$exports = $this->savedExportRepository->findByUser($user, ['title' => 'ASC']);
$exports = array_filter(
$this->savedExportRepository->findSharedWithUser($user, ['exportAlias' => 'ASC', 'title' => 'ASC']),
fn (SavedExport $savedExport): bool => $this->security->isGranted(SavedExportVoter::GENERATE, $savedExport),
);
// group by center
/** @var array<string, array{saved: SavedExport, export: ExportInterface}> $exportsGrouped */
@@ -189,12 +194,20 @@ final readonly class SavedExportController
ksort($exportsGrouped);
// get last executions
$lastExecutions = [];
foreach ($exports as $savedExport) {
$lastExecutions[$savedExport->getId()->toString()] = $this->exportGenerationRepository
->findExportGenerationBySavedExportAndUser($savedExport, $user, 5);
}
return new Response(
$this->templating->render(
'@ChillMain/SavedExport/index.html.twig',
[
'grouped_exports' => $exportsGrouped,
'total' => \count($exports),
'last_executions' => $lastExecutions,
],
),
);