diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php index 893d8eefc..5e5746387 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php @@ -238,11 +238,11 @@ class CalendarController extends AbstractController $em->persist($entity); $em->flush(); - $this->addFlash('success', $this->get('translator')->trans('Success : activity updated!')); + $this->addFlash('success', $this->get('translator')->trans('Success : calendar item updated!')); $params = $this->buildParamsToUrl($user, $accompanyingPeriod); $params['id'] = $id; - return $this->redirectToRoute('chill_activity_activity_show', $params); + return $this->redirectToRoute('chill_calendar_calendar_show', $params); } elseif ($form->isSubmitted() and !$form->isValid()) { $this->addFlash('error', $this->get('translator')->trans('This form contains errors')); } diff --git a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php index 45d47f3c5..618b354b7 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php +++ b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php @@ -125,7 +125,7 @@ class Calendar /** * @ORM\Column(type="boolean", nullable=true) */ - private boolean $sendSMS; + private ?bool $sendSMS; public function __construct() { diff --git a/src/Bundle/ChillCalendarBundle/Form/CalendarType.php b/src/Bundle/ChillCalendarBundle/Form/CalendarType.php index 2c756898e..9ff29a52c 100644 --- a/src/Bundle/ChillCalendarBundle/Form/CalendarType.php +++ b/src/Bundle/ChillCalendarBundle/Form/CalendarType.php @@ -21,7 +21,7 @@ use Chill\MainBundle\Entity\User; use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\PersonBundle\Entity\Person; use Chill\ThirdPartyBundle\Entity\ThirdParty; - +use DateTimeImmutable; class CalendarType extends AbstractType { @@ -55,16 +55,6 @@ class CalendarType extends AbstractType ->add('comment', CommentType::class, [ 'required' => false ]) - ->add('startDate', DateType::class, [ - 'required' => true, - 'input' => 'datetime_immutable', - 'widget' => 'single_text' - ]) - ->add('endDate', DateType::class, [ - 'required' => true, - 'input' => 'datetime_immutable', - 'widget' => 'single_text' - ]) ->add('cancelReason', EntityType::class, [ 'required' => false, 'class' => CancelReason::class, @@ -82,6 +72,41 @@ class CalendarType extends AbstractType ]) ; + $builder->add('startDate', HiddenType::class); + $builder->get('startDate') + ->addModelTransformer(new CallbackTransformer( + function (?DateTimeImmutable $dateTimeImmutable): string { + if (NULL !== $dateTimeImmutable) { + $res = date_format($dateTimeImmutable, 'Y-m-d H:i:s'); + } else { + $res = ''; + } + return $res; + }, + function (?string $dateAsString): DateTimeImmutable { + dump($dateAsString); + return new DateTimeImmutable($dateAsString); + } + )) + ; + + $builder->add('endDate', HiddenType::class); + $builder->get('endDate') + ->addModelTransformer(new CallbackTransformer( + function (?DateTimeImmutable $dateTimeImmutable): string { + if (NULL !== $dateTimeImmutable) { + $res = date_format($dateTimeImmutable, 'Y-m-d H:i:s'); + } else { + $res = ''; + } + return $res; + }, + function (?string $dateAsString): DateTimeImmutable { + return new DateTimeImmutable($dateAsString); + } + )) + ; + $builder->add('persons', HiddenType::class); $builder->get('persons') ->addModelTransformer(new CallbackTransformer( diff --git a/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/store.js b/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/store.js index 77a9344c7..aa141fc78 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/store.js +++ b/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/store.js @@ -63,7 +63,7 @@ const store = createStore({ }; }, // Calendar - onDateSelect(state, payload) { + setEvents(state, payload) { console.log(payload) state.events.push( {start: payload.start, end: payload.end}) } @@ -107,9 +107,13 @@ const store = createStore({ }, // Calendar - onDateSelect({ commit }, payload) { - console.log('### action onDateSelect', payload); - commit('onDateSelect', payload); + setDateRange({ commit }, payload) { + console.log('### action setDateRange', payload); + let startDateInput = document.getElementById("chill_calendarbundle_calendar_startDate"); + startDateInput.value = payload.startStr; + let endDateInput = document.getElementById("chill_calendarbundle_calendar_endDate"); + endDateInput.value = payload.endStr; + commit('setEvents', payload); } } }); diff --git a/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/_components/CalendarRange/CalendarRange.vue b/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/_components/CalendarRange/CalendarRange.vue index d246c396c..6692ed40e 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/_components/CalendarRange/CalendarRange.vue +++ b/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/_components/CalendarRange/CalendarRange.vue @@ -30,7 +30,7 @@ export default { }, methods: { onDateSelect(payload) { - this.$store.dispatch('onDateSelect', payload); + this.$store.dispatch('setDateRange', payload); } } } diff --git a/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/_components/CalendarRange/js/i18n.js b/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/_components/CalendarRange/js/i18n.js index dc20ed9d4..5f1dd867a 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/_components/CalendarRange/js/i18n.js +++ b/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/_components/CalendarRange/js/i18n.js @@ -1,6 +1,6 @@ const calendarMessages = { fr: { - choose_your_date: 'Sélectionner vos dates', + choose_your_date: 'Sélectionnez vos dates', } }; diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/edit.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/edit.html.twig index c8f869902..0f0548c47 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/edit.html.twig +++ b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/edit.html.twig @@ -68,7 +68,7 @@