mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
rdv: available calendar ranges
This commit is contained in:
parent
0457ee2b8d
commit
65bce1aacb
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\CalendarBundle\Controller;
|
||||
|
||||
use Chill\MainBundle\CRUD\Controller\ApiController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Chill\MainBundle\Pagination\PaginatorInterface;
|
||||
use Chill\MainBundle\Serializer\Model\Collection;
|
||||
|
||||
class CalendarRangeAPIController extends ApiController
|
||||
{
|
||||
|
||||
/**
|
||||
* @Route("/api/1.0/calendar/calendar-range-available.{_format}", name="chill_api_single_calendar_range_available")
|
||||
*/
|
||||
public function availableRanges(Request $request, string $_format): JsonResponse
|
||||
{
|
||||
if ($request->query->has('user')) {
|
||||
$user = $request->query->get('user');
|
||||
}
|
||||
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$query = $em->createQuery(
|
||||
'SELECT c FROM ChillCalendarBundle:CalendarRange c
|
||||
WHERE NOT EXISTS (SELECT cal.id FROM ChillCalendarBundle:Calendar cal WHERE cal.calendarRange = c.id)')
|
||||
;
|
||||
|
||||
$results = $query->getResult();
|
||||
|
||||
return $this->json(['count' => count($results), 'results' => $results], Response::HTTP_OK, [], [ 'groups' => [ 'read' ]]);
|
||||
//TODO use also the paginator, eg return $this->serializeCollection('get', $request, $_format, $paginator, $results);
|
||||
}
|
||||
|
||||
}
|
@ -57,6 +57,7 @@ class ChillCalendarExtension extends Extension implements PrependExtensionInterf
|
||||
$container->prependExtensionConfig('chill_main', [
|
||||
'apis' => [
|
||||
[
|
||||
'controller' => \Chill\CalendarBundle\Controller\CalendarRangeAPIController::class,
|
||||
'class' => \Chill\CalendarBundle\Entity\CalendarRange::class,
|
||||
'name' => 'calendar_range',
|
||||
'base_path' => '/api/1.0/calendar/calendar-range',
|
||||
|
@ -116,7 +116,7 @@ class Calendar
|
||||
private ?CancelReason $cancelReason = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="CalendarRange")
|
||||
* @ORM\ManyToOne(targetEntity="CalendarRange", inversedBy="calendars")
|
||||
*/
|
||||
private ?CalendarRange $calendarRange = null;
|
||||
|
||||
|
@ -4,6 +4,8 @@ namespace Chill\CalendarBundle\Entity;
|
||||
|
||||
use Chill\CalendarBundle\Repository\CalendarRangeRepository;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
|
||||
@ -23,7 +25,7 @@ class CalendarRange
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
|
||||
* @groups({"read"})
|
||||
* @Groups({"read"})
|
||||
*/
|
||||
private User $user;
|
||||
|
||||
@ -39,8 +41,19 @@ class CalendarRange
|
||||
*/
|
||||
private \DateTimeImmutable $endDate;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity=Calendar::class,
|
||||
* mappedBy="calendarRange")
|
||||
*/
|
||||
private Collection $calendars;
|
||||
|
||||
//TODO Lieu
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->calendars = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
|
@ -19,9 +19,9 @@
|
||||
:options="options">
|
||||
</VueMultiselect>
|
||||
</div>
|
||||
<div>
|
||||
<input type="checkbox" id="myCalendar" v-model="showMyCalendarWidget" />
|
||||
<label for="checkbox">{{ $t('show_my_calendar') }}</label>
|
||||
<div class="form-check">
|
||||
<input type="checkbox" id="myCalendar" class="form-check-input" v-model="showMyCalendarWidget" />
|
||||
<label class="form-check-label" for="myCalendar">{{ $t('show_my_calendar') }}</label>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
@ -151,7 +151,7 @@ export default {
|
||||
transName(value) {
|
||||
return `${value.username}`;
|
||||
},
|
||||
coloriseSelectedValues() { //TODO cette function doit être exécutée au bon moment, après sélection (normalement avec @input)
|
||||
coloriseSelectedValues() {
|
||||
let tags = document.querySelectorAll('div.multiselect__tags-wrap')[0];
|
||||
|
||||
if (tags.hasChildNodes()) {
|
||||
|
@ -4,7 +4,7 @@
|
||||
* @returns {Promise} a promise containing all Calendar ranges objects
|
||||
*/
|
||||
const fetchCalendarRanges = () => {
|
||||
const url = `/api/1.0/calendar/calendar-range.json?item_per_page=1000`;
|
||||
const url = `/api/1.0/calendar/calendar-range-available.json`;
|
||||
return fetch(url)
|
||||
.then(response => {
|
||||
if (response.ok) { return response.json(); }
|
||||
|
Loading…
x
Reference in New Issue
Block a user