diff --git a/webapp/src/Controller/Jury/ContestController.php b/webapp/src/Controller/Jury/ContestController.php index 0bfe46e49b..987d05e18e 100644 --- a/webapp/src/Controller/Jury/ContestController.php +++ b/webapp/src/Controller/Jury/ContestController.php @@ -379,7 +379,6 @@ public function indexAction(Request $request): Response 'upcoming_contest' => $upcomingContest, 'contests_table' => $contests_table, 'table_fields' => $table_fields, - 'num_actions' => $this->isGranted('ROLE_ADMIN') && !$contest->isLocked() ? 2 : 0, ]); } diff --git a/webapp/src/Controller/Jury/ExecutableController.php b/webapp/src/Controller/Jury/ExecutableController.php index f80f732a65..9cbb7afec1 100644 --- a/webapp/src/Controller/Jury/ExecutableController.php +++ b/webapp/src/Controller/Jury/ExecutableController.php @@ -116,7 +116,6 @@ public function indexAction(Request $request): Response return $this->render('jury/executables.html.twig', [ 'executables' => $executables_table, 'table_fields' => $table_fields, - 'num_actions' => count($execactions), 'form' => $form->createView(), ]); } diff --git a/webapp/src/Controller/Jury/JudgehostController.php b/webapp/src/Controller/Jury/JudgehostController.php index d4b0cdc807..afd7a024bc 100644 --- a/webapp/src/Controller/Jury/JudgehostController.php +++ b/webapp/src/Controller/Jury/JudgehostController.php @@ -184,7 +184,6 @@ public function indexAction(Request $request): Response $data = [ 'judgehosts' => $judgehosts_table, 'table_fields' => $table_fields, - 'num_actions' => $this->isGranted('ROLE_ADMIN') ? 2 : 0, 'all_checked_in_recently' => $all_checked_in_recently, 'refresh' => [ 'after' => 5, diff --git a/webapp/src/Controller/Jury/LanguageController.php b/webapp/src/Controller/Jury/LanguageController.php index f5f6c1683c..fb3c5e0020 100644 --- a/webapp/src/Controller/Jury/LanguageController.php +++ b/webapp/src/Controller/Jury/LanguageController.php @@ -146,7 +146,6 @@ public function indexAction(): Response 'enabled_languages' => $enabled_languages, 'disabled_languages' => $disabled_languages, 'table_fields' => $table_fields, - 'num_actions' => $this->isGranted('ROLE_ADMIN') ? 2 : 0, ]); } diff --git a/webapp/src/Controller/Jury/ProblemController.php b/webapp/src/Controller/Jury/ProblemController.php index 536c6fb928..62502bd74b 100644 --- a/webapp/src/Controller/Jury/ProblemController.php +++ b/webapp/src/Controller/Jury/ProblemController.php @@ -214,7 +214,6 @@ public function indexAction(): Response $data = [ 'problems' => $problems_table, 'table_fields' => $table_fields, - 'num_actions' => $this->isGranted('ROLE_ADMIN') ? 4 : 2, ]; return $this->render('jury/problems.html.twig', $data); diff --git a/webapp/src/Controller/Jury/TeamAffiliationController.php b/webapp/src/Controller/Jury/TeamAffiliationController.php index 62c12c5750..02436c76d5 100644 --- a/webapp/src/Controller/Jury/TeamAffiliationController.php +++ b/webapp/src/Controller/Jury/TeamAffiliationController.php @@ -143,7 +143,6 @@ public function indexAction(string $projectDir): Response return $this->render('jury/team_affiliations.html.twig', [ 'team_affiliations' => $team_affiliations_table, 'table_fields' => $table_fields, - 'num_actions' => $this->isGranted('ROLE_ADMIN') ? 2 : 0, ]); } diff --git a/webapp/src/Controller/Jury/TeamCategoryController.php b/webapp/src/Controller/Jury/TeamCategoryController.php index 9c0eecd9e6..789c12db82 100644 --- a/webapp/src/Controller/Jury/TeamCategoryController.php +++ b/webapp/src/Controller/Jury/TeamCategoryController.php @@ -127,7 +127,6 @@ public function indexAction(): Response return $this->render('jury/team_categories.html.twig', [ 'team_categories' => $team_categories_table, 'table_fields' => $table_fields, - 'num_actions' => $this->isGranted('ROLE_ADMIN') ? 2 : 0, ]); } diff --git a/webapp/src/Controller/Jury/TeamController.php b/webapp/src/Controller/Jury/TeamController.php index f4056c460d..500badb58e 100644 --- a/webapp/src/Controller/Jury/TeamController.php +++ b/webapp/src/Controller/Jury/TeamController.php @@ -239,7 +239,6 @@ public function indexAction(): Response return $this->render('jury/teams.html.twig', [ 'teams' => $teams_table, 'table_fields' => $table_fields, - 'num_actions' => $this->isGranted('ROLE_ADMIN') ? 3 : 1, ]); } diff --git a/webapp/src/Controller/Jury/UserController.php b/webapp/src/Controller/Jury/UserController.php index 7aed63c520..f69387ea69 100644 --- a/webapp/src/Controller/Jury/UserController.php +++ b/webapp/src/Controller/Jury/UserController.php @@ -184,7 +184,6 @@ public function indexAction(): Response return $this->render('jury/users.html.twig', [ 'users' => $users_table, 'table_fields' => $table_fields, - 'num_actions' => $this->isGranted('ROLE_ADMIN') ? 2 : 0, ]); } diff --git a/webapp/src/Twig/TwigExtension.php b/webapp/src/Twig/TwigExtension.php index 217b555ab4..4e1470b1b9 100644 --- a/webapp/src/Twig/TwigExtension.php +++ b/webapp/src/Twig/TwigExtension.php @@ -128,6 +128,7 @@ public function getFilters(): array new TwigFilter('printWarningContent', [$this, 'printWarningContent'], ['is_safe' => ['html']]), new TwigFilter('entityIdBadge', [$this, 'entityIdBadge'], ['is_safe' => ['html']]), new TwigFilter('medalType', [$this->awards, 'medalType']), + new TwigFilter('numTableActions', [$this, 'numTableActions']), ]; } @@ -1207,4 +1208,13 @@ public function entityIdBadge(BaseApiEntity $entity, string $idPrefix = ''): str 'externalId' => $externalIdField ? $propertyAccessor->getValue($entity, $externalIdField) : null, ]); } + + public function numTableActions(array $tableData): int + { + $maxNumActions = 0; + foreach ($tableData as $item) { + $maxNumActions = max($maxNumActions, count($item['actions'] ?? [])); + } + return $maxNumActions; + } } diff --git a/webapp/templates/jury/contests.html.twig b/webapp/templates/jury/contests.html.twig index a9af41e1a4..04cc260fc8 100644 --- a/webapp/templates/jury/contests.html.twig +++ b/webapp/templates/jury/contests.html.twig @@ -87,7 +87,7 @@
diff --git a/webapp/templates/jury/executables.html.twig b/webapp/templates/jury/executables.html.twig index 94af4cae5b..cd5276371e 100644 --- a/webapp/templates/jury/executables.html.twig +++ b/webapp/templates/jury/executables.html.twig @@ -12,7 +12,7 @@
diff --git a/webapp/templates/jury/jury_macros.twig b/webapp/templates/jury/jury_macros.twig index f86c3e08ac..ddb70eb30a 100644 --- a/webapp/templates/jury/jury_macros.twig +++ b/webapp/templates/jury/jury_macros.twig @@ -85,12 +85,13 @@ {% endmacro %} -{% macro table(data, fields, num_actions, options) %} +{% macro table(data, fields, options) %}