|
20 | 20 | use Symfony\Component\HttpFoundation\RedirectResponse; |
21 | 21 | use Symfony\Component\HttpFoundation\Request; |
22 | 22 | use Symfony\Component\HttpFoundation\Response; |
| 23 | +use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; |
23 | 24 | use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
24 | 25 | use Symfony\Component\HttpKernel\KernelInterface; |
25 | 26 | use Symfony\Component\PropertyAccess\PropertyAccess; |
@@ -65,13 +66,30 @@ public function indexAction(): Response |
65 | 66 | 'allow_self_registration' => ['title' => 'self-registration', 'sort' => true], |
66 | 67 | ]; |
67 | 68 |
|
| 69 | + if ($this->isGranted('ROLE_ADMIN')) { |
| 70 | + $table_fields = array_merge( |
| 71 | + ['checkbox' => ['title' => '<input type="checkbox" class="select-all" title="Select all categories">', 'sort' => false, 'search' => false, 'raw' => true]], |
| 72 | + $table_fields |
| 73 | + ); |
| 74 | + } |
| 75 | + |
68 | 76 | $propertyAccessor = PropertyAccess::createPropertyAccessor(); |
69 | 77 | $team_categories_table = []; |
70 | 78 | foreach ($teamCategories as $teamCategoryData) { |
71 | 79 | /** @var TeamCategory $teamCategory */ |
72 | 80 | $teamCategory = $teamCategoryData[0]; |
73 | 81 | $categorydata = []; |
74 | 82 | $categoryactions = []; |
| 83 | + |
| 84 | + if ($this->isGranted('ROLE_ADMIN')) { |
| 85 | + $categorydata['checkbox'] = [ |
| 86 | + 'value' => sprintf( |
| 87 | + '<input type="checkbox" name="ids[]" value="%s" class="category-checkbox">', |
| 88 | + $teamCategory->getCategoryid() |
| 89 | + ) |
| 90 | + ]; |
| 91 | + } |
| 92 | + |
75 | 93 | // Get whatever fields we can from the category object itself. |
76 | 94 | foreach ($table_fields as $k => $v) { |
77 | 95 | if ($propertyAccessor->isReadable($teamCategory, $k)) { |
@@ -230,6 +248,20 @@ public function addAction(Request $request): Response |
230 | 248 | ]); |
231 | 249 | } |
232 | 250 |
|
| 251 | + #[IsGranted('ROLE_ADMIN')] |
| 252 | + #[Route(path: '/delete-multiple', name: 'jury_team_category_delete_multiple', methods: ['GET', 'POST'])] |
| 253 | + public function deleteMultipleAction(Request $request): Response |
| 254 | + { |
| 255 | + $ids = $request->query->all('ids'); |
| 256 | + if (empty($ids)) { |
| 257 | + throw new BadRequestHttpException('No IDs specified for deletion'); |
| 258 | + } |
| 259 | + |
| 260 | + $categories = $this->em->getRepository(TeamCategory::class)->findBy(['categoryid' => $ids]); |
| 261 | + |
| 262 | + return $this->deleteEntities($request, $categories, $this->generateUrl('jury_team_categories')); |
| 263 | + } |
| 264 | + |
233 | 265 | #[Route(path: '/{categoryId<\d+>}/request-remaining', name: 'jury_team_category_request_remaining')] |
234 | 266 | public function requestRemainingRunsWholeTeamCategoryAction(string $categoryId): RedirectResponse |
235 | 267 | { |
|
0 commit comments