Skip to content

Commit 9716802

Browse files
Show label or external ID when set in jury clarification recipient dropdown.
1 parent 706b7bd commit 9716802

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

webapp/src/Form/Type/JuryClarificationType.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use App\Entity\Team;
77
use App\Service\ConfigurationService;
88
use App\Service\DOMJudgeService;
9+
use App\Service\EventLogService;
910
use Doctrine\ORM\EntityManagerInterface;
1011
use Symfony\Component\Form\AbstractType;
1112
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
@@ -22,6 +23,7 @@ public function __construct(
2223
private readonly EntityManagerInterface $em,
2324
private readonly ConfigurationService $config,
2425
private readonly DOMJudgeService $dj,
26+
private readonly EventLogService $eventLogService,
2527
) {}
2628

2729
public function buildForm(FormBuilderInterface $builder, array $options): void
@@ -33,12 +35,12 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
3335

3436
$limitToTeam = $options['limit_to_team'] ?? null;
3537
if ($limitToTeam) {
36-
$recipientOptions[sprintf("%s (t%s)", $limitToTeam->getEffectiveName(), $limitToTeam->getTeamid())] = $limitToTeam->getTeamid();
38+
$recipientOptions[$this->getTeamLabel($limitToTeam)] = $limitToTeam->getTeamid();
3739
} else {
3840
/** @var Team|null $limitToTeam */
3941
$teams = $this->em->getRepository(Team::class)->findAll();
4042
foreach ($teams as $team) {
41-
$recipientOptions[sprintf("%s (t%s)", $team->getEffectiveName(), $team->getTeamid())] = $team->getTeamid();
43+
$recipientOptions[$this->getTeamLabel($team)] = $team->getTeamid();
4244
}
4345
}
4446

@@ -110,4 +112,17 @@ public function configureOptions(OptionsResolver $resolver): void
110112
{
111113
$resolver->setDefault('limit_to_team', null);
112114
}
115+
116+
private function getTeamLabel(Team $team): string
117+
{
118+
if ($team->getLabel()) {
119+
return sprintf('%s (%s)', $team->getEffectiveName(), $team->getLabel());
120+
}
121+
122+
if ($this->eventLogService->externalIdFieldForEntity($team)) {
123+
return sprintf('%s (%s)', $team->getEffectiveName(), $team->getExternalId());
124+
}
125+
126+
return sprintf('%s (t%s)', $team->getEffectiveName(), $team->getTeamid());
127+
}
113128
}

webapp/tests/Unit/Controller/Jury/ClarificationControllerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ public function testClarificationRequestComposeForm(): void
9797

9898
$options = $crawler->filter('option')->extract(['_text']);
9999
self::assertEquals('ALL', $options[1]);
100-
self::assertEquals('DOMjudge (t1)', $options[2]);
101-
self::assertEquals('Example teamname (t2)', $options[3]);
100+
self::assertEquals('DOMjudge (domjudge)', $options[2]);
101+
self::assertEquals('Example teamname (exteam)', $options[3]);
102102

103103
$labels = $crawler->filter('label')->extract(['_text']);
104104
self::assertEquals('Send to', $labels[0]);

0 commit comments

Comments
 (0)