From a86b7b9830b3421eae588740fa08ac5e96b65849 Mon Sep 17 00:00:00 2001 From: Nicky Gerritsen Date: Sat, 23 Mar 2024 12:36:27 +0100 Subject: [PATCH] Make number of actions the same for all contests. This fixes a javascript error with DataTables. --- .../src/Controller/Jury/ContestController.php | 41 +++++++++++-------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/webapp/src/Controller/Jury/ContestController.php b/webapp/src/Controller/Jury/ContestController.php index 479d0d6b07..e71095d13c 100644 --- a/webapp/src/Controller/Jury/ContestController.php +++ b/webapp/src/Controller/Jury/ContestController.php @@ -258,22 +258,31 @@ public function indexAction(Request $request): Response } else { $contestactions[] = []; } - if ($this->isGranted('ROLE_ADMIN') && !$contest->isLocked()) { - $contestactions[] = [ - 'icon' => 'edit', - 'title' => 'edit this contest', - 'link' => $this->generateUrl('jury_contest_edit', [ - 'contestId' => $contest->getCid(), - ]) - ]; - $contestactions[] = [ - 'icon' => 'trash-alt', - 'title' => 'delete this contest', - 'link' => $this->generateUrl('jury_contest_delete', [ - 'contestId' => $contest->getCid(), - ]), - 'ajaxModal' => true, - ]; + if ($this->isGranted('ROLE_ADMIN')) { + if ($contest->isLocked()) { + // The number of table columns and thus the number of actions need + // to match for all rows to not get DataTables errors. + // Since we add two actions for non-locked contests, we need to add + // two empty actions for locked contests. + $contestactions[] = []; + $contestactions[] = []; + } else { + $contestactions[] = [ + 'icon' => 'edit', + 'title' => 'edit this contest', + 'link' => $this->generateUrl('jury_contest_edit', [ + 'contestId' => $contest->getCid(), + ]) + ]; + $contestactions[] = [ + 'icon' => 'trash-alt', + 'title' => 'delete this contest', + 'link' => $this->generateUrl('jury_contest_delete', [ + 'contestId' => $contest->getCid(), + ]), + 'ajaxModal' => true, + ]; + } } $contestdata['process_balloons'] = [