diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarAPIController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarAPIController.php new file mode 100644 index 000000000..d6e3586b2 --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarAPIController.php @@ -0,0 +1,22 @@ +query->has('main_user')) { + + $qb->where('e.mainUser = :main_user') + ->setParameter('main_user', $request->query->get('main_user')); + + } + } + +} diff --git a/src/Bundle/ChillCalendarBundle/DependencyInjection/ChillCalendarExtension.php b/src/Bundle/ChillCalendarBundle/DependencyInjection/ChillCalendarExtension.php index 8b71b26f0..4b6a0cadf 100644 --- a/src/Bundle/ChillCalendarBundle/DependencyInjection/ChillCalendarExtension.php +++ b/src/Bundle/ChillCalendarBundle/DependencyInjection/ChillCalendarExtension.php @@ -75,6 +75,27 @@ class ChillCalendarExtension extends Extension implements PrependExtensionInterf ] ], ] + ], + [ + 'controller' => \Chill\CalendarBundle\Controller\CalendarAPIController::class, + 'class' => \Chill\CalendarBundle\Entity\Calendar::class, + 'name' => 'calendar', + 'base_path' => '/api/1.0/calendar/calendar', + 'base_role' => 'ROLE_USER', + 'actions' => [ + '_index' => [ + 'methods' => [ + Request::METHOD_GET => true, + Request::METHOD_HEAD => true + ], + ], + '_entity' => [ + 'methods' => [ + Request::METHOD_GET => true, + Request::METHOD_HEAD => true + ] + ], + ] ] ] ]); diff --git a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php index 3ee5bcc54..06a97fd7f 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php +++ b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php @@ -41,17 +41,18 @@ class Calendar /** * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User") + * @Groups({"read"}) */ private User $user; /** * @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod") - * @Groups({"read"}) */ private AccompanyingPeriod $accompanyingPeriod; /** * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User") + * @Groups({"read"}) */ private ?User $mainUser; @@ -92,11 +93,13 @@ class Calendar /** * @ORM\Column(type="datetimetz_immutable") + * @Groups({"read"}) */ private \DateTimeImmutable $startDate; /** * @ORM\Column(type="datetimetz_immutable") + * @Groups({"read"}) */ private \DateTimeImmutable $endDate; diff --git a/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/App.vue b/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/App.vue index 65c77c937..7f0082a72 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/App.vue +++ b/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/App.vue @@ -51,7 +51,7 @@ export default { calendarEvents: { loaded: [], selected: [], - userEvents: [], //TODO load user calendar events + user: [], //TODO load user calendar events current: currentEvent }, calendarOptions: { @@ -81,22 +81,24 @@ export default { console.log(window.startDate) // let calendar = this.$refs.fullCalendar.getApi() // console.log(calendar) + this.calendarEvents.selected.push(this.calendarEvents.user); + this.calendarOptions.eventSources = this.calendarEvents.selected; + console.log(this.calendarOptions.eventSources) + }, updateEventsSource() { - this.calendarOptions.eventSources = this.calendarEvents.selected; if (window.startDate !== undefined) { this.calendarEvents.selected.push(currentEvent); } + this.calendarEvents.selected.push(this.calendarEvents.user); + this.calendarOptions.eventSources = this.calendarEvents.selected; + console.log(this.calendarOptions.eventSources) }, onDateSelect(payload) { Object.assign(payload, {users: this.users}); this.$store.dispatch('createEvent', payload); }, onEventChange(payload) { - console.log(payload.event); - console.log(payload.event.extendedProps); - console.log(payload.event.source); - console.log(payload.event.source.id); console.log(this.calendarOptions.eventSources) this.$store.dispatch('updateEvent', payload); }, diff --git a/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/store.js b/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/store.js index ba4329ff4..03d0548dc 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/store.js +++ b/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/store.js @@ -113,7 +113,6 @@ const store = createStore({ startDateInput.value = payload.startStr; let endDateInput = document.getElementById("chill_calendarbundle_calendar_endDate"); endDateInput.value = payload.endStr; - //TODO specify the mainUserInput value if not from a source let mainUserInput = document.getElementById("chill_calendarbundle_calendar_mainUser"); mainUserInput.value = payload.users.logged.id; commit('setEvents', payload); @@ -128,7 +127,6 @@ const store = createStore({ calendarRangeInput.value = Number(payload.event.extendedProps.calendarRangeId); let mainUserInput = document.getElementById("chill_calendarbundle_calendar_mainUser"); mainUserInput.value = Number(payload.event.source.id); - //TODO check if working when reiszing an event commit('setEvents', payload); }, diff --git a/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/_components/CalendarUserSelector/CalendarUserSelector.vue b/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/_components/CalendarUserSelector/CalendarUserSelector.vue index a22d0103f..064e550a9 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/_components/CalendarUserSelector/CalendarUserSelector.vue +++ b/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/_components/CalendarUserSelector/CalendarUserSelector.vue @@ -22,7 +22,7 @@