Skip to content

Commit a86b7b9

Browse files
Make number of actions the same for all contests.
This fixes a javascript error with DataTables.
1 parent 280cd28 commit a86b7b9

File tree

1 file changed

+25
-16
lines changed

1 file changed

+25
-16
lines changed

webapp/src/Controller/Jury/ContestController.php

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -258,22 +258,31 @@ public function indexAction(Request $request): Response
258258
} else {
259259
$contestactions[] = [];
260260
}
261-
if ($this->isGranted('ROLE_ADMIN') && !$contest->isLocked()) {
262-
$contestactions[] = [
263-
'icon' => 'edit',
264-
'title' => 'edit this contest',
265-
'link' => $this->generateUrl('jury_contest_edit', [
266-
'contestId' => $contest->getCid(),
267-
])
268-
];
269-
$contestactions[] = [
270-
'icon' => 'trash-alt',
271-
'title' => 'delete this contest',
272-
'link' => $this->generateUrl('jury_contest_delete', [
273-
'contestId' => $contest->getCid(),
274-
]),
275-
'ajaxModal' => true,
276-
];
261+
if ($this->isGranted('ROLE_ADMIN')) {
262+
if ($contest->isLocked()) {
263+
// The number of table columns and thus the number of actions need
264+
// to match for all rows to not get DataTables errors.
265+
// Since we add two actions for non-locked contests, we need to add
266+
// two empty actions for locked contests.
267+
$contestactions[] = [];
268+
$contestactions[] = [];
269+
} else {
270+
$contestactions[] = [
271+
'icon' => 'edit',
272+
'title' => 'edit this contest',
273+
'link' => $this->generateUrl('jury_contest_edit', [
274+
'contestId' => $contest->getCid(),
275+
])
276+
];
277+
$contestactions[] = [
278+
'icon' => 'trash-alt',
279+
'title' => 'delete this contest',
280+
'link' => $this->generateUrl('jury_contest_delete', [
281+
'contestId' => $contest->getCid(),
282+
]),
283+
'ajaxModal' => true,
284+
];
285+
}
277286
}
278287

279288
$contestdata['process_balloons'] = [

0 commit comments

Comments
 (0)