improved duration and minute selector (#2264)
* do not close modal if form is dirty * deprecated TimesheetConfiguration * inject timezone in form types * cleanup usage of UserDateTimeFactory * allow to configure increment steps for minutes * use 15 minutes step for datetimepicker in project edit form * use rounding rules for increments in minute select for begin and end * allow duration in multi user and admin timesheet forms * make dropdown values configurable
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Configuration\SystemConfiguration;
|
||||
use App\Entity\MetaTableTypeInterface;
|
||||
use App\Entity\Tag;
|
||||
use App\Entity\Timesheet;
|
||||
@@ -28,7 +29,6 @@ use App\Repository\TagRepository;
|
||||
use App\Repository\TimesheetRepository;
|
||||
use App\Timesheet\TimesheetService;
|
||||
use App\Timesheet\TrackingMode\TrackingModeInterface;
|
||||
use App\Timesheet\TrackingModeService;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
@@ -41,10 +41,6 @@ abstract class TimesheetAbstractController extends AbstractController
|
||||
* @var TimesheetRepository
|
||||
*/
|
||||
protected $repository;
|
||||
/**
|
||||
* @var TrackingModeService
|
||||
*/
|
||||
protected $trackingModeService;
|
||||
/**
|
||||
* @var EventDispatcherInterface
|
||||
*/
|
||||
@@ -57,24 +53,28 @@ abstract class TimesheetAbstractController extends AbstractController
|
||||
* @var TimesheetService
|
||||
*/
|
||||
protected $service;
|
||||
/**
|
||||
* @var SystemConfiguration
|
||||
*/
|
||||
protected $configuration;
|
||||
|
||||
public function __construct(
|
||||
TimesheetRepository $repository,
|
||||
TrackingModeService $trackingModeService,
|
||||
EventDispatcherInterface $dispatcher,
|
||||
ServiceExport $exportService,
|
||||
TimesheetService $timesheetService
|
||||
TimesheetService $timesheetService,
|
||||
SystemConfiguration $configuration
|
||||
) {
|
||||
$this->repository = $repository;
|
||||
$this->trackingModeService = $trackingModeService;
|
||||
$this->dispatcher = $dispatcher;
|
||||
$this->exportService = $exportService;
|
||||
$this->service = $timesheetService;
|
||||
$this->configuration = $configuration;
|
||||
}
|
||||
|
||||
protected function getTrackingMode(): TrackingModeInterface
|
||||
{
|
||||
return $this->trackingModeService->getActiveMode();
|
||||
return $this->service->getActiveTrackingMode();
|
||||
}
|
||||
|
||||
protected function index($page, Request $request, string $renderTemplate, string $location): Response
|
||||
@@ -201,9 +201,7 @@ abstract class TimesheetAbstractController extends AbstractController
|
||||
}
|
||||
|
||||
$this->service->prepareNewTimesheet($entry, $request);
|
||||
|
||||
$mode = $this->getTrackingMode();
|
||||
$createForm = $this->getCreateForm($entry, $mode);
|
||||
$createForm = $this->getCreateForm($entry);
|
||||
$createForm->handleRequest($request);
|
||||
|
||||
if ($createForm->isSubmitted() && $createForm->isValid()) {
|
||||
@@ -440,8 +438,10 @@ abstract class TimesheetAbstractController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
protected function getCreateForm(Timesheet $entry, TrackingModeInterface $mode): FormInterface
|
||||
protected function getCreateForm(Timesheet $entry): FormInterface
|
||||
{
|
||||
$mode = $this->getTrackingMode();
|
||||
|
||||
return $this->createForm($this->getCreateFormClassName(), $entry, [
|
||||
'action' => $this->generateUrl($this->getCreateRoute()),
|
||||
'include_rate' => $this->isGranted('edit_rate', $entry),
|
||||
@@ -450,6 +450,10 @@ abstract class TimesheetAbstractController extends AbstractController
|
||||
'allow_begin_datetime' => $mode->canEditBegin(),
|
||||
'allow_end_datetime' => $mode->canEditEnd(),
|
||||
'allow_duration' => $mode->canEditDuration(),
|
||||
'duration_minutes' => $this->configuration->getTimesheetIncrementDuration(),
|
||||
'begin_minutes' => $this->configuration->getTimesheetIncrementBegin(),
|
||||
'end_minutes' => $this->configuration->getTimesheetIncrementEnd(),
|
||||
'timezone' => $this->getDateTimeFactory()->getTimezone(),
|
||||
'customer' => true,
|
||||
]);
|
||||
}
|
||||
@@ -474,6 +478,10 @@ abstract class TimesheetAbstractController extends AbstractController
|
||||
'allow_begin_datetime' => $mode->canEditBegin(),
|
||||
'allow_end_datetime' => $mode->canEditEnd(),
|
||||
'allow_duration' => $mode->canEditDuration(),
|
||||
'duration_minutes' => $this->configuration->getTimesheetIncrementDuration(),
|
||||
'begin_minutes' => $this->configuration->getTimesheetIncrementBegin(),
|
||||
'end_minutes' => $this->configuration->getTimesheetIncrementEnd(),
|
||||
'timezone' => $this->getDateTimeFactory()->getTimezone(),
|
||||
'customer' => true,
|
||||
]);
|
||||
}
|
||||
@@ -488,6 +496,7 @@ abstract class TimesheetAbstractController extends AbstractController
|
||||
'action' => $this->generateUrl($this->getTimesheetRoute(), [
|
||||
'page' => $query->getPage(),
|
||||
]),
|
||||
'timezone' => $this->getDateTimeFactory()->getTimezone()->getName(),
|
||||
'method' => 'GET',
|
||||
'include_user' => $this->includeUserInForms('toolbar'),
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user