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:
@@ -143,6 +143,7 @@ class ExportController extends AbstractController
|
||||
'action' => $this->generateUrl('export', []),
|
||||
'include_user' => $this->isGranted('view_other_timesheet'),
|
||||
'method' => $method,
|
||||
'timezone' => $this->getDateTimeFactory()->getTimezone()->getName(),
|
||||
'attr' => [
|
||||
'id' => 'export-form'
|
||||
]
|
||||
|
||||
@@ -408,6 +408,7 @@ final class InvoiceController extends AbstractController
|
||||
'action' => $this->generateUrl('invoice', []),
|
||||
'method' => 'GET',
|
||||
'include_user' => $this->isGranted('view_other_timesheet'),
|
||||
'timezone' => $this->getDateTimeFactory()->getTimezone()->getName(),
|
||||
'attr' => [
|
||||
'id' => 'invoice-print-form'
|
||||
],
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Configuration\TimesheetConfiguration;
|
||||
use App\Configuration\SystemConfiguration;
|
||||
use App\Event\RecentActivityEvent;
|
||||
use App\Repository\TimesheetRepository;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
@@ -20,7 +20,7 @@ use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
|
||||
*/
|
||||
class LayoutController extends AbstractController
|
||||
{
|
||||
public function activeEntries(TimesheetRepository $repository, TimesheetConfiguration $configuration, EventDispatcherInterface $dispatcher): Response
|
||||
public function activeEntries(TimesheetRepository $repository, SystemConfiguration $configuration, EventDispatcherInterface $dispatcher): Response
|
||||
{
|
||||
$user = $this->getUser();
|
||||
$activeEntries = $repository->getActiveEntries($user);
|
||||
@@ -32,7 +32,7 @@ class LayoutController extends AbstractController
|
||||
'navbar/active-entries.html.twig',
|
||||
[
|
||||
'entries' => $recentActivity->getRecentActivities(),
|
||||
'soft_limit' => $configuration->getActiveEntriesSoftLimit(),
|
||||
'soft_limit' => $configuration->getTimesheetActiveEntriesSoftLimit(),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -523,7 +523,9 @@ final class ProjectController extends AbstractController
|
||||
'action' => $url,
|
||||
'method' => 'POST',
|
||||
'currency' => $currency,
|
||||
'include_budget' => $this->isGranted('budget', $project)
|
||||
'timezone' => $this->getDateTimeFactory()->getTimezone()->getName(),
|
||||
'include_budget' => $this->isGranted('budget', $project),
|
||||
'time_increment' => 15,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ use App\Form\SystemConfigurationForm;
|
||||
use App\Form\Type\DateTimeTextType;
|
||||
use App\Form\Type\DayTimeType;
|
||||
use App\Form\Type\LanguageType;
|
||||
use App\Form\Type\MinuteIncrementType;
|
||||
use App\Form\Type\RoundingModeType;
|
||||
use App\Form\Type\SkinType;
|
||||
use App\Form\Type\TrackingModeType;
|
||||
@@ -275,6 +276,21 @@ final class SystemConfigurationController extends AbstractController
|
||||
->setConstraints([
|
||||
new GreaterThanOrEqual(['value' => 1])
|
||||
]),
|
||||
(new Configuration())
|
||||
->setName('timesheet.time_increment')
|
||||
->setType(MinuteIncrementType::class)
|
||||
->setOptions(['deactivate' => false])
|
||||
->setTranslationDomain('system-configuration')
|
||||
->setConstraints([
|
||||
new GreaterThanOrEqual(['value' => 1])
|
||||
]),
|
||||
(new Configuration())
|
||||
->setName('timesheet.duration_increment')
|
||||
->setType(MinuteIncrementType::class)
|
||||
->setTranslationDomain('system-configuration')
|
||||
->setConstraints([
|
||||
new GreaterThanOrEqual(['value' => 0])
|
||||
]),
|
||||
]),
|
||||
(new SystemConfigurationModel())
|
||||
->setSection(SystemConfigurationModel::SECTION_ROUNDING)
|
||||
|
||||
@@ -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'),
|
||||
]);
|
||||
|
||||
@@ -20,7 +20,6 @@ use App\Repository\ActivityRepository;
|
||||
use App\Repository\ProjectRepository;
|
||||
use App\Repository\Query\TimesheetQuery;
|
||||
use App\Repository\TagRepository;
|
||||
use App\Timesheet\TrackingMode\TrackingModeInterface;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
@@ -101,8 +100,7 @@ class TimesheetTeamController extends TimesheetAbstractController
|
||||
$entry->setUser($this->getUser());
|
||||
$this->service->prepareNewTimesheet($entry, $request);
|
||||
|
||||
$mode = $this->getTrackingMode();
|
||||
$createForm = $this->getMultiUserCreateForm($entry, $mode);
|
||||
$createForm = $this->getMultiUserCreateForm($entry);
|
||||
$createForm->handleRequest($request);
|
||||
|
||||
if ($createForm->isSubmitted() && $createForm->isValid()) {
|
||||
@@ -150,8 +148,10 @@ class TimesheetTeamController extends TimesheetAbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
protected function getMultiUserCreateForm(MultiUserTimesheet $entry, TrackingModeInterface $mode): FormInterface
|
||||
protected function getMultiUserCreateForm(MultiUserTimesheet $entry): FormInterface
|
||||
{
|
||||
$mode = $this->getTrackingMode();
|
||||
|
||||
return $this->createForm(TimesheetMultiUserEditForm::class, $entry, [
|
||||
'action' => $this->generateUrl('admin_timesheet_create_multiuser'),
|
||||
'include_rate' => $this->isGranted('edit_rate', $entry),
|
||||
@@ -160,6 +160,10 @@ class TimesheetTeamController extends TimesheetAbstractController
|
||||
'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()->getName(),
|
||||
'customer' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user