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")
|
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
|
||||||
|
* @Groups({"read"})
|
||||||
*/
|
*/
|
||||||
private User $user;
|
private User $user;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod")
|
* @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod")
|
||||||
* @Groups({"read"})
|
|
||||||
*/
|
*/
|
||||||
private AccompanyingPeriod $accompanyingPeriod;
|
private AccompanyingPeriod $accompanyingPeriod;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
|
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
|
||||||
|
* @Groups({"read"})
|
||||||
*/
|
*/
|
||||||
private ?User $mainUser;
|
private ?User $mainUser;
|
||||||
|
|
||||||
@ -92,11 +93,13 @@ class Calendar
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="datetimetz_immutable")
|
* @ORM\Column(type="datetimetz_immutable")
|
||||||
|
* @Groups({"read"})
|
||||||
*/
|
*/
|
||||||
private \DateTimeImmutable $startDate;
|
private \DateTimeImmutable $startDate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="datetimetz_immutable")
|
* @ORM\Column(type="datetimetz_immutable")
|
||||||
|
* @Groups({"read"})
|
||||||
*/
|
*/
|
||||||
private \DateTimeImmutable $endDate;
|
private \DateTimeImmutable $endDate;
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ export default {
|
|||||||
calendarEvents: {
|
calendarEvents: {
|
||||||
loaded: [],
|
loaded: [],
|
||||||
selected: [],
|
selected: [],
|
||||||
userEvents: [], //TODO load user calendar events
|
user: [], //TODO load user calendar events
|
||||||
current: currentEvent
|
current: currentEvent
|
||||||
},
|
},
|
||||||
calendarOptions: {
|
calendarOptions: {
|
||||||
@ -81,22 +81,24 @@ export default {
|
|||||||
console.log(window.startDate)
|
console.log(window.startDate)
|
||||||
// let calendar = this.$refs.fullCalendar.getApi()
|
// let calendar = this.$refs.fullCalendar.getApi()
|
||||||
// console.log(calendar)
|
// console.log(calendar)
|
||||||
|
this.calendarEvents.selected.push(this.calendarEvents.user);
|
||||||
|
this.calendarOptions.eventSources = this.calendarEvents.selected;
|
||||||
|
console.log(this.calendarOptions.eventSources)
|
||||||
|
|
||||||
},
|
},
|
||||||
updateEventsSource() {
|
updateEventsSource() {
|
||||||
this.calendarOptions.eventSources = this.calendarEvents.selected;
|
|
||||||
if (window.startDate !== undefined) {
|
if (window.startDate !== undefined) {
|
||||||
this.calendarEvents.selected.push(currentEvent);
|
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) {
|
onDateSelect(payload) {
|
||||||
Object.assign(payload, {users: this.users});
|
Object.assign(payload, {users: this.users});
|
||||||
this.$store.dispatch('createEvent', payload);
|
this.$store.dispatch('createEvent', payload);
|
||||||
},
|
},
|
||||||
onEventChange(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)
|
console.log(this.calendarOptions.eventSources)
|
||||||
this.$store.dispatch('updateEvent', payload);
|
this.$store.dispatch('updateEvent', payload);
|
||||||
},
|
},
|
||||||
|
@ -113,7 +113,6 @@ const store = createStore({
|
|||||||
startDateInput.value = payload.startStr;
|
startDateInput.value = payload.startStr;
|
||||||
let endDateInput = document.getElementById("chill_calendarbundle_calendar_endDate");
|
let endDateInput = document.getElementById("chill_calendarbundle_calendar_endDate");
|
||||||
endDateInput.value = payload.endStr;
|
endDateInput.value = payload.endStr;
|
||||||
//TODO specify the mainUserInput value if not from a source
|
|
||||||
let mainUserInput = document.getElementById("chill_calendarbundle_calendar_mainUser");
|
let mainUserInput = document.getElementById("chill_calendarbundle_calendar_mainUser");
|
||||||
mainUserInput.value = payload.users.logged.id;
|
mainUserInput.value = payload.users.logged.id;
|
||||||
commit('setEvents', payload);
|
commit('setEvents', payload);
|
||||||
@ -128,7 +127,6 @@ const store = createStore({
|
|||||||
calendarRangeInput.value = Number(payload.event.extendedProps.calendarRangeId);
|
calendarRangeInput.value = Number(payload.event.extendedProps.calendarRangeId);
|
||||||
let mainUserInput = document.getElementById("chill_calendarbundle_calendar_mainUser");
|
let mainUserInput = document.getElementById("chill_calendarbundle_calendar_mainUser");
|
||||||
mainUserInput.value = Number(payload.event.source.id);
|
mainUserInput.value = Number(payload.event.source.id);
|
||||||
//TODO check if working when reiszing an event
|
|
||||||
commit('setEvents', payload);
|
commit('setEvents', payload);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
import { fetchCalendarRanges } from './js/api'
|
import { fetchCalendarRanges, fetchCalendar } from './js/api'
|
||||||
import VueMultiselect from 'vue-multiselect';
|
import VueMultiselect from 'vue-multiselect';
|
||||||
import { whoami } from 'ChillPersonAssets/vuejs/AccompanyingCourse/api';
|
import { whoami } from 'ChillPersonAssets/vuejs/AccompanyingCourse/api';
|
||||||
|
|
||||||
@ -54,9 +54,9 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
init() {
|
init() {
|
||||||
this.getUniqueUserCalendarRanges()
|
this.fetchData()
|
||||||
},
|
},
|
||||||
getUniqueUserCalendarRanges() {
|
fetchData() {
|
||||||
fetchCalendarRanges().then(calendarRanges => new Promise((resolve, reject) => {
|
fetchCalendarRanges().then(calendarRanges => new Promise((resolve, reject) => {
|
||||||
let results = calendarRanges.results;
|
let results = calendarRanges.results;
|
||||||
|
|
||||||
@ -103,12 +103,33 @@ export default {
|
|||||||
this.users.logged = me;
|
this.users.logged = me;
|
||||||
let currentUser = users.find(u => u.id === me.id);
|
let currentUser = users.find(u => u.id === me.id);
|
||||||
this.value = currentUser;
|
this.value = currentUser;
|
||||||
this.selectUsers(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()
|
resolve();
|
||||||
}))
|
}))
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.errorMsg.push(error.message);
|
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'
|
'icon' => 'tasks'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$menu->addChild("My aside activities", [
|
// $menu->addChild("My aside activities", [
|
||||||
'route' => 'chill_crud_aside_activity_index'
|
// 'route' => 'chill_crud_aside_activity_index'
|
||||||
])
|
// ])
|
||||||
->setExtras([
|
// ->setExtras([
|
||||||
'order' => -10,
|
// 'order' => -10,
|
||||||
'icon' => 'tasks'
|
// 'icon' => 'tasks'
|
||||||
]);
|
// ]);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function addItemInMenu(MenuItem $menu, User $u, $message, $title, $status, $number, $order)
|
protected function addItemInMenu(MenuItem $menu, User $u, $message, $title, $status, $number, $order)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user