From f596290960d80035ab15d825fb099459c796befe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Thu, 4 Apr 2024 08:58:17 +0200 Subject: [PATCH] feat: improved teamer status label in overview --- src/Twig/AppRuntime.php | 22 +++++++++++++++++-- templates/admin/teamer/skills.html.twig | 2 +- .../administrative/teamer/index.html.twig | 2 +- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/Twig/AppRuntime.php b/src/Twig/AppRuntime.php index 26278fa..a0b8fe3 100644 --- a/src/Twig/AppRuntime.php +++ b/src/Twig/AppRuntime.php @@ -25,9 +25,27 @@ class AppRuntime implements RuntimeExtensionInterface ) { } - public function teamerStatusLabel(string $status): string + public function teamerStatusLabel(Teamer $teamer): string { - if (Teamer::STATUS_NEW === $status) { + $labelItems = []; + + if ($teamer->getUser()->hasRole('ROLE_ADMIN')) { + $labelItems[] = 'Admin'; + } + + if ($teamer->getUser()->hasRole('ROLE_MANAGER')) { + $labelItems[] = 'Reisemanagement'; + } + + if ($teamer->getUser()->hasRole('ROLE_HOUSE_MANAGER')) { + $labelItems[] = 'Hausleitung'; + } + + if (0 < count($labelItems)) { + return implode(', ', $labelItems); + } + + if (Teamer::STATUS_NEW === $teamer->getStatus()) { return 'Neuteamer:in'; } diff --git a/templates/admin/teamer/skills.html.twig b/templates/admin/teamer/skills.html.twig index a0636d7..0875186 100644 --- a/templates/admin/teamer/skills.html.twig +++ b/templates/admin/teamer/skills.html.twig @@ -78,7 +78,7 @@ Status:
- {{ teamer.status|teamer_status_label }} + {{ teamer|teamer_status_label }}
diff --git a/templates/administrative/teamer/index.html.twig b/templates/administrative/teamer/index.html.twig index d454c97..ce9d33d 100644 --- a/templates/administrative/teamer/index.html.twig +++ b/templates/administrative/teamer/index.html.twig @@ -80,7 +80,7 @@ - {{ teamer.status|teamer_status_label }} + {{ teamer|teamer_status_label }} {{ teamer.communication.email }}