diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php index f247c69d4..d72c77de1 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php @@ -192,31 +192,6 @@ class CalendarController extends AbstractController ]); } - /** - * @Route("/{_locale}/calendar/calendar/my", name="chill_calendar_calendar_list_my") - * - * @param Request $request - * @return Response - */ - public function myCalendar(Request $request): Response - { - $this->denyAccessUnlessGranted('ROLE_USER'); - - if (!$this->remoteCalendarConnector->isReady()) { - return $this->remoteCalendarConnector->getMakeReadyResponse($request->getUri()); - } - - if (!$this->getUser() instanceof User) { - throw new UnauthorizedHttpException('you are not an user'); - } - - $view = '@ChillCalendar/Calendar/listByUser.html.twig'; - - return $this->render($view, [ - 'user' => $this->getUser(), - ]); - } - /** * Lists all Calendar entities. * @@ -247,6 +222,28 @@ class CalendarController extends AbstractController ]); } + /** + * @Route("/{_locale}/calendar/calendar/my", name="chill_calendar_calendar_list_my") + */ + public function myCalendar(Request $request): Response + { + $this->denyAccessUnlessGranted('ROLE_USER'); + + if (!$this->remoteCalendarConnector->isReady()) { + return $this->remoteCalendarConnector->getMakeReadyResponse($request->getUri()); + } + + if (!$this->getUser() instanceof User) { + throw new UnauthorizedHttpException('you are not an user'); + } + + $view = '@ChillCalendar/Calendar/listByUser.html.twig'; + + return $this->render($view, [ + 'user' => $this->getUser(), + ]); + } + /** * Create a new calendar item. * diff --git a/src/Bundle/ChillCalendarBundle/Entity/CalendarRange.php b/src/Bundle/ChillCalendarBundle/Entity/CalendarRange.php index 3cd87b7f6..a7f7ce2c9 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/CalendarRange.php +++ b/src/Bundle/ChillCalendarBundle/Entity/CalendarRange.php @@ -45,7 +45,7 @@ class CalendarRange implements TrackCreationInterface, TrackUpdateInterface /** * @ORM\Column(type="datetime_immutable", nullable=false) * @Groups({"read", "write", "calendar:read"}) - * @Assert\NotNull() + * @Assert\NotNull */ private ?DateTimeImmutable $endDate = null; @@ -61,41 +61,24 @@ class CalendarRange implements TrackCreationInterface, TrackUpdateInterface * @ORM\ManyToOne(targetEntity=Location::class) * @ORM\JoinColumn(nullable=false) * @Groups({"read", "write", "calendar:read"}) - * @Assert\NotNull() + * @Assert\NotNull */ private ?Location $location; /** * @ORM\Column(type="datetime_immutable", nullable=false) * @groups({"read", "write", "calendar:read"}) - * @Assert\NotNull() + * @Assert\NotNull */ private ?DateTimeImmutable $startDate = null; /** * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User") * @Groups({"read", "write", "calendar:read"}) - * @Assert\NotNull() + * @Assert\NotNull */ private ?User $user = null; - /** - * @return Location|null - */ - public function getLocation(): ?Location - { - return $this->location; - } - - /** - * @param Location|null $location - */ - public function setLocation(?Location $location): void - { - $this->location = $location; - } - - public function getCalendar(): ?Calendar { return $this->calendar; @@ -111,6 +94,11 @@ class CalendarRange implements TrackCreationInterface, TrackUpdateInterface return $this->id; } + public function getLocation(): ?Location + { + return $this->location; + } + public function getStartDate(): ?DateTimeImmutable { return $this->startDate; @@ -136,6 +124,11 @@ class CalendarRange implements TrackCreationInterface, TrackUpdateInterface return $this; } + public function setLocation(?Location $location): void + { + $this->location = $location; + } + public function setStartDate(DateTimeImmutable $startDate): self { $this->startDate = $startDate; diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteEventConverter.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteEventConverter.php index 4ff42cd6f..63c768ff7 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteEventConverter.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteEventConverter.php @@ -196,7 +196,8 @@ class RemoteEventConverter $event['subject'], '', $startDate, - $endDate + $endDate, + $event['isAllDay'] ); } diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraphRemoteCalendarConnector.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraphRemoteCalendarConnector.php index d346d67bc..05997bc1c 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraphRemoteCalendarConnector.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraphRemoteCalendarConnector.php @@ -100,7 +100,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface 'query' => [ 'startDateTime' => $startDate->format(DateTimeImmutable::ATOM), 'endDateTime' => $endDate->format(DateTimeImmutable::ATOM), - '$select' => 'id,subject,start,end', + '$select' => 'id,subject,start,end,isAllDay', ], ] )->toArray(); diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Model/RemoteEvent.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Model/RemoteEvent.php index 99673c47e..5d2cdc1de 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Model/RemoteEvent.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Model/RemoteEvent.php @@ -38,12 +38,18 @@ class RemoteEvent */ public string $title; - public function __construct(string $id, string $title, string $description, DateTimeImmutable $startDate, DateTimeImmutable $endDate) + /** + * @Serializer\Groups({"read"}) + */ + public bool $isAllDay; + + public function __construct(string $id, string $title, string $description, DateTimeImmutable $startDate, DateTimeImmutable $endDate, bool $isAllDay = false) { $this->id = $id; $this->title = $title; $this->description = $description; $this->startDate = $startDate; $this->endDate = $endDate; + $this->isAllDay = $isAllDay; } } diff --git a/src/Bundle/ChillCalendarBundle/Resources/public/types.ts b/src/Bundle/ChillCalendarBundle/Resources/public/types.ts index d5684009d..dcb239ea3 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/public/types.ts +++ b/src/Bundle/ChillCalendarBundle/Resources/public/types.ts @@ -34,7 +34,8 @@ export interface CalendarRemote { id: number; endDate: DateTime; startDate: DateTime; - title: string + title: string; + isAllDay: boolean; } export type EventInputCalendarRange = EventInput & { diff --git a/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/store/utils.ts b/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/store/utils.ts index 7ce63a45c..db2d600dc 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/store/utils.ts +++ b/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/store/utils.ts @@ -85,7 +85,7 @@ export const remoteToFullCalendarEvent = (entity: CalendarRemote): EventInput & title: entity.title, start: entity.startDate.datetime8601, end: entity.endDate.datetime8601, - allDay: false, + allDay: entity.isAllDay, is: 'remote', }; } diff --git a/src/Bundle/ChillCalendarBundle/migrations/Version20220629095515.php b/src/Bundle/ChillCalendarBundle/migrations/Version20220629095515.php index c0ddf73f0..ebc677473 100644 --- a/src/Bundle/ChillCalendarBundle/migrations/Version20220629095515.php +++ b/src/Bundle/ChillCalendarBundle/migrations/Version20220629095515.php @@ -1,5 +1,12 @@ addSql('alter table chill_calendar.calendar_range DROP COLUMN location_id'); + } + public function getDescription(): string { return 'Add location on calendar range'; @@ -22,9 +34,4 @@ final class Version20220629095515 extends AbstractMigration $this->addSql('ALTER TABLE chill_calendar.calendar_range ADD CONSTRAINT FK_38D57D0564D218E FOREIGN KEY (location_id) REFERENCES chill_main_location (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); $this->addSql('CREATE INDEX IDX_38D57D0564D218E ON chill_calendar.calendar_range (location_id)'); } - - public function down(Schema $schema): void - { - $this->addSql('alter table chill_calendar.calendar_range DROP COLUMN location_id'); - } }