support multiple teamleads in each team (#2702)

* fix jumping avatars
* fix line-break after color dot for long names
This commit is contained in:
Kevin Papst
2021-08-07 18:05:41 +02:00
committed by GitHub
parent e9986c92d6
commit b2d3272151
101 changed files with 1952 additions and 649 deletions

View File

@@ -0,0 +1,33 @@
<?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\Validator\Constraints;
use Doctrine\Common\Annotations\Annotation\Target;
use Symfony\Component\Validator\Constraint;
/**
* @Annotation
* @Target({"CLASS", "PROPERTY", "METHOD", "ANNOTATION"})
*/
class Team extends Constraint
{
public const MISSING_TEAMLEAD = 'kimai-team-001';
protected static $errorNames = [
self::MISSING_TEAMLEAD => 'At least one team leader must be assigned to the team.',
];
public $message = 'The team has invalid settings.';
public function getTargets()
{
return self::CLASS_CONSTRAINT;
}
}

View File

@@ -0,0 +1,41 @@
<?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\Validator\Constraints;
use App\Entity\Team as TeamEntity;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
class TeamValidator extends ConstraintValidator
{
/**
* @param TeamEntity $value
* @param Constraint $constraint
*/
public function validate($value, Constraint $constraint)
{
if (!($constraint instanceof Team)) {
throw new UnexpectedTypeException($constraint, Team::class);
}
if (!\is_object($value) || !($value instanceof TeamEntity)) {
return;
}
if (!$value->hasTeamleads()) {
$this->context->buildViolation(Team::getErrorName(Team::MISSING_TEAMLEAD))
->atPath('teamleads')
->setTranslationDomain('validators')
->setCode(Team::MISSING_TEAMLEAD)
->addViolation();
}
}
}