Skip to content

Commit 8f523ae

Browse files
Auto calculate num actions for jury tables.
(cherry picked from commit 1294b6e) # Conflicts: # webapp/src/Controller/Jury/ExecutableController.php # webapp/src/Twig/TwigExtension.php
1 parent 9457175 commit 8f523ae

20 files changed

+22
-20
lines changed

webapp/src/Controller/Jury/ContestController.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,6 @@ public function indexAction(Request $request): Response
379379
'upcoming_contest' => $upcomingContest,
380380
'contests_table' => $contests_table,
381381
'table_fields' => $table_fields,
382-
'num_actions' => $this->isGranted('ROLE_ADMIN') && !$contest->isLocked() ? 2 : 0,
383382
]);
384383
}
385384

webapp/src/Controller/Jury/ExecutableController.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ public function indexAction(Request $request): Response
116116
return $this->render('jury/executables.html.twig', [
117117
'executables' => $executables_table,
118118
'table_fields' => $table_fields,
119-
'num_actions' => count($execactions),
120119
'form' => $form->createView(),
121120
]);
122121
}

webapp/src/Controller/Jury/JudgehostController.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ public function indexAction(Request $request): Response
184184
$data = [
185185
'judgehosts' => $judgehosts_table,
186186
'table_fields' => $table_fields,
187-
'num_actions' => $this->isGranted('ROLE_ADMIN') ? 2 : 0,
188187
'all_checked_in_recently' => $all_checked_in_recently,
189188
'refresh' => [
190189
'after' => 5,

webapp/src/Controller/Jury/LanguageController.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ public function indexAction(): Response
146146
'enabled_languages' => $enabled_languages,
147147
'disabled_languages' => $disabled_languages,
148148
'table_fields' => $table_fields,
149-
'num_actions' => $this->isGranted('ROLE_ADMIN') ? 2 : 0,
150149
]);
151150
}
152151

webapp/src/Controller/Jury/ProblemController.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ public function indexAction(): Response
214214
$data = [
215215
'problems' => $problems_table,
216216
'table_fields' => $table_fields,
217-
'num_actions' => $this->isGranted('ROLE_ADMIN') ? 4 : 2,
218217
];
219218

220219
return $this->render('jury/problems.html.twig', $data);

webapp/src/Controller/Jury/TeamAffiliationController.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ public function indexAction(string $projectDir): Response
143143
return $this->render('jury/team_affiliations.html.twig', [
144144
'team_affiliations' => $team_affiliations_table,
145145
'table_fields' => $table_fields,
146-
'num_actions' => $this->isGranted('ROLE_ADMIN') ? 2 : 0,
147146
]);
148147
}
149148

webapp/src/Controller/Jury/TeamCategoryController.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ public function indexAction(): Response
127127
return $this->render('jury/team_categories.html.twig', [
128128
'team_categories' => $team_categories_table,
129129
'table_fields' => $table_fields,
130-
'num_actions' => $this->isGranted('ROLE_ADMIN') ? 2 : 0,
131130
]);
132131
}
133132

webapp/src/Controller/Jury/TeamController.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,6 @@ public function indexAction(): Response
239239
return $this->render('jury/teams.html.twig', [
240240
'teams' => $teams_table,
241241
'table_fields' => $table_fields,
242-
'num_actions' => $this->isGranted('ROLE_ADMIN') ? 3 : 1,
243242
]);
244243
}
245244

webapp/src/Controller/Jury/UserController.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ public function indexAction(): Response
184184
return $this->render('jury/users.html.twig', [
185185
'users' => $users_table,
186186
'table_fields' => $table_fields,
187-
'num_actions' => $this->isGranted('ROLE_ADMIN') ? 2 : 0,
188187
]);
189188
}
190189

webapp/src/Twig/TwigExtension.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ public function getFilters(): array
128128
new TwigFilter('printWarningContent', [$this, 'printWarningContent'], ['is_safe' => ['html']]),
129129
new TwigFilter('entityIdBadge', [$this, 'entityIdBadge'], ['is_safe' => ['html']]),
130130
new TwigFilter('medalType', [$this->awards, 'medalType']),
131+
new TwigFilter('numTableActions', [$this, 'numTableActions']),
131132
];
132133
}
133134

@@ -1207,4 +1208,13 @@ public function entityIdBadge(BaseApiEntity $entity, string $idPrefix = ''): str
12071208
'externalId' => $externalIdField ? $propertyAccessor->getValue($entity, $externalIdField) : null,
12081209
]);
12091210
}
1211+
1212+
public function numTableActions(array $tableData): int
1213+
{
1214+
$maxNumActions = 0;
1215+
foreach ($tableData as $item) {
1216+
$maxNumActions = max($maxNumActions, count($item['actions'] ?? []));
1217+
}
1218+
return $maxNumActions;
1219+
}
12101220
}

0 commit comments

Comments
 (0)