export filtered timesheets without additional search form (#5234)

This commit is contained in:
Kevin Papst
2024-12-15 18:38:30 +01:00
committed by GitHub
parent 17a815e5a9
commit 21c031f2c8
33 changed files with 98 additions and 306 deletions

View File

@@ -10,9 +10,17 @@
namespace App\EventSubscriber\Actions;
use App\Event\PageActionsEvent;
use App\Export\ServiceExport;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
final class TimesheetsSubscriber extends AbstractActionsSubscriber
{
public function __construct(AuthorizationCheckerInterface $auth, UrlGeneratorInterface $urlGenerator, private readonly ServiceExport $serviceExport)
{
parent::__construct($auth, $urlGenerator);
}
public static function getActionName(): string
{
return 'timesheets';
@@ -25,7 +33,9 @@ final class TimesheetsSubscriber extends AbstractActionsSubscriber
}
if ($this->isGranted('export_own_timesheet')) {
$event->addAction('download', ['url' => $this->path('timesheet_export'), 'class' => 'modal-ajax-form', 'title' => 'export']);
foreach ($this->serviceExport->getTimesheetExporter() as $exporter) {
$event->addActionToSubmenu('export', $exporter->getId(), ['url' => $this->path('timesheet_export', ['exporter' => $exporter->getId()]), 'class' => 'toolbar-action', 'title' => 'button.' . $exporter->getId(), 'translation_domain' => 'messages']);
}
}
}
}

View File

@@ -10,9 +10,17 @@
namespace App\EventSubscriber\Actions;
use App\Event\PageActionsEvent;
use App\Export\ServiceExport;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
final class TimesheetsTeamSubscriber extends AbstractActionsSubscriber
{
public function __construct(AuthorizationCheckerInterface $auth, UrlGeneratorInterface $urlGenerator, private readonly ServiceExport $serviceExport)
{
parent::__construct($auth, $urlGenerator);
}
public static function getActionName(): string
{
return 'timesheets_team';
@@ -26,7 +34,9 @@ final class TimesheetsTeamSubscriber extends AbstractActionsSubscriber
}
if ($this->isGranted('export_other_timesheet')) {
$event->addAction('download', ['url' => $this->path('admin_timesheet_export'), 'class' => 'modal-ajax-form', 'title' => 'export']);
foreach ($this->serviceExport->getTimesheetExporter() as $exporter) {
$event->addActionToSubmenu('export', $exporter->getId(), ['url' => $this->path('admin_timesheet_export', ['exporter' => $exporter->getId()]), 'class' => 'toolbar-action', 'title' => 'button.' . $exporter->getId(), 'translation_domain' => 'messages']);
}
}
}
}