rdv: others pages: edit, list

This commit is contained in:
nobohan
2021-07-19 17:18:56 +02:00
parent d4ec5d137e
commit 7e02b284ca
8 changed files with 157 additions and 125 deletions

View File

@@ -100,45 +100,6 @@ class CalendarController extends AbstractController
));
}
// public function selectTypeAction(Request $request): Response
// {
// $em = $this->getDoctrine()->getManager();
// $view = null;
// [$person, $accompanyingPeriod] = $this->getEntity($request);
// if ($accompanyingPeriod instanceof AccompanyingPeriod) {
// $view = 'ChillCalendarBundle:Calendar:selectTypeAccompanyingCourse.html.twig';
// } elseif ($person instanceof Person) {
// $view = 'ChillCalendarBundle:Calendar:selectTypePerson.html.twig';
// }
// $data = [];
// $activityTypeCategories = $em->getRepository(\Chill\CalendarBundle\Entity\ActivityTypeCategory::class)
// ->findBy(['active' => true], ['ordering' => 'ASC']);
// foreach ($activityTypeCategories as $activityTypeCategory) {
// $activityTypes = $em->getRepository(\Chill\ActivityBundle\Entity\ActivityType::class)
// ->findBy(['active' => true, 'category' => $activityTypeCategory], ['ordering' => 'ASC']);
// $data[] = [
// 'activityTypeCategory' => $activityTypeCategory,
// 'activityTypes' => $activityTypes,
// ];
// }
// if ($view === null) {
// throw $this->createNotFoundException('Template not found');
// }
// return $this->render($view, [
// 'person' => $person,
// 'accompanyingCourse' => $accompanyingPeriod,
// 'data' => $data,
// ]);
// }
/**
* Create a new calendar item
* @Route("/{_locale}/calendar/new", name="chill_calendar_calendar_new")
@@ -251,7 +212,7 @@ class CalendarController extends AbstractController
{
$em = $this->getDoctrine()->getManager();
[$person, $accompanyingPeriod] = $this->getEntity($request);
[$user, $accompanyingPeriod] = $this->getEntity($request);
if ($accompanyingPeriod instanceof AccompanyingPeriod) {
$view = 'ChillCalendarBundle:Calendar:editAccompanyingCourse.html.twig';
@@ -267,9 +228,6 @@ class CalendarController extends AbstractController
}
$form = $this->createForm(CalendarType::class, $entity, [
'center' => $entity->getCenter(),
'role' => new Role('CHILL_ACTIVITY_UPDATE'),
'activityType' => $entity->getType(),
'accompanyingPeriod' => $accompanyingPeriod,
])->handleRequest($request);
@@ -279,25 +237,25 @@ class CalendarController extends AbstractController
$this->addFlash('success', $this->get('translator')->trans('Success : activity updated!'));
$params = $this->buildParamsToUrl($person, $accompanyingPeriod);
$params = $this->buildParamsToUrl($user, $accompanyingPeriod);
$params['id'] = $id;
return $this->redirectToRoute('chill_activity_activity_show', $params);
}
$deleteForm = $this->createDeleteForm($id, $person, $accompanyingPeriod);
$deleteForm = $this->createDeleteForm($id, $user, $accompanyingPeriod);
if ($view === null) {
throw $this->createNotFoundException('Template not found');
}
$activity_array = $this->serializer->normalize($entity, 'json', ['groups' => 'read']);
$entity_array = $this->serializer->normalize($entity, 'json', ['groups' => 'read']);
return $this->render($view, array(
'entity' => $entity,
'edit_form' => $form->createView(),
'entity' => $entity,
'form' => $form->createView(),
'delete_form' => $deleteForm->createView(),
'accompanyingCourse' => $accompanyingPeriod,
'activity_json' => $activity_array
'entity_json' => $entity_array
));
}