Commit 807fcbfd authored by BuildTools's avatar BuildTools
Browse files

Merge branch 'master' of https://gitlab.com/a_boiteau/site-vikazimut-stage into #75_make_event_test

 Conflicts:
	src/Entity/EventCourse.php
parents 6a121d06 6b40aa9f
.navbar-item {
color: white;
padding: 5px;
margin: 0 0.5em;
}
#nav-link-list {
display: flex;
margin-left: auto;
}
#big-screen-visitor-nav{
display: none;
}
#big-screen-visitor-nav .nav-item{
margin-right: 3em;
}
.side-nav{
border-top: solid 1px white;
padding: 0.1em;
margin-left: 20px;
margin-right: 20px;
}
.nav-item a {
font-size: 1.15em;
}
.custom-toggler .navbar-toggler-icon { /*generates the hamburger menu icon, editable*/
background-image: url("data:image/svg+xml;charset=utf8,%3Csvg viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath stroke='rgba(255,255,255,0.8)' stroke-width='2' stroke-linecap='round' stroke-miterlimit='10' d='M4 8h24M4 16h24M4 24h24'/%3E%3C/svg%3E");
}
.custom-toggler.navbar-toggler {
border-color: rgba(255,255,255,0.85);
}
#locale-dropdown {
position: relative;
display: block;
margin-left: 1em;
}
#locale-dropdown-list {
......@@ -12,7 +51,8 @@
}
.locale-dropdown-item a {
padding-right : 20px;
padding-right : 30px;
font-size: 0.85em;
}
.locale-dropdown-item:hover {
......@@ -27,38 +67,16 @@
border-radius: 2px 2px 0 0;
}
.navbar-item {
color: white;
padding: 5px;
margin: 0 0.5em;
}
#nav-link-list {
display: flex;
margin-left: auto;
}
.nav-switcher {
display: none;
}
@media (max-width: 1000px) {
.nav-switcher {
display: block;
@media (min-width: 1000px) {
#big-screen-visitor-nav{
display: flex;
}
#nav-link-list {
#small-screen-visitor-nav{
display: none;
grid-template-columns: 1fr 1fr 1fr;
grid-column-gap: 3em;
grid-row-gap: 5px;
}
}
@media (max-width: 600px) {
#nav-link-list {
grid-template-columns: 1fr 1fr;
grid-column-gap: 9em;
grid-row-gap: 10px;
#tool-nav{
display: none;
}
}
......@@ -9,8 +9,10 @@ use App\Entity\ParticipantMakeEventCourse;
use App\Entity\User;
use App\Form\EventType;
use App\Form\EventCourseType;
use App\Form\ModifyEventCourseType;
use App\Form\ModifyParticipantMakeEventCourseType;
use App\Form\ParticipantType;
use App\Model\ModifyEventCourse;
use App\Model\ModifyParticipantMakeEventCourse;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\RedirectResponse;
......@@ -206,8 +208,9 @@ class EventController extends AbstractController
if ($participantForm->isSubmitted() && $participantForm->isValid()) {
$error = $participant->create($event, $this->getDoctrine()->getManager());
if ($error == "") {
if ($error === "") {
$success = "success";
return $this->redirect($request->getUri());
}
}
......@@ -249,36 +252,42 @@ class EventController extends AbstractController
* @param Request $request
* @return Response
*/
public function my_event_course(int $id, Request $request): Response
public function my_event_courses(int $id, Request $request): Response
{
$event = $this->getDoctrine()->getRepository(Event::class)->find($id);
$eventCourse = new EventCourse();
$eventCourseForm = $this->createForm(EventCourseType::class, $eventCourse, ['user' => $this->security->getUser(), 'id' => $eventCourse->getId()]);
$eventCourseForm = $this->createForm(EventCourseType::class, $eventCourse, ['user' => $this->security->getUser()]);
$eventCourseForm->handleRequest($request);
if ($eventCourseForm->isSubmitted() && $eventCourseForm->isValid()) {
$event = $this->getDoctrine()->getRepository(Event::class)->find($id);
if ($eventCourseForm->isSubmitted() && $eventCourseForm->isValid() && $eventCourse->getId() === null) {
$eventCourse->setEvent($event);
$eventCourse->convertTimeToMaxTime();
$entityManager = $this->getDoctrine()->getManager();
$entityManager->persist($eventCourse);
$participants = $event->getParticipants();
foreach ($participants as $participant) {
$participantMakeEventCourse = new ParticipantMakeEventCourse();
$participantMakeEventCourse->setParticipant($participant);
$participantMakeEventCourse->setEventCourse($eventCourse);
$entityManager->persist($participantMakeEventCourse);
$eventCourse->generateParticipantMakeEventCourse($entityManager);
//return $this->redirect($request->getUri());
}
$modifyFormsView=[];
foreach ($this->getDoctrine()->getRepository(Event::class)->find($id)->getEventCourses() as $eventCourse){
$modifyEventCourse = new ModifyEventCourse($eventCourse);
$modifyEventCourseForm = $this->createForm(ModifyEventCourseType::class, $modifyEventCourse,);
$modifyFormsView[$eventCourse->getId()] = $modifyEventCourseForm->createView();
$modifyEventCourseForm->handleRequest($request);
if ($modifyEventCourseForm->isSubmitted() && $modifyEventCourseForm->isValid() && $modifyEventCourse->getId()===$eventCourse->getId()) {
$modifyEventCourse->modify($this->getDoctrine()->getRepository(EventCourse::class), $this->getDoctrine()->getManager());
}
$entityManager->flush();
}
return $this->render(
'event/my_event_add_course.html.twig',
'event/my_event_courses.html.twig',
[
'event' => $event,
'eventCourseForm' => $eventCourseForm->createView(),
'eventCourses' => $this->getDoctrine()->getRepository(Event::class)->find($id)->getEventCourses(),
'idEvent' => $id,
'modifyEventCourseFormView' => $modifyFormsView,
]
);
}
......
......@@ -159,4 +159,16 @@ class EventCourse
$entityManager->remove($this);
$entityManager->flush();
}
public function generateParticipantMakeEventCourse($entityManager)
{
$participants = $this->event->getParticipants();
foreach ($participants as $participant) {
$participantMakeEventCourse = new ParticipantMakeEventCourse();
$participantMakeEventCourse->setParticipant($participant);
$participantMakeEventCourse->setEventCourse($this);
$entityManager->persist($participantMakeEventCourse);
}
$entityManager->flush();
}
}
\ No newline at end of file
......@@ -6,8 +6,10 @@ namespace App\Form;
use App\Entity\EventCourse;
use App\Entity\User;
use phpDocumentor\Reflection\Types\Integer;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\Extension\Core\Type\TimeType;
......@@ -22,6 +24,7 @@ class EventCourseType extends AbstractType
$courses[$course->getName()] = $course;
}
$builder
->add('id', HiddenType::class, ['data' => $options['id']])
->add(
'course',
ChoiceType::class,
......@@ -56,6 +59,7 @@ class EventCourseType extends AbstractType
[
'eventCourse' => EventCourse::class,
'user' => User::class,
'id' => Integer::class,
]
);
}
......
<?php
namespace App\Form;
use App\Model\ModifyEventCourse;
use App\Entity\User;
use phpDocumentor\Reflection\Types\Integer;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\Extension\Core\Type\TimeType;
use Symfony\Component\OptionsResolver\OptionsResolver;
class ModifyEventCourseType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('id', HiddenType::class,)
->add(
'format',
ChoiceType::class,
[
'label' => "form.eventCourse.format",
'choices' => [
'form.eventCourse.imposed' => 0,
'form.eventCourse.free' => 1,
],
]
)
->add('missingPunchPenalty', TextType::class, ['label' => "form.eventCourse.missingPunchPenalty",])
->add('overTimePenalty', TextType::class, ['label' => "form.eventCourse.overTimePenalty",])
->add('time', TimeType::class, [
'input' => 'timestamp',
'widget' => 'choice',
'label' => "form.eventCourse.maxTime",
]);
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(
[
'modifyEventCourse' => ModifyEventCourse::class,
]
);
}
}
\ No newline at end of file
<?php
namespace App\Model;
use App\Entity\EventCourse;
class ModifyEventCourse
{
private int $id;
private int $format;
private int $missingPunchPenalty;
private int $overTimePenalty;
private string $time;
function __construct(EventCourse $eventCourse)
{
$this->id = $eventCourse->getId();
$this->format = $eventCourse->getFormat();
$this->missingPunchPenalty = $eventCourse->getMissingPunchPenalty();
$this->overTimePenalty = $eventCourse->getOverTimePenalty();
$this->time = (string)$eventCourse->getMaxTime() / 1000;
}
function modify($eventCourseRepository, $entityManager){
$eventCourse = $eventCourseRepository->find($this->id);
$eventCourse->setFormat($this->format);
$eventCourse->setMissingPunchPenalty($this->missingPunchPenalty);
$eventCourse->setOverTimePenalty($this->overTimePenalty);
$eventCourse->setTime($this->time);
$eventCourse->convertTimeToMaxTime();
$entityManager->persist($eventCourse);
$entityManager->flush();
}
/**
* @return int|null
*/
public function getId(): ?int
{
return $this->id;
}
/**
* @param int|null $id
*/
public function setId(?int $id): void
{
$this->id = $id;
}
/**
* @return int|null
*/
public function getFormat(): ?int
{
return $this->format;
}
/**
* @param int|null $format
*/
public function setFormat(?int $format): void
{
$this->format = $format;
}
/**
* @return int|null
*/
public function getMissingPunchPenalty(): ?int
{
return $this->missingPunchPenalty;
}
/**
* @param int|null $missingPunchPenalty
*/
public function setMissingPunchPenalty(?int $missingPunchPenalty): void
{
$this->missingPunchPenalty = $missingPunchPenalty;
}
/**
* @return int|null
*/
public function getOverTimePenalty(): ?int
{
return $this->overTimePenalty;
}
/**
* @param int|null $overTimePenalty
*/
public function setOverTimePenalty(?int $overTimePenalty): void
{
$this->overTimePenalty = $overTimePenalty;
}
/**
* @return float|int|string
*/
public function getTime()
{
return $this->time;
}
/**
* @param float|int|string $time
*/
public function setTime($time): void
{
$this->time = $time;
}
}
\ No newline at end of file
<!DOCTYPE html>
<html lang="fr">
<html lang="{{ app.request.locale }}">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
......@@ -20,71 +20,39 @@
</style>
{% block stylesheets %}{% endblock %}
<script>
function toggleNavbar(){
let linkList = document.getElementById("nav-link-list");
window.getComputedStyle(linkList).getPropertyValue("display") === "grid" ? linkList.style.display = "none" : linkList.style.display = "grid";
function toggleSidebar(){
let sidebar = document.getElementById("nav-sidebar");
window.getComputedStyle(sidebar).getPropertyValue("display") === "none" ? sidebar.style.display = "block" : sidebar.style.display = "none";
}
window.onresize = function(){
let linkList = document.getElementById("nav-link-list");
window.innerWidth <= 1000 ? linkList.style.display = "none" : linkList.style.display = "flex"
};
</script>
</head>
<body>
<nav class="navbar navbar-nav navbar-dark fixed-top" style="background-color: #FF671F;">
<div class="container align-items-center" id="navbar">
<div class="navbar-brand">
<img src="{{ asset('public/images/logo.png') }}" alt="Logo_Vikazimut" style="padding-right:10px;">
<strong>Vikazimut</strong>
</div>
<button onclick="toggleNavbar()" class="navbar-toggler nav-switcher">
<span class="navbar-toggler-icon"></span>
</button>
<ul class="nav" id="nav-link-list">
<nav class="navbar navbar-nav navbar-dark fixed-top" style="background-color: #FF671F; height: 50pt;">
<div class="container align-items-center" id="top-navbar">
<a class="navbar-brand" href="{{ path('home') }}">
<img src="{{ asset('public/images/logo.png') }}" alt="Logo_Vikazimut" style="padding-right:10px;">
<strong>Vikazimut</strong>
</a>
<ul class="nav" id="big-screen-visitor-nav"> <!-- contains the elements of small-screen-visitor-nav and tool-nav for wide display-->
<li class="nav-item">
<a class="nav-link navbar-item" href="{{ path('home') }}">{% trans %}menu.item.home{% endtrans %}</a>
<a class="nav-link navbar-item" href="{{ path('worldmap') }}">{% trans %}menu.item.courses{% endtrans %}</a>
</li>
<li class="nav-item">
<a class="nav-link navbar-item" href="{{ path('worldmap') }}">{% trans %}menu.item.courses{% endtrans %}</a>
<a class="nav-link navbar-item" href="{{ path('events_list') }}">{% trans %}menu.item.events{% endtrans %}</a>
</li>
{% if app.user %}
<li class="nav-item">
<a class="nav-link navbar-item" href="{{ path('events_list') }}">{% trans %}menu.item.events{% endtrans %}</a>
</li>
<li class="nav-item">
<a class="nav-link navbar-item" href="{{ path('your_courses') }}">{% trans %}menu.item.your_courses{% endtrans %}</a>
</li>
<li class="nav-item">
<a class="nav-link navbar-item" href="{{ path('my_events') }}">{% trans %}menu.item.my_event{% endtrans %}</a>
</li>
{% if is_granted('ROLE_ADMIN') %}
<li class="nav-item">
<a class="nav-link navbar-item" href="{{ path('all_planners') }}">{% trans %}menu.item.planners{% endtrans %}</a>
</li>
{% endif %}
{% endif %}
<li class="nav-item mr-5">
<a class="nav-link navbar-item" href="{{ path('home') }}#team ">{% trans %}menu.item.us{% endtrans %}</a>
</li>
{% if app.user %}
<a class="btn btn-outline-light mr-2" href="{{ path('profile') }}">{% trans %}your.info{% endtrans %}</a>
<a class="btn btn-light mr-2" href="{{ path('app_logout') }}">{% trans %}log.out{% endtrans %}</a>
{% else %}
<a class="btn btn-outline-light mr-2" href="{{ path('app_login') }}">{% trans %}log.in{% endtrans %}</a>
{% endif %}
<li class="nav-item">
<div class="nav navbar-nav navbar-right" id="locale-dropdown">
<button class="btn btn-secondary btn-sm" id="locale-dropdown-toggle">
<button class="btn btn-secondary btn-sm" id="locale-dropdown-toggle" style="margin-top: 5px;">
{% trans %}actual.locale{% endtrans %}
</button>
<ul id="locale-dropdown-list">
{% for locale in supported_locales %}
{% if locale != app.request.locale %}
<li class="locale-dropdown-item"> <a class="btn btn-sm" href="{{ path('change_locale', {'locale': locale}) }}">{{ supported_locales_fullname[locale] }}</a> </li>
<li class="locale-dropdown-item"><a class="btn btn-sm" href="{{ path('change_locale', {'locale': locale}) }}">{{ supported_locales_fullname[locale] }}</a></li>
{% endif %}
{% endfor %}
</ul>
......@@ -92,8 +60,83 @@
</li>
</ul>
</div>
<div id="sidebar-toggle-container" style="position: absolute; right: 13pt; top: 13pt;">
{% if app.user %}
<span class="navbar-item">{{ app.user.username }}</span>
{% endif %}
<button onclick="toggleSidebar()" class="navbar-toggler custom-toggler nav-switcher">
<span class="navbar-toggler-icon"></span>
</button>
</div>
</nav>
<div id="nav-sidebar" style="display: none; position: fixed; right: 0; top: 50pt; min-width: 200px;height: 100%; background-color: #FF671F; z-index: 999;">
<ul class="nav flex-column side-nav" id="small-screen-visitor-nav">
<li class="nav-item">
<a class="nav-link navbar-item" href="{{ path('worldmap') }}">{% trans %}menu.item.courses{% endtrans %}</a>
</li>
<li class="nav-item">
<a class="nav-link navbar-item" href="{{ path('events_list') }}">{% trans %}menu.item.events{% endtrans %}</a>
</li>
<li class="nav-item">
<a class="nav-link navbar-item" href="{{ path('home') }}#team ">{% trans %}menu.item.us{% endtrans %}</a>
</li>
</ul>
{% if app.user %}
<ul class="nav flex-column side-nav" id="planner-nav">
<li class="nav-item">
<a class="nav-link navbar-item" href="{{ path('your_courses') }}">{% trans %}menu.item.your_courses{% endtrans %}</a>
</li>
<li class="nav-item">
<a class="nav-link navbar-item" href="{{ path('my_events') }}">{% trans %}menu.item.my_event{% endtrans %}</a>
</li>
</ul>
{% if is_granted('ROLE_ADMIN') %}
<ul class="nav flex-column side-nav" id="admin-nav">
<li class="nav-item">
<a class="nav-link navbar-item" href="{{ path('all_planners') }}">{% trans %}menu.item.planners{% endtrans %}</a>
</li>
</ul>
{% endif %}
{% endif %}
<ul class="nav flex-column side-nav" id="account-nav">
{% if app.user %}
<li class="nav-item">
<a class="nav-link navbar-item" href="{{ path('profile') }}">{% trans %}your.info{% endtrans %}</a>
</li>
<li class="nav-item">
<a class="nav-link navbar-item" href="{{ path('app_logout') }}">
<img src="{{ asset('public/images/power.png') }}" alt="log_out_icon" style="height: 13px; width: 13px; margin-bottom: 4px;">
{% trans %}log.out{% endtrans %}
</a>
</li>
{% else %}
<li class="nav-item">
<a class="nav-link navbar-item" href="{{ path('app_login') }}">
<img src="{{ asset('public/images/power.png') }}" alt="log_in_icon" style="height: 13px; width: 13px; margin-bottom: 4px;">
{% trans %}log.in{% endtrans %}
</a>
</li>
{% endif %}
</ul>
<ul class="nav flex-column side-nav" id="tool-nav">
<li class="nav-item">
<div class="nav navbar-nav navbar-right" id="locale-dropdown" style="margin-top: 0.5em;">
<button class="btn btn-secondary btn-sm" id="locale-dropdown-toggle">
{% trans %}actual.locale{% endtrans %}
</button>
<ul id="locale-dropdown-list">
{% for locale in supported_locales %}
{% if locale != app.request.locale %}
<li class="locale-dropdown-item"> <a class="btn btn-sm" href="{{ path('change_locale', {'locale': locale}) }}">{{ supported_locales_fullname[locale] }}</a> </li>
{% endif %}
{% endfor %}
</ul>
</div>
</li>
</ul>
</div>
{% block body %}{% endblock %}
<footer class="container pt-1 text-muted text-left text-small">
<p>&copy; {% trans %}copyright{% endtrans %}</p>
......
......@@ -22,8 +22,13 @@
<th scope="col">{% trans %}event.info.courses_table.course{% endtrans %}</th>
<th scope="col">{% trans %}event.info.courses_table.order{% endtrans %}</th>
<th scope="col">{% trans %}event.info.courses_table.limit_time{% endtrans %}</th>
<th scope="col">{% trans %}event.info.courses_table.PM_penalty{% endtrans %}</th>
<th scope="col">{% trans %}event.info.courses_table.over_time_penalty{% endtrans %}</th>
{% if event.type==0 or event.type == 1 %}
<th scope="col">{% trans %}event.info.courses_table.PM_penalty{% endtrans %}</th>
<th scope="col">{% trans %}event.info.courses_table.over_time_penalty{% endtrans %}</th>
{% elseif event.type==2 %}
<th scope="col">{% trans %}event.info.courses_table.PM_penalty_sec{% endtrans %}</th>
<th scope="col">{% trans %}event.info.courses_table.over_time_penalty_sec{% endtrans %}</th>
{% endif %}
</tr>
</thead>
{% for eventCourse in eventCourses %}
......@@ -143,5 +148,5 @@
{% block javascripts %}
<script src="{{ asset('public/javascript/jquery-3.5.1.slim.min.js') }}"></script>
<script src="{{ asset('public/bootstrap-4.5.2/js/bootstrap.min.js') }}"></script>
<script src="{{ asset('public/javascript/event.js') }}"></script>
<script src="{{ asset('public/javascript/event.js') }}"></script>
{% endblock %}
\ No newline at end of file
......@@ -4,18 +4,24 @@
{% block body %}
<div class="container text-center" style="padding-top: 20pt">
<h2>{% trans %}my_events.courses.title{% endtrans %}</h2>