Skip to content

Commit

Permalink
Create a create team page for demo env
Browse files Browse the repository at this point in the history
  • Loading branch information
Rayvented committed Feb 8, 2024
1 parent 8194bf1 commit ce802aa
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 6 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ OAUTH_KEYCLOAK_REALM=addHere

###> demo ###
demo_installation=prod #demo
APP_DEMO=0
###< demo ###

###> LaF ###
Expand Down
3 changes: 2 additions & 1 deletion config/packages/twig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ twig:
dataPrivacy: '%env(dataPrivacy)%'
supportMail: '%env(SUPPORT_MAIL)%'
demo: '%env(demo_installation)%'
laf_version: '%env(laF_version)%'
laf_version: '%env(laF_version)%'
APP_DEMO: '%env(APP_DEMO)%'
22 changes: 22 additions & 0 deletions src/Controller/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 [
Expand Down
8 changes: 8 additions & 0 deletions src/Controller/TeamController.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public function create(
ValidatorInterface $validator,
EntityManagerInterface $em,
Request $request,
CurrentTeamService $teamService,
): Response
{
$user = $this->getUser();
Expand All @@ -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()]);
}
}
Expand Down
15 changes: 11 additions & 4 deletions templates/dashboard/noteam.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,17 @@
<h2>{% trans %}noTeam{% endtrans %}</h2>
</div>
<div>
<p>{% trans %}noTeamHelp{% endtrans %}</p>
<hr class="my-5">
<a href="mailto:{{ supportMail }}" class="btn">{% trans %}supportRequest{% endtrans %}</a>
<a href="{{ path('logout_keycloak') }}" class="btn">{% trans %}logout{% endtrans %}</a>
{% if APP_DEMO %}
<p>{% trans %}createTeamHelp{% endtrans %}</p>
<a href="{{ path('no_team_create') }}" class="btn btn-create mt-5">
{% trans from 'team' %}team.create{% endtrans %}
</a>
{% else %}
<p>{% trans %}noTeamHelp{% endtrans %}</p>
<hr class="my-5">
<a href="mailto:{{ supportMail }}" class="btn">{% trans %}supportRequest{% endtrans %}</a>
<a href="{{ path('logout_keycloak') }}" class="btn">{% trans %}logout{% endtrans %}</a>
{% endif %}
</div>
</div>
{% endblock %}
11 changes: 11 additions & 0 deletions templates/dashboard/noteamCreate.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{% extends 'client_request/base.html.twig' %}
{% trans_default_domain 'dashboard' %}

{% block content %}
<div class="card-outlined">
<h2>{% trans from 'team' %}team.create{% endtrans %}</h2>
{{ form_start(form) }}
{{ form_row(form) }}
{{ form_end(form) }}
</div>
{% endblock %}
3 changes: 2 additions & 1 deletion translations/dashboard/dashboard.de.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ guideline: Richtlinie
noTeamHelp: Für Ihren Benutzer ist kein Team vorhanden.<br>Fragen Sie Ihrem Administrator oder beim Support der H2 invent nach.
supportRequest: Support anfragen
logout: Logout
noTeam: Kein Team vorhanden
noTeam: Kein Team vorhanden
createTeamHelp: Erstellen Sie Ihr erstes Team.
1 change: 1 addition & 0 deletions translations/team/team.de.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:'
Expand Down

0 comments on commit ce802aa

Please sign in to comment.