1414use Symfony \Component \DependencyInjection \Attribute \Autowire ;
1515use Symfony \Component \HttpFoundation \Request ;
1616use Symfony \Component \HttpFoundation \Response ;
17+ use Symfony \Component \HttpKernel \Exception \BadRequestHttpException ;
1718use Symfony \Component \HttpKernel \Exception \NotFoundHttpException ;
1819use Symfony \Component \HttpKernel \KernelInterface ;
1920use Symfony \Component \PropertyAccess \PropertyAccess ;
@@ -59,6 +60,13 @@ public function indexAction(
5960 'name ' => ['title ' => 'name ' , 'sort ' => true , 'default_sort ' => true ],
6061 ];
6162
63+ if ($ this ->isGranted ('ROLE_ADMIN ' )) {
64+ $ table_fields = array_merge (
65+ ['checkbox ' => ['title ' => '<input type="checkbox" class="select-all" title="Select all affiliations"> ' , 'sort ' => false , 'search ' => false , 'raw ' => true ]],
66+ $ table_fields
67+ );
68+ }
69+
6270 if ($ showFlags ) {
6371 $ table_fields ['country ' ] = ['title ' => 'country ' , 'sort ' => true ];
6472 $ table_fields ['affiliation_logo ' ] = ['title ' => 'logo ' , 'sort ' => false ];
@@ -73,6 +81,16 @@ public function indexAction(
7381 $ teamAffiliation = $ teamAffiliationData [0 ];
7482 $ affiliationdata = [];
7583 $ affiliationactions = [];
84+
85+ if ($ this ->isGranted ('ROLE_ADMIN ' )) {
86+ $ affiliationdata ['checkbox ' ] = [
87+ 'value ' => sprintf (
88+ '<input type="checkbox" name="ids[]" value="%s" class="affiliation-checkbox"> ' ,
89+ $ teamAffiliation ->getAffilid ()
90+ )
91+ ];
92+ }
93+
7694 // Get whatever fields we can from the affiliation object itself.
7795 foreach ($ table_fields as $ k => $ v ) {
7896 if ($ propertyAccessor ->isReadable ($ teamAffiliation , $ k )) {
@@ -201,6 +219,20 @@ public function deleteAction(Request $request, int $affilId): Response
201219 return $ this ->deleteEntities ($ request , [$ teamAffiliation ], $ this ->generateUrl ('jury_team_affiliations ' ));
202220 }
203221
222+ #[IsGranted('ROLE_ADMIN ' )]
223+ #[Route(path: '/delete-multiple ' , name: 'jury_team_affiliation_delete_multiple ' , methods: ['GET ' , 'POST ' ])]
224+ public function deleteMultipleAction (Request $ request ): Response
225+ {
226+ $ ids = $ request ->query ->all ('ids ' );
227+ if (empty ($ ids )) {
228+ throw new BadRequestHttpException ('No IDs specified for deletion ' );
229+ }
230+
231+ $ affiliations = $ this ->em ->getRepository (TeamAffiliation::class)->findBy (['affilid ' => $ ids ]);
232+
233+ return $ this ->deleteEntities ($ request , $ affiliations , $ this ->generateUrl ('jury_team_affiliations ' ));
234+ }
235+
204236 #[IsGranted('ROLE_ADMIN ' )]
205237 #[Route(path: '/add ' , name: 'jury_team_affiliation_add ' )]
206238 public function addAction (Request $ request ): Response
0 commit comments