mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
rdv: connect fullcalendar vue component to startDate and endDate fields
This commit is contained in:
parent
cc3e7f54a7
commit
5181098339
@ -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'));
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ class Calendar
|
||||
/**
|
||||
* @ORM\Column(type="boolean", nullable=true)
|
||||
*/
|
||||
private boolean $sendSMS;
|
||||
private ?bool $sendSMS;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
@ -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(
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -30,7 +30,7 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
onDateSelect(payload) {
|
||||
this.$store.dispatch('onDateSelect', payload);
|
||||
this.$store.dispatch('setDateRange', payload);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
const calendarMessages = {
|
||||
fr: {
|
||||
choose_your_date: 'Sélectionner vos dates',
|
||||
choose_your_date: 'Sélectionnez vos dates',
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -68,7 +68,7 @@
|
||||
</li>
|
||||
<li>
|
||||
<button class="btn btn-create" type="submit">
|
||||
{{ 'Create'|trans }}
|
||||
{{ 'Update'|trans }}
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
|
Loading…
x
Reference in New Issue
Block a user