mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Merge branch 'deleteAccompanyingPeriodWork_234' into 'master'
Delete AccompanyingPeriodWork See merge request Chill-Projet/chill-bundles!199
This commit is contained in:
commit
831b4f354c
@ -12,13 +12,14 @@ and this project adheres to
|
||||
|
||||
<!-- write down unreleased development here -->
|
||||
* unnecessary whitespace removed from person banner after person-id + double parentheses removed (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/290)
|
||||
|
||||
* [person]: delete accompanying period work, including related objects (cascade) (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/36)
|
||||
|
||||
## Test releases
|
||||
|
||||
### Test release 2021-11-08
|
||||
|
||||
* [person]: Display the name of a user when searching after a User (TMS)
|
||||
>>>>>>> CHANGELOG.md
|
||||
* [person]: Add civility to the person
|
||||
* [person]: Various improvements on the edit person form
|
||||
* [person]: Set available_languages and available_countries as parameters for use in the edit person form
|
||||
|
@ -10,7 +10,7 @@
|
||||
'title' : 'Remove activity'|trans,
|
||||
'confirm_question' : 'Are you sure you want to remove the activity about "%name%" ?'|trans({ '%name%' : accompanyingCourse.id } ),
|
||||
'cancel_route' : 'chill_activity_activity_list',
|
||||
'cancel_parameters' : { 'accompanying_course_id' : accompanyingCourse.id, 'id' : activity.id },
|
||||
'cancel_parameters' : { 'accompanying_period_id' : accompanyingCourse.id, 'id' : activity.id },
|
||||
'form' : delete_form
|
||||
} ) }}
|
||||
{% endblock %}
|
||||
|
@ -11,7 +11,10 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Serializer\SerializerInterface;
|
||||
use Symfony\Component\Translation\TranslatorInterface;
|
||||
use Symfony\Component\Form\Form;
|
||||
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
|
||||
class AccompanyingCourseWorkController extends AbstractController
|
||||
{
|
||||
@ -19,17 +22,20 @@ class AccompanyingCourseWorkController extends AbstractController
|
||||
private SerializerInterface $serializer;
|
||||
private AccompanyingPeriodWorkRepository $workRepository;
|
||||
private PaginatorFactory $paginator;
|
||||
protected LoggerInterface $logger;
|
||||
|
||||
public function __construct(
|
||||
TranslatorInterface $trans,
|
||||
SerializerInterface $serializer,
|
||||
AccompanyingPeriodWorkRepository $workRepository,
|
||||
PaginatorFactory $paginator
|
||||
PaginatorFactory $paginator,
|
||||
LoggerInterface $chillLogger
|
||||
) {
|
||||
$this->trans = $trans;
|
||||
$this->serializer = $serializer;
|
||||
$this->workRepository = $workRepository;
|
||||
$this->paginator = $paginator;
|
||||
$this->logger = $logger;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -106,4 +112,65 @@ class AccompanyingCourseWorkController extends AbstractController
|
||||
'paginator' => $paginator
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @Route(
|
||||
* "{_locale}/person/accompanying-period/work/{id}/delete",
|
||||
* name="chill_person_accompanying_period_work_delete",
|
||||
* methods={"GET", "POST", "DELETE"}
|
||||
* )
|
||||
*/
|
||||
public function deleteWork(AccompanyingPeriodWork $work, Request $request): Response
|
||||
{
|
||||
// TODO ACL
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$form = $this->createDeleteForm($work->getId());
|
||||
|
||||
if ($request->getMethod() === Request::METHOD_DELETE) {
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isValid()) {
|
||||
|
||||
$this->logger->notice("An accompanying period work has been removed", [
|
||||
'by_user' => $this->getUser()->getUsername(),
|
||||
'work_id' => $work->getId(),
|
||||
'accompanying_period_id' => $work->getAccompanyingPeriod()->getId()
|
||||
]);
|
||||
|
||||
$em->remove($work);
|
||||
$em->flush();
|
||||
|
||||
$this->addFlash(
|
||||
'success',
|
||||
$this->trans->trans("The accompanying period work has been successfully removed.")
|
||||
);
|
||||
|
||||
return $this->redirectToRoute('chill_person_accompanying_period_work_list', [
|
||||
'id' => $work->getAccompanyingPeriod()->getId()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render('@ChillPerson/AccompanyingCourseWork/delete.html.twig', [
|
||||
'accompanyingCourse' => $work->getAccompanyingPeriod(),
|
||||
'work' => $work,
|
||||
'delete_form' => $form->createView()
|
||||
]);
|
||||
}
|
||||
|
||||
private function createDeleteForm(int $id): Form
|
||||
{
|
||||
$params['id'] = $id;
|
||||
|
||||
return $this->createFormBuilder()
|
||||
->setAction($this->generateUrl('chill_person_accompanying_period_work_delete', $params))
|
||||
->setMethod('DELETE')
|
||||
->add('submit', SubmitType::class, ['label' => 'Delete'])
|
||||
->getForm()
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ use Symfony\Component\Validator\Constraints as Assert;
|
||||
* @ORM\OneToMany(
|
||||
* targetEntity=AccompanyingPeriodWorkEvaluation::class,
|
||||
* mappedBy="accompanyingPeriodWork",
|
||||
* cascade={"persist"},
|
||||
* cascade={"remove", "persist"},
|
||||
* orphanRemoval=true
|
||||
* )
|
||||
* @Serializer\Groups({"read"})
|
||||
|
@ -70,7 +70,8 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity=StoredObject::class
|
||||
* targetEntity=StoredObject::class,
|
||||
* cascade={"remove"},
|
||||
* )
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
|
@ -26,7 +26,7 @@
|
||||
</div>
|
||||
|
||||
<div v-if="isLoadingSocialActions">
|
||||
<p>spinner</p>
|
||||
<i class="fa fa-circle-o-notch fa-spin fa-fw"></i>
|
||||
</div>
|
||||
|
||||
<div v-if="hasSocialActionPicked" id="persons">
|
||||
@ -72,7 +72,7 @@
|
||||
{{ $t('action.save') }}
|
||||
</button>
|
||||
<button class="btn btn-save" v-show="isPostingWork" disabled>
|
||||
{{ $t('Save') }}
|
||||
{{ $t('action.save') }}
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -0,0 +1,34 @@
|
||||
{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %}
|
||||
|
||||
{% set activeRouteKey = 'chill_person_accompanying_period_work_list' %}
|
||||
|
||||
{% block title 'accompanying_course_work.remove'|trans %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<div class="accompanying_course_work-list">
|
||||
<h2 class="badge-title">
|
||||
<span class="title_label">{{ 'accompanying_course_work.action'|trans }}</span>
|
||||
<span class="title_action">{{ work.socialAction|chill_entity_render_string }}</span>
|
||||
</h2>
|
||||
|
||||
<div>
|
||||
<h3>{{ "Associated peoples"|trans }}</h3>
|
||||
<ul>
|
||||
{% for p in work.persons %}
|
||||
{{ p|chill_entity_render_box }}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{{ include('@ChillMain/Util/confirmation_template.html.twig',
|
||||
{
|
||||
'title' : 'accompanying_course_work.remove'|trans,
|
||||
'confirm_question' : 'Are you sure you want to remove this work of the accompanying period %name% ?'|trans({ '%name%' : accompanyingCourse.id } ),
|
||||
'cancel_route' : 'chill_person_accompanying_period_work_list',
|
||||
'cancel_parameters' : {'id' : accompanyingCourse.id},
|
||||
'form' : delete_form
|
||||
} ) }}
|
||||
{% endblock %}
|
@ -103,6 +103,11 @@
|
||||
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>
|
||||
</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>
|
||||
|
||||
</div>
|
||||
|
@ -405,6 +405,8 @@ Back to household: Revenir au ménage
|
||||
# accompanying course work
|
||||
Accompanying Course Actions: Actions d'accompagnements
|
||||
Accompanying Course Action: Action d'accompagnement
|
||||
Are you sure you want to remove this work of the accompanying period %name% ?: Êtes-vous sûr de vouloir supprimer cette action de la période d'accompagnement %name% ?
|
||||
The accompanying period work has been successfully removed.: L'action d'accompagnement a été supprimée.
|
||||
accompanying_course_work:
|
||||
create: Créer une action
|
||||
Create accompanying course work: Créer une action d'accompagnement
|
||||
@ -419,6 +421,7 @@ accompanying_course_work:
|
||||
results: Résultats - orientations
|
||||
goal: Objectif - motif - dispositif
|
||||
Any work: Aucune action d'accompagnement
|
||||
remove: Supprimer une action d'accompagnement
|
||||
|
||||
#
|
||||
Person addresses: Adresses de résidence
|
||||
|
Loading…
x
Reference in New Issue
Block a user