closed step added + form/controller/template basic start

This commit is contained in:
Julie Lenaerts 2021-11-18 14:46:33 +01:00
parent 1509fcc2e9
commit ce5af04df7
5 changed files with 91 additions and 0 deletions

View File

@ -158,4 +158,29 @@ class AccompanyingCourseController extends Controller
]); ]);
} }
/**
* @Route("/{_locale}/parcours/{accompanying_period_id}/close", name="chill_person_accompanying_course_close")
* @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"})
*/
public function closeAction(AccompanyingPeriod $accompanyingCourse, Request $request): Response
{
$this->denyAccessUnlessGranted(AccompanyingPeriodVoter::EDIT, $accompanyingCourse);
$form = $this->createForm(AccompanyingCourseType::class, $accompanyingCourse);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$this->getDoctrine()->getManager()->flush();
}
return $this->render('@ChillPerson/AccompanyingCourse/close.html.twig', [
'form' => $form->createView(),
'accompanyingCourse' => $accompanyingCourse
]);
}
} }

View File

@ -221,12 +221,17 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
'places' => [ 'places' => [
'DRAFT', 'DRAFT',
'CONFIRMED', 'CONFIRMED',
'CLOSED',
], ],
'transitions' => [ 'transitions' => [
'confirm' => [ 'confirm' => [
'from' => 'DRAFT', 'from' => 'DRAFT',
'to' => 'CONFIRMED' 'to' => 'CONFIRMED'
], ],
'close' => [
'from' => 'CONFIRMED',
'to' => 'CLOSED'
],
], ],
], ],
] ]

View File

@ -94,6 +94,14 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
*/ */
public const STEP_CONFIRMED = 'CONFIRMED'; public const STEP_CONFIRMED = 'CONFIRMED';
/**
* Mark an accompanying period as "closed".
*
* This means that the accompanying period **is**
* closed by the creator
*/
public const STEP_CLOSED = 'CLOSED';
/** /**
* @var integer * @var integer
* *
@ -117,6 +125,8 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
* *
* @ORM\Column(type="date", nullable=true) * @ORM\Column(type="date", nullable=true)
* @Groups({"read", "write"}) * @Groups({"read", "write"})
* @Assert\NotBlank(groups={AccompanyingPeriod::STEP_CLOSED})
* @Assert\GreaterThan(propertyPath="openingDate", groups={AccompanyingPeriod::STEP_CLOSED})
*/ */
private $closingDate = null; private $closingDate = null;
@ -166,6 +176,7 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
* targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive") * targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive")
* @ORM\JoinColumn(nullable=true) * @ORM\JoinColumn(nullable=true)
* @Groups({"read", "write"}) * @Groups({"read", "write"})
* @Assert\NotBlank(groups={AccompanyingPeriod::STEP_CLOSED})
*/ */
private $closingMotive = null; private $closingMotive = null;

View File

@ -0,0 +1,22 @@
<?php
declare(strict_types=1);
namespace Chill\PersonBundle\Form;
use Chill\MainBundle\Form\Type\ChillDateType;
use Chill\PersonBundle\Form\Type\ClosingMotivePickerType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
class AccompanyingCourseType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('closingDate', ChillDateType::class,
[
'required' => true,
]);
$builder->add('closingMotive', ClosingMotivePickerType::class);
}
}

View File

@ -0,0 +1,28 @@
{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %}
{% block content %}
<h1>{{ "Close accompanying course"|trans }}</h1>
{{ form_start(form) }}
{{ form_row(form.closingDate) }}
{{ form_row(form.closingMotive) }}
{% set accompanying_course_id = null %}
{% if accompanyingCourse %}
{% set accompanying_course_id = accompanyingCourse.id %}
{% endif %}
<ul class="record_actions sticky-form-buttons">
<li class="cancel">
<a href="{{ chill_return_path_or('chill_person_accompanying_course_index', {'accompanying_period_id' : accompanyingCourse.id}) }}" class="btn btn-cancel">
{{ 'Return'|trans }}
</a>
</li>
<li>
<button class="btn btn-update" type="submit">{{ 'Save'|trans }}</button>
</li>
</ul>
{{ form_end(form) }}
{% endblock %}