mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
rdv: fullcalendar: save calendarRange id as an extended prop in the calendar entity
This commit is contained in:
parent
07eb5c797a
commit
a70d5cc263
@ -15,6 +15,7 @@ use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||
|
||||
use Chill\MainBundle\Form\Type\CommentType;
|
||||
use Chill\CalendarBundle\Entity\Calendar;
|
||||
use Chill\CalendarBundle\Entity\CalendarRange;
|
||||
use Chill\CalendarBundle\Entity\CancelReason;
|
||||
use Chill\CalendarBundle\Entity\Invite;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
@ -145,6 +146,24 @@ class CalendarType extends AbstractType
|
||||
))
|
||||
;
|
||||
|
||||
$builder->add('calendarRange', HiddenType::class);
|
||||
$builder->get('calendarRange')
|
||||
->addModelTransformer(new CallbackTransformer(
|
||||
function (?CalendarRange $calendarRange): int {
|
||||
if (NULL !== $calendarRange) {
|
||||
$res = $calendarRange->getId();
|
||||
} else {
|
||||
$res = -1;
|
||||
}
|
||||
return $res;
|
||||
},
|
||||
function (?string $calendarRangeId): CalendarRange {
|
||||
return $this->om->getRepository(CalendarRange::class)->findOneBy(['id' => (int) $calendarRangeId]);
|
||||
}
|
||||
))
|
||||
;
|
||||
|
||||
|
||||
// $builder->add('invites', HiddenType::class);
|
||||
// $builder->get('invites')
|
||||
// ->addModelTransformer(new CallbackTransformer(
|
||||
|
@ -63,8 +63,8 @@ export default {
|
||||
select: this.onDateSelect,
|
||||
eventChange: this.onEventChange,
|
||||
eventClick: this.onEventClick,
|
||||
eventMouseEnter: this.onEventMouseEnter,
|
||||
eventMouseLeave: this.onEventMouseLeave,
|
||||
// eventMouseEnter: this.onEventMouseEnter,
|
||||
// eventMouseLeave: this.onEventMouseLeave,
|
||||
selectMirror: true,
|
||||
editable: true,
|
||||
headerToolbar: {
|
||||
@ -82,9 +82,6 @@ export default {
|
||||
// console.log(calendar)
|
||||
},
|
||||
updateEventsSource() {
|
||||
console.log('updateEventsSource')
|
||||
console.log(this.calendarEvents.selected)
|
||||
|
||||
this.calendarOptions.eventSources = this.calendarEvents.selected;
|
||||
if (window.startDate !== undefined) {
|
||||
this.calendarEvents.selected.push(currentEvent);
|
||||
@ -94,12 +91,14 @@ export default {
|
||||
this.$store.dispatch('createEvent', payload);
|
||||
},
|
||||
onEventChange(payload) {
|
||||
console.log(payload.event.extendedProps);
|
||||
console.log(this.calendarOptions.eventSources)
|
||||
this.$store.dispatch('updateEvent', payload);
|
||||
},
|
||||
onEventClick(payload) {
|
||||
payload.event.setProp('backgroundColor','#3788d8');
|
||||
payload.event.setProp('textColor','#ffffff');
|
||||
this.$store.dispatch('updateEvent', payload);
|
||||
//this.$store.dispatch('updateEvent', payload);
|
||||
},
|
||||
onEventMouseEnter(payload) {
|
||||
payload.event.setProp('borderColor','#444444');
|
||||
|
@ -29,7 +29,7 @@ const store = createStore({
|
||||
strict: debug,
|
||||
state: {
|
||||
activity: mapEntity(window.entity),
|
||||
events: []
|
||||
currentEvent: null
|
||||
},
|
||||
mutations: {
|
||||
|
||||
@ -65,7 +65,7 @@ const store = createStore({
|
||||
// Calendar
|
||||
setEvents(state, payload) {
|
||||
console.log(payload)
|
||||
state.events.push( {start: payload.start, end: payload.end})
|
||||
state.currentEvent = {start: payload.start, end: payload.end}
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
@ -121,6 +121,8 @@ const store = createStore({
|
||||
startDateInput.value = payload.event.start.toISOString();
|
||||
let endDateInput = document.getElementById("chill_calendarbundle_calendar_endDate");
|
||||
endDateInput.value = payload.event.end.toISOString();
|
||||
let calendarRangeInput = document.getElementById("chill_calendarbundle_calendar_calendarRange");
|
||||
calendarRangeInput.value = payload.event.extendedProps.calendarRangeId;
|
||||
commit('setEvents', payload);
|
||||
},
|
||||
|
||||
|
@ -80,6 +80,7 @@ export default {
|
||||
({
|
||||
start: i.startDate.datetime,
|
||||
end: i.endDate.datetime,
|
||||
calendarRangeId: i.id
|
||||
//display: 'background' // can be an option for the disponibility
|
||||
})
|
||||
);
|
||||
@ -93,7 +94,7 @@ export default {
|
||||
|
||||
this.users.loaded = users;
|
||||
this.options = users;
|
||||
|
||||
console.log(calendarEvents)
|
||||
this.calendarEvents.loaded = calendarEvents;
|
||||
whoami().then(me => new Promise((resolve, reject) => {
|
||||
let currentUser = users.find(u => u.id === me.id);
|
||||
|
@ -34,6 +34,10 @@
|
||||
{{ form_row(form.endDate) }}
|
||||
{% endif %}
|
||||
|
||||
{%- if form.calendarRange is defined -%}
|
||||
{{ form_row(form.calendarRange) }}
|
||||
{% endif %}
|
||||
|
||||
.. location
|
||||
|
||||
{%- if form.cancelReason is defined -%}
|
||||
|
@ -34,6 +34,10 @@
|
||||
{{ form_row(form.endDate) }}
|
||||
{% endif %}
|
||||
|
||||
{%- if form.calendarRange is defined -%}
|
||||
{{ form_row(form.calendarRange) }}
|
||||
{% endif %}
|
||||
|
||||
.. location
|
||||
|
||||
{%- if form.cancelReason is defined -%}
|
||||
|
Loading…
x
Reference in New Issue
Block a user