diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php index b9952a45d..c59b6d5e6 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php @@ -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 )); } diff --git a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php index 85130df98..8a106efbd 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php +++ b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php @@ -16,6 +16,8 @@ use Chill\CalendarBundle\Entity\CalendarRange; use Chill\CalendarBundle\Entity\Invite; use Chill\ActivityBundle\Entity\Activity; use Chill\CalendarBundle\Repository\CalendarRepository; +use DateInterval; +use DateTimeImmutable; use Symfony\Component\Validator\Constraints\NotBlank; use Symfony\Component\Validator\Constraints\Range; use Symfony\Component\Validator\Mapping\ClassMetadata; @@ -51,7 +53,7 @@ class Calendar /** * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User") */ - private User $mainUser; + private ?User $mainUser; /** * @@ -416,7 +418,6 @@ class Calendar return $this->getInvites(); //TODO get users of the invite } - public static function loadValidatorMetadata(ClassMetadata $metadata): void { $metadata->addPropertyConstraint('startDate', new NotBlank()); diff --git a/src/Bundle/ChillCalendarBundle/Form/CalendarType.php b/src/Bundle/ChillCalendarBundle/Form/CalendarType.php index a4072f12e..00b410f7f 100644 --- a/src/Bundle/ChillCalendarBundle/Form/CalendarType.php +++ b/src/Bundle/ChillCalendarBundle/Form/CalendarType.php @@ -17,6 +17,7 @@ use Chill\MainBundle\Form\Type\CommentType; use Chill\CalendarBundle\Entity\Calendar; use Chill\CalendarBundle\Entity\CancelReason; use Chill\CalendarBundle\Entity\Invite; +use Chill\MainBundle\Entity\User; use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\PersonBundle\Entity\Person; use Chill\ThirdPartyBundle\Entity\ThirdParty; @@ -43,6 +44,14 @@ class CalendarType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { $builder + ->add('mainUser', EntityType::class, array( + 'required' => true, + 'class' => User::class, + 'choice_label' => function (User $entity) { + return $entity->getUsernameCanonical(); + }, + // TODO 'empty_data' => + )) ->add('comment', CommentType::class, array( 'required' => false )) diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/edit.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/edit.html.twig new file mode 100644 index 000000000..c8f869902 --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/edit.html.twig @@ -0,0 +1,76 @@ +
- - {{ calendar.durationTime|date('H:i') }} -
- {% endif %} - - {% if calendar.travelTime and t.travelTimeVisible %} -- - {{ calendar.travelTime|date('H:i') }} -
- {% endif %} -