added search modal for timesheet export (#2728)
This commit is contained in:
@@ -1,39 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Kimai time-tracking app.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
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;
|
||||
|
||||
abstract class AbstractTimesheetsSubscriber extends AbstractActionsSubscriber
|
||||
{
|
||||
private $serviceExport;
|
||||
|
||||
public function __construct(AuthorizationCheckerInterface $security, UrlGeneratorInterface $urlGenerator, ServiceExport $serviceExport)
|
||||
{
|
||||
parent::__construct($security, $urlGenerator);
|
||||
$this->serviceExport = $serviceExport;
|
||||
}
|
||||
|
||||
protected function addExporter(PageActionsEvent $event, string $routeExport): void
|
||||
{
|
||||
$allExporter = $this->serviceExport->getTimesheetExporter();
|
||||
if (\count($allExporter) === 1) {
|
||||
$event->addAction('download', ['url' => $this->path($routeExport, ['exporter' => $allExporter[0]->getId()]), 'class' => 'toolbar-action']);
|
||||
} else {
|
||||
foreach ($allExporter as $exporter) {
|
||||
$id = $exporter->getId();
|
||||
$event->addActionToSubmenu('download', 'exporter.' . $id, ['title' => 'button.' . $id, 'url' => $this->path($routeExport, ['exporter' => $id]), 'class' => 'toolbar-action exporter-' . $id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,7 @@ class ReportingSubscriber extends AbstractActionsSubscriber
|
||||
if ($report instanceof Report) {
|
||||
$subMenu = $report->getReportIcon();
|
||||
}
|
||||
$event->addActionToSubmenu($subMenu, $report->getId(), ['title' => $report->getLabel(), 'translation_domain' => 'reporting', 'url' => $this->path($report->getRoute()), 'class' => 'toolbar-action report-' . $report->getId()]);
|
||||
$event->addActionToSubmenu($subMenu, $report->getId(), ['title' => $report->getLabel(), 'translation_domain' => 'reporting', 'url' => $this->path($report->getRoute()), 'class' => 'report-' . $report->getId()]);
|
||||
}
|
||||
|
||||
$event->addHelp($this->documentationLink('reporting.html'));
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace App\EventSubscriber\Actions;
|
||||
|
||||
use App\Event\PageActionsEvent;
|
||||
|
||||
class TimesheetsSubscriber extends AbstractTimesheetsSubscriber
|
||||
class TimesheetsSubscriber extends AbstractActionsSubscriber
|
||||
{
|
||||
public static function getActionName(): string
|
||||
{
|
||||
@@ -24,7 +24,7 @@ class TimesheetsSubscriber extends AbstractTimesheetsSubscriber
|
||||
$event->addColumnToggle('#modal_timesheet');
|
||||
|
||||
if ($this->isGranted('export_own_timesheet')) {
|
||||
$this->addExporter($event, 'timesheet_export');
|
||||
$event->addAction('download', ['url' => $this->path('timesheet_export'), 'class' => 'toolbar-action modal-ajax-form']);
|
||||
}
|
||||
|
||||
if ($this->isGranted('create_own_timesheet')) {
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace App\EventSubscriber\Actions;
|
||||
|
||||
use App\Event\PageActionsEvent;
|
||||
|
||||
class TimesheetsTeamSubscriber extends AbstractTimesheetsSubscriber
|
||||
class TimesheetsTeamSubscriber extends AbstractActionsSubscriber
|
||||
{
|
||||
public static function getActionName(): string
|
||||
{
|
||||
@@ -24,7 +24,7 @@ class TimesheetsTeamSubscriber extends AbstractTimesheetsSubscriber
|
||||
$event->addColumnToggle('#modal_timesheet_admin');
|
||||
|
||||
if ($this->isGranted('export_other_timesheet')) {
|
||||
$this->addExporter($event, 'admin_timesheet_export');
|
||||
$event->addAction('download', ['url' => $this->path('admin_timesheet_export'), 'class' => 'toolbar-action modal-ajax-form']);
|
||||
}
|
||||
|
||||
if ($this->isGranted('create_other_timesheet')) {
|
||||
|
||||
Reference in New Issue
Block a user