added drag and drop for new records via calendar (#1962)

This commit is contained in:
Kevin Papst
2020-09-17 01:13:48 +02:00
committed by GitHub
parent 14b3de4300
commit 9ef32e75c5
82 changed files with 2808 additions and 385 deletions

View File

@@ -45,9 +45,11 @@ final class TimesheetFutureTimesValidator extends ConstraintValidator
return;
}
$now = new \DateTime('now', $timesheet->getBegin()->getTimezone());
// allow configured default rounding time + 1 minute - see #1295
$allowedDiff = ($this->configuration->getDefaultRoundingBegin() * 60) + 60;
if ((time() + $allowedDiff) < $timesheet->getBegin()->getTimestamp()) {
if (($now->getTimestamp() + $allowedDiff) < $timesheet->getBegin()->getTimestamp()) {
$this->context->buildViolation('The begin date cannot be in the future.')
->atPath('begin')
->setTranslationDomain('validators')

View File

@@ -47,6 +47,14 @@ final class TimesheetOverlappingValidator extends ConstraintValidator
throw new UnexpectedTypeException($timesheet, TimesheetEntity::class);
}
$begin = $timesheet->getBegin();
$end = $timesheet->getEnd();
// this case is handled in TimesheetValidator and should not raise a second validation
if ($begin !== null && $end !== null && $begin > $end) {
return;
}
if ($this->configuration->isAllowOverlappingRecords()) {
return;
}

View File

@@ -72,7 +72,10 @@ final class TimesheetValidator extends ConstraintValidator
*/
protected function validateBeginAndEnd(TimesheetEntity $timesheet, ExecutionContextInterface $context)
{
if (null === $timesheet->getBegin()) {
$begin = $timesheet->getBegin();
$end = $timesheet->getEnd();
if (null === $begin) {
$context->buildViolation('You must submit a begin date.')
->atPath('begin')
->setTranslationDomain('validators')
@@ -82,7 +85,7 @@ final class TimesheetValidator extends ConstraintValidator
return;
}
if (null !== $timesheet->getBegin() && null !== $timesheet->getEnd() && $timesheet->getEnd()->getTimestamp() < $timesheet->getBegin()->getTimestamp()) {
if (null !== $end && $begin > $end) {
$context->buildViolation('End date must not be earlier then start date.')
->atPath('end')
->setTranslationDomain('validators')