mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
accompanying period work: can delete the work
This commit is contained in:
parent
6afd8ae3cd
commit
d94c367e3d
@ -13,6 +13,7 @@ use Symfony\Component\Serializer\SerializerInterface;
|
|||||||
use Symfony\Component\Translation\TranslatorInterface;
|
use Symfony\Component\Translation\TranslatorInterface;
|
||||||
use Symfony\Component\Form\Form;
|
use Symfony\Component\Form\Form;
|
||||||
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository;
|
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||||
|
|
||||||
class AccompanyingCourseWorkController extends AbstractController
|
class AccompanyingCourseWorkController extends AbstractController
|
||||||
@ -21,17 +22,20 @@ class AccompanyingCourseWorkController extends AbstractController
|
|||||||
private SerializerInterface $serializer;
|
private SerializerInterface $serializer;
|
||||||
private AccompanyingPeriodWorkRepository $workRepository;
|
private AccompanyingPeriodWorkRepository $workRepository;
|
||||||
private PaginatorFactory $paginator;
|
private PaginatorFactory $paginator;
|
||||||
|
protected LoggerInterface $logger;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
TranslatorInterface $trans,
|
TranslatorInterface $trans,
|
||||||
SerializerInterface $serializer,
|
SerializerInterface $serializer,
|
||||||
AccompanyingPeriodWorkRepository $workRepository,
|
AccompanyingPeriodWorkRepository $workRepository,
|
||||||
PaginatorFactory $paginator
|
PaginatorFactory $paginator
|
||||||
|
// LoggerInterface $logger,
|
||||||
) {
|
) {
|
||||||
$this->trans = $trans;
|
$this->trans = $trans;
|
||||||
$this->serializer = $serializer;
|
$this->serializer = $serializer;
|
||||||
$this->workRepository = $workRepository;
|
$this->workRepository = $workRepository;
|
||||||
$this->paginator = $paginator;
|
$this->paginator = $paginator;
|
||||||
|
// $this->logger = $logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -114,65 +118,48 @@ class AccompanyingCourseWorkController extends AbstractController
|
|||||||
* @Route(
|
* @Route(
|
||||||
* "{_locale}/person/accompanying-period/work/{id}/delete",
|
* "{_locale}/person/accompanying-period/work/{id}/delete",
|
||||||
* name="chill_person_accompanying_period_work_delete",
|
* name="chill_person_accompanying_period_work_delete",
|
||||||
* methods={"GET"}
|
* methods={"GET", "POST", "DELETE"}
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
public function deleteWork(AccompanyingPeriodWork $work): Response
|
public function deleteWork(AccompanyingPeriodWork $work, Request $request): Response
|
||||||
{
|
{
|
||||||
// TODO ACL
|
// TODO ACL
|
||||||
|
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
dump($work);
|
dump($work);
|
||||||
// [$person, $accompanyingPeriod] = $this->getEntity($request);
|
|
||||||
|
|
||||||
// /* @var $activity Activity */
|
|
||||||
// $activity = $em->getRepository('ChillActivityBundle:Activity')->find($id);
|
|
||||||
|
|
||||||
// if (!$activity) {
|
|
||||||
// throw $this->createNotFoundException('Unable to find Activity entity.');
|
|
||||||
// }
|
|
||||||
|
|
||||||
// TODO
|
|
||||||
// $this->denyAccessUnlessGranted('CHILL_ACTIVITY_DELETE', $activity);
|
|
||||||
|
|
||||||
$form = $this->createDeleteForm($work->getId());
|
$form = $this->createDeleteForm($work->getId());
|
||||||
|
|
||||||
// if ($request->getMethod() === Request::METHOD_DELETE) {
|
if ($request->getMethod() === Request::METHOD_DELETE) {
|
||||||
// $form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
|
||||||
// if ($form->isValid()) {
|
if ($form->isValid()) {
|
||||||
|
|
||||||
// // $this->logger->notice("An activity has been removed", array(
|
// $this->logger->notice("An accompanying period work has been removed", [
|
||||||
// // 'by_user' => $this->getUser()->getUsername(),
|
// 'by_user' => $this->getUser()->getUsername(),
|
||||||
// // 'activity_id' => $activity->getId(),
|
// 'work_id' => $work->getId(),
|
||||||
// // 'person_id' => $activity->getPerson() ? $activity->getPerson()->getId() : null,
|
// 'accompanying_period_id' => $work->getAccompanyingPeriod()->getId()
|
||||||
// // 'comment' => $activity->getComment()->getComment(),
|
// ]);
|
||||||
// // 'scope_id' => $activity->getScope() ? $activity->getScope()->getId() : null,
|
|
||||||
// // 'reasons_ids' => $activity->getReasons()
|
|
||||||
// // ->map(function ($ar) { return $ar->getId(); })
|
|
||||||
// // ->toArray(),
|
|
||||||
// // 'type_id' => $activity->getType()->getId(),
|
|
||||||
// // 'duration' => $activity->getDurationTime() ? $activity->getDurationTime()->format('U') : null,
|
|
||||||
// // 'date' => $activity->getDate()->format('Y-m-d'),
|
|
||||||
// // 'attendee' => $activity->getAttendee()
|
|
||||||
// // )); //TODO
|
|
||||||
|
|
||||||
// $em->remove($work);
|
$em->remove($work);
|
||||||
// $em->flush();
|
$em->flush();
|
||||||
|
|
||||||
// // $this->addFlash('success', $this->get('translator')
|
$this->addFlash(
|
||||||
// // ->trans("The activity has been successfully removed."));
|
'success',
|
||||||
|
//$translator->trans("The accompanying period work has been successfully removed.") //TODO translation
|
||||||
|
"The accompanying period work has been successfully removed."
|
||||||
|
);
|
||||||
|
|
||||||
// // $params = $this->buildParamsToUrl($person, $accompanyingPeriod);
|
return $this->redirectToRoute('chill_person_accompanying_period_work_list', [
|
||||||
// // return $this->redirectToRoute('chill_activity_activity_list', $params);
|
'id' => $work->getAccompanyingPeriod()->getId()
|
||||||
// }
|
]);
|
||||||
// }
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $this->render('@ChillPerson/AccompanyingCourseWork/delete.html.twig', array(
|
return $this->render('@ChillPerson/AccompanyingCourseWork/delete.html.twig', [
|
||||||
'accompanyingCourse' => $work->getAccompanyingPeriod(),
|
'accompanyingCourse' => $work->getAccompanyingPeriod(),
|
||||||
'work' => $work,
|
'work' => $work,
|
||||||
'delete_form' => $form->createView()
|
'delete_form' => $form->createView()
|
||||||
));
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createDeleteForm(int $id): Form
|
private function createDeleteForm(int $id): Form
|
||||||
@ -182,7 +169,7 @@ class AccompanyingCourseWorkController extends AbstractController
|
|||||||
return $this->createFormBuilder()
|
return $this->createFormBuilder()
|
||||||
->setAction($this->generateUrl('chill_person_accompanying_period_work_delete', $params))
|
->setAction($this->generateUrl('chill_person_accompanying_period_work_delete', $params))
|
||||||
->setMethod('DELETE')
|
->setMethod('DELETE')
|
||||||
->add('submit', SubmitType::class, array('label' => 'Delete'))
|
->add('submit', SubmitType::class, ['label' => 'Delete'])
|
||||||
->getForm()
|
->getForm()
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %}
|
{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %}
|
||||||
|
|
||||||
{% set activeRouteKey = 'chill_activity_activity_list' %}
|
{% set activeRouteKey = 'chill_person_accompanying_period_work_list' %}
|
||||||
|
|
||||||
{% block title 'Remove activity'|trans %}
|
{% block title 'accompanying_course_work.remove'|trans %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{{ include('@ChillMain/Util/confirmation_template.html.twig',
|
{{ include('@ChillMain/Util/confirmation_template.html.twig',
|
||||||
{
|
{
|
||||||
'title' : 'Remove activity'|trans,
|
'title' : 'accompanying_course_work.remove'|trans,
|
||||||
'confirm_question' : 'Are you sure you want to remove the activity about "%name%" ?'|trans({ '%name%' : work.id } ),
|
'confirm_question' : 'Are you sure you want to remove the work of the accompanying period %name% ?'|trans({ '%name%' : accompanyingCourse.id } ),
|
||||||
'cancel_route' : 'chill_activity_activity_list',
|
'cancel_route' : 'chill_person_accompanying_period_work_list',
|
||||||
'cancel_parameters' : { 'accompanying_period_id' : work.id},
|
'cancel_parameters' : {'id' : accompanyingCourse.id},
|
||||||
'form' : delete_form
|
'form' : delete_form
|
||||||
} ) }}
|
} ) }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -103,6 +103,11 @@
|
|||||||
href="{{ chill_path_add_return_path('chill_person_accompanying_period_work_edit', { 'id': w.id }) }}"
|
href="{{ chill_path_add_return_path('chill_person_accompanying_period_work_edit', { 'id': w.id }) }}"
|
||||||
>{% if buttonText is not defined or buttonText == true %}{{ 'Edit'|trans }}{% endif %}</a>
|
>{% if buttonText is not defined or buttonText == true %}{{ 'Edit'|trans }}{% endif %}</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<a class="btn btn-delete" title="{{ 'Delete'|trans }}"
|
||||||
|
href="{{ path('chill_person_accompanying_period_work_delete', { 'id': w.id } ) }}"
|
||||||
|
>{% if buttonText is not defined or buttonText == true %}{{ 'Delete'|trans }}{% endif %}</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -405,6 +405,7 @@ Back to household: Revenir au ménage
|
|||||||
# accompanying course work
|
# accompanying course work
|
||||||
Accompanying Course Actions: Actions d'accompagnements
|
Accompanying Course Actions: Actions d'accompagnements
|
||||||
Accompanying Course Action: Action d'accompagnement
|
Accompanying Course Action: Action d'accompagnement
|
||||||
|
Are you sure you want to remove the work of the accompanying period %name% ?: Êtes-vous sûr de vouloir supprimer l'action de la période d'accompagnement %name% ?
|
||||||
accompanying_course_work:
|
accompanying_course_work:
|
||||||
create: Créer une action
|
create: Créer une action
|
||||||
Create accompanying course work: Créer une action d'accompagnement
|
Create accompanying course work: Créer une action d'accompagnement
|
||||||
@ -419,6 +420,7 @@ accompanying_course_work:
|
|||||||
results: Résultats - orientations
|
results: Résultats - orientations
|
||||||
goal: Objectif - motif - dispositif
|
goal: Objectif - motif - dispositif
|
||||||
Any work: Aucune action d'accompagnement
|
Any work: Aucune action d'accompagnement
|
||||||
|
remove: Supprimer une action d'accompagnement
|
||||||
|
|
||||||
#
|
#
|
||||||
Person addresses: Adresses de résidence
|
Person addresses: Adresses de résidence
|
||||||
|
Loading…
x
Reference in New Issue
Block a user