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:
@@ -20,12 +20,18 @@ class Duration extends Regex
|
||||
public function __construct($options = null)
|
||||
{
|
||||
$patterns = [
|
||||
// decimal times (can be separated by comma or dot, depending on the locale)
|
||||
'[0-9]{1,}',
|
||||
'[0-9]{1,}[,.]{1}[0-9]{1,}',
|
||||
// ASP.NET style time spans - https://momentjs.com/docs/#/durations/
|
||||
'[0-9]{1,}:[0-9]{1,}:[0-9]{1,}',
|
||||
'[0-9]{1,}:[0-9]{1,}',
|
||||
'[0-9]{1,}[hmsHMS]{1}',
|
||||
'[0-9]{1,}[hmsHMS]{1}[0-9]{1,}[hmsHMS]{1}',
|
||||
'[0-9]{1,}[hmsHMS]{1}[0-9]{1,}[hmsHMS]{1}[0-9]{1,}[hmsHMS]{1}',
|
||||
// https://en.wikipedia.org/wiki/ISO_8601#Time_intervals
|
||||
'[0-9]{1,}[hHmMsS]{1}',
|
||||
'[0-9]{1,}[hH]{1}[0-9]{1,}[mM]{1}',
|
||||
'[0-9]{1,}[hHmM]{1}[0-9]{1,}[sS]{1}',
|
||||
'[0-9]{1,}[mM]{1}[0-9]{1,}[sS]{1}',
|
||||
'[0-9]{1,}[hH]{1}[0-9]{1,}[mM]{1}[0-9]{1,}[sS]{1}',
|
||||
];
|
||||
$options['pattern'] = '/^' . implode('$|^', $patterns) . '$/';
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
namespace App\Validator\Constraints;
|
||||
|
||||
use App\Configuration\TimesheetConfiguration;
|
||||
use App\Configuration\SystemConfiguration;
|
||||
use App\Entity\Timesheet as TimesheetEntity;
|
||||
use Symfony\Component\Validator\Constraint;
|
||||
use Symfony\Component\Validator\ConstraintValidator;
|
||||
@@ -18,11 +18,11 @@ use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
||||
final class TimesheetFutureTimesValidator extends ConstraintValidator
|
||||
{
|
||||
/**
|
||||
* @var TimesheetConfiguration
|
||||
* @var SystemConfiguration
|
||||
*/
|
||||
private $configuration;
|
||||
|
||||
public function __construct(TimesheetConfiguration $configuration)
|
||||
public function __construct(SystemConfiguration $configuration)
|
||||
{
|
||||
$this->configuration = $configuration;
|
||||
}
|
||||
@@ -41,14 +41,14 @@ final class TimesheetFutureTimesValidator extends ConstraintValidator
|
||||
throw new UnexpectedTypeException($timesheet, TimesheetEntity::class);
|
||||
}
|
||||
|
||||
if ($this->configuration->isAllowFutureTimes()) {
|
||||
if ($this->configuration->isTimesheetAllowFutureTimes()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$now = new \DateTime('now', $timesheet->getBegin()->getTimezone());
|
||||
|
||||
// allow configured default rounding time + 1 minute - see #1295
|
||||
$allowedDiff = ($this->configuration->getDefaultRoundingBegin() * 60) + 60;
|
||||
$allowedDiff = ($this->configuration->getTimesheetDefaultRoundingBegin() * 60) + 60;
|
||||
if (($now->getTimestamp() + $allowedDiff) < $timesheet->getBegin()->getTimestamp()) {
|
||||
$this->context->buildViolation('The begin date cannot be in the future.')
|
||||
->atPath('begin')
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
namespace App\Validator\Constraints;
|
||||
|
||||
use App\Configuration\TimesheetConfiguration;
|
||||
use App\Configuration\SystemConfiguration;
|
||||
use App\Entity\Timesheet as TimesheetEntity;
|
||||
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
||||
use Symfony\Component\Validator\Constraint;
|
||||
@@ -23,11 +23,11 @@ final class TimesheetLockdownValidator extends ConstraintValidator
|
||||
*/
|
||||
private $auth;
|
||||
/**
|
||||
* @var TimesheetConfiguration
|
||||
* @var SystemConfiguration
|
||||
*/
|
||||
private $configuration;
|
||||
|
||||
public function __construct(AuthorizationCheckerInterface $auth, TimesheetConfiguration $configuration)
|
||||
public function __construct(AuthorizationCheckerInterface $auth, SystemConfiguration $configuration)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
$this->configuration = $configuration;
|
||||
@@ -53,14 +53,14 @@ final class TimesheetLockdownValidator extends ConstraintValidator
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$this->configuration->isLockdownActive()) {
|
||||
if (!$this->configuration->isTimesheetLockdownActive()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$lockedStart = $this->configuration->getLockdownPeriodStart();
|
||||
$lockedEnd = $this->configuration->getLockdownPeriodEnd();
|
||||
$lockedStart = $this->configuration->getTimesheetLockdownPeriodStart();
|
||||
$lockedEnd = $this->configuration->getTimesheetLockdownPeriodEnd();
|
||||
|
||||
$gracePeriod = $this->configuration->getLockdownGracePeriod();
|
||||
$gracePeriod = $this->configuration->getTimesheetLockdownGracePeriod();
|
||||
if (!empty($gracePeriod)) {
|
||||
$gracePeriod = $gracePeriod . ' ';
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
namespace App\Validator\Constraints;
|
||||
|
||||
use App\Configuration\TimesheetConfiguration;
|
||||
use App\Configuration\SystemConfiguration;
|
||||
use App\Entity\Timesheet as TimesheetEntity;
|
||||
use App\Repository\TimesheetRepository;
|
||||
use Symfony\Component\Validator\Constraint;
|
||||
@@ -19,7 +19,7 @@ use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
||||
final class TimesheetOverlappingValidator extends ConstraintValidator
|
||||
{
|
||||
/**
|
||||
* @var TimesheetConfiguration
|
||||
* @var SystemConfiguration
|
||||
*/
|
||||
private $configuration;
|
||||
/**
|
||||
@@ -27,7 +27,7 @@ final class TimesheetOverlappingValidator extends ConstraintValidator
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
public function __construct(TimesheetConfiguration $configuration, TimesheetRepository $repository)
|
||||
public function __construct(SystemConfiguration $configuration, TimesheetRepository $repository)
|
||||
{
|
||||
$this->configuration = $configuration;
|
||||
$this->repository = $repository;
|
||||
@@ -55,7 +55,7 @@ final class TimesheetOverlappingValidator extends ConstraintValidator
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->configuration->isAllowOverlappingRecords()) {
|
||||
if ($this->configuration->isTimesheetAllowOverlappingRecords()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user