mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
rdv: add user calendar endpoint + add this calendar in the calendar
This commit is contained in:
parent
dbf72774c2
commit
7c4f976230
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\CalendarBundle\Controller;
|
||||
|
||||
use Chill\MainBundle\CRUD\Controller\ApiController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
|
||||
class CalendarAPIController extends ApiController
|
||||
{
|
||||
|
||||
protected function customizeQuery(string $action, Request $request, $qb): void
|
||||
{
|
||||
if ($request->query->has('main_user')) {
|
||||
|
||||
$qb->where('e.mainUser = :main_user')
|
||||
->setParameter('main_user', $request->query->get('main_user'));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -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
|
||||
]
|
||||
],
|
||||
]
|
||||
]
|
||||
]
|
||||
]);
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
},
|
||||
|
@ -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);
|
||||
},
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
</template>
|
||||
<script>
|
||||
|
||||
import { fetchCalendarRanges } from './js/api'
|
||||
import { fetchCalendarRanges, fetchCalendar } from './js/api'
|
||||
import VueMultiselect from 'vue-multiselect';
|
||||
import { whoami } from 'ChillPersonAssets/vuejs/AccompanyingCourse/api';
|
||||
|
||||
@ -54,9 +54,9 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
init() {
|
||||
this.getUniqueUserCalendarRanges()
|
||||
this.fetchData()
|
||||
},
|
||||
getUniqueUserCalendarRanges() {
|
||||
fetchData() {
|
||||
fetchCalendarRanges().then(calendarRanges => new Promise((resolve, reject) => {
|
||||
let results = calendarRanges.results;
|
||||
|
||||
@ -103,12 +103,33 @@ export default {
|
||||
this.users.logged = me;
|
||||
let currentUser = users.find(u => u.id === me.id);
|
||||
this.value = currentUser;
|
||||
|
||||
fetchCalendar(currentUser.id).then(calendar => new Promise((resolve, reject) => {
|
||||
let results = calendar.results;
|
||||
console.log(results)
|
||||
let events = results.map(i =>
|
||||
({
|
||||
start: i.startDate.datetime,
|
||||
end: i.endDate.datetime,
|
||||
})
|
||||
);
|
||||
let calendarEventsCurrentUser = {
|
||||
events: events,
|
||||
color: 'darkblue',
|
||||
id: 1000
|
||||
};
|
||||
console.log(calendarEventsCurrentUser);
|
||||
this.calendarEvents.user = calendarEventsCurrentUser;
|
||||
|
||||
this.selectUsers(currentUser);
|
||||
|
||||
resolve();
|
||||
}));
|
||||
|
||||
resolve()
|
||||
resolve();
|
||||
}));
|
||||
|
||||
resolve();
|
||||
}))
|
||||
.catch((error) => {
|
||||
this.errorMsg.push(error.message);
|
||||
|
@ -12,6 +12,21 @@ const fetchCalendarRanges = () => {
|
||||
});
|
||||
};
|
||||
|
||||
export {
|
||||
fetchCalendarRanges
|
||||
/*
|
||||
* Endpoint chill_api_single_calendar
|
||||
* method GET, get Calendar events, can be filtered by mainUser
|
||||
* @returns {Promise} a promise containing all Calendar objects
|
||||
*/
|
||||
const fetchCalendar = (mainUserId) => {
|
||||
const url = `/api/1.0/calendar/calendar.json?main_user=${mainUserId}&item_per_page=1000`;
|
||||
return fetch(url)
|
||||
.then(response => {
|
||||
if (response.ok) { return response.json(); }
|
||||
throw Error('Error with request resource response');
|
||||
});
|
||||
};
|
||||
|
||||
export {
|
||||
fetchCalendarRanges,
|
||||
fetchCalendar
|
||||
};
|
||||
|
@ -115,13 +115,13 @@ class UserMenuBuilder implements LocalMenuBuilderInterface
|
||||
'icon' => 'tasks'
|
||||
]);
|
||||
|
||||
$menu->addChild("My aside activities", [
|
||||
'route' => 'chill_crud_aside_activity_index'
|
||||
])
|
||||
->setExtras([
|
||||
'order' => -10,
|
||||
'icon' => 'tasks'
|
||||
]);
|
||||
// $menu->addChild("My aside activities", [
|
||||
// 'route' => 'chill_crud_aside_activity_index'
|
||||
// ])
|
||||
// ->setExtras([
|
||||
// 'order' => -10,
|
||||
// 'icon' => 'tasks'
|
||||
// ]);
|
||||
}
|
||||
|
||||
protected function addItemInMenu(MenuItem $menu, User $u, $message, $title, $status, $number, $order)
|
||||
|
Loading…
x
Reference in New Issue
Block a user