diff --git a/.env b/.env index 126ff163..bb37a150 100644 --- a/.env +++ b/.env @@ -70,6 +70,7 @@ OAUTH_KEYCLOAK_REALM=addHere ###> demo ### demo_installation=prod #demo +APP_DEMO=0 ###< demo ### ###> LaF ### diff --git a/config/packages/twig.yaml b/config/packages/twig.yaml index 06020e21..4eacfeb4 100644 --- a/config/packages/twig.yaml +++ b/config/packages/twig.yaml @@ -12,4 +12,5 @@ twig: dataPrivacy: '%env(dataPrivacy)%' supportMail: '%env(SUPPORT_MAIL)%' demo: '%env(demo_installation)%' - laf_version: '%env(laF_version)%' \ No newline at end of file + laf_version: '%env(laF_version)%' + APP_DEMO: '%env(APP_DEMO)%' \ No newline at end of file diff --git a/src/Controller/DashboardController.php b/src/Controller/DashboardController.php index 31e5d026..9769a3e5 100644 --- a/src/Controller/DashboardController.php +++ b/src/Controller/DashboardController.php @@ -14,6 +14,8 @@ namespace App\Controller; +use App\Entity\Team; +use App\Form\Type\TeamType; use App\Repository\AkademieBuchungenRepository; use App\Repository\AuditTomRepository; use App\Repository\DatenweitergabeRepository; @@ -150,6 +152,26 @@ public function noTeam(): Response ]); } + #[Route(path: '/no_team/create', name: 'no_team_create')] + public function noTeamCreate(): Response + { + if (!$_ENV['APP_DEMO']) { + return $this->redirectToRoute('dashboard'); + } + + $team = (new Team())->setActiv(true); + $form = $this->createForm(TeamType::class, $team, [ + 'action' => $this->generateUrl('team_create') + ]) + ->remove('video') + ->remove('externalLink'); + + return $this->render('dashboard/noteamCreate.html.twig', [ + 'user' => $this->getUser(), + 'form' => $form->createView(), + ]); + } + private function getTabsAssignments(): array { return [ diff --git a/src/Controller/TeamController.php b/src/Controller/TeamController.php index e805d6a1..8bd02a85 100644 --- a/src/Controller/TeamController.php +++ b/src/Controller/TeamController.php @@ -120,6 +120,7 @@ public function create( ValidatorInterface $validator, EntityManagerInterface $em, Request $request, + CurrentTeamService $teamService, ): Response { $user = $this->getUser(); @@ -140,6 +141,13 @@ public function create( $em->persist($nTeam); $em->persist($user); $em->flush(); + $this->addSuccessMessage($this->translator->trans(id: 'team.created', domain: 'team')); + + if ($_ENV['APP_DEMO']) { + $teamService->switchToTeam((string) $nTeam->getId()); + return $this->redirectToRoute('dashboard'); + } + return $this->redirectToRoute('team_edit', ['id' => $nTeam->getId()]); } } diff --git a/templates/dashboard/noteam.html.twig b/templates/dashboard/noteam.html.twig index 8717ccd9..31091038 100644 --- a/templates/dashboard/noteam.html.twig +++ b/templates/dashboard/noteam.html.twig @@ -7,10 +7,17 @@

{% trans %}noTeam{% endtrans %}

-

{% trans %}noTeamHelp{% endtrans %}

-
- {% trans %}supportRequest{% endtrans %} - {% trans %}logout{% endtrans %} + {% if APP_DEMO %} +

{% trans %}createTeamHelp{% endtrans %}

+ + {% trans from 'team' %}team.create{% endtrans %} + + {% else %} +

{% trans %}noTeamHelp{% endtrans %}

+
+ {% trans %}supportRequest{% endtrans %} + {% trans %}logout{% endtrans %} + {% endif %}
{% endblock %} \ No newline at end of file diff --git a/templates/dashboard/noteamCreate.html.twig b/templates/dashboard/noteamCreate.html.twig new file mode 100644 index 00000000..c4a8ad56 --- /dev/null +++ b/templates/dashboard/noteamCreate.html.twig @@ -0,0 +1,11 @@ +{% extends 'client_request/base.html.twig' %} +{% trans_default_domain 'dashboard' %} + +{% block content %} +
+

{% trans from 'team' %}team.create{% endtrans %}

+ {{ form_start(form) }} + {{ form_row(form) }} + {{ form_end(form) }} +
+{% endblock %} \ No newline at end of file diff --git a/translations/dashboard/dashboard.de.yaml b/translations/dashboard/dashboard.de.yaml index cf3a74fe..25e60635 100644 --- a/translations/dashboard/dashboard.de.yaml +++ b/translations/dashboard/dashboard.de.yaml @@ -32,4 +32,5 @@ guideline: Richtlinie noTeamHelp: Für Ihren Benutzer ist kein Team vorhanden.
Fragen Sie Ihrem Administrator oder beim Support der H2 invent nach. supportRequest: Support anfragen logout: Logout -noTeam: Kein Team vorhanden \ No newline at end of file +noTeam: Kein Team vorhanden +createTeamHelp: Erstellen Sie Ihr erstes Team. \ No newline at end of file diff --git a/translations/team/team.de.yaml b/translations/team/team.de.yaml index ea0ba7e5..423d655b 100644 --- a/translations/team/team.de.yaml +++ b/translations/team/team.de.yaml @@ -19,6 +19,7 @@ team: delete: '{teamName} löschen' manage: Teams verwalten create: Team erstellen + created: Team erstellt manageData: Stammdaten bearbeiten manageMembers: Mitglieder bearbeiten deletionBlocked: 'Diese Gruppe kann erst gelöscht werden, wenn folgende Elemente entfernt wurden:'