mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
handle remote events 'isAllDay' and fix cs
This commit is contained in:
parent
849e7158e4
commit
adad4313a6
@ -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.
|
* 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.
|
* Create a new calendar item.
|
||||||
*
|
*
|
||||||
|
@ -45,7 +45,7 @@ class CalendarRange implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
/**
|
/**
|
||||||
* @ORM\Column(type="datetime_immutable", nullable=false)
|
* @ORM\Column(type="datetime_immutable", nullable=false)
|
||||||
* @Groups({"read", "write", "calendar:read"})
|
* @Groups({"read", "write", "calendar:read"})
|
||||||
* @Assert\NotNull()
|
* @Assert\NotNull
|
||||||
*/
|
*/
|
||||||
private ?DateTimeImmutable $endDate = null;
|
private ?DateTimeImmutable $endDate = null;
|
||||||
|
|
||||||
@ -61,41 +61,24 @@ class CalendarRange implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
* @ORM\ManyToOne(targetEntity=Location::class)
|
* @ORM\ManyToOne(targetEntity=Location::class)
|
||||||
* @ORM\JoinColumn(nullable=false)
|
* @ORM\JoinColumn(nullable=false)
|
||||||
* @Groups({"read", "write", "calendar:read"})
|
* @Groups({"read", "write", "calendar:read"})
|
||||||
* @Assert\NotNull()
|
* @Assert\NotNull
|
||||||
*/
|
*/
|
||||||
private ?Location $location;
|
private ?Location $location;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="datetime_immutable", nullable=false)
|
* @ORM\Column(type="datetime_immutable", nullable=false)
|
||||||
* @groups({"read", "write", "calendar:read"})
|
* @groups({"read", "write", "calendar:read"})
|
||||||
* @Assert\NotNull()
|
* @Assert\NotNull
|
||||||
*/
|
*/
|
||||||
private ?DateTimeImmutable $startDate = null;
|
private ?DateTimeImmutable $startDate = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
|
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
|
||||||
* @Groups({"read", "write", "calendar:read"})
|
* @Groups({"read", "write", "calendar:read"})
|
||||||
* @Assert\NotNull()
|
* @Assert\NotNull
|
||||||
*/
|
*/
|
||||||
private ?User $user = null;
|
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
|
public function getCalendar(): ?Calendar
|
||||||
{
|
{
|
||||||
return $this->calendar;
|
return $this->calendar;
|
||||||
@ -111,6 +94,11 @@ class CalendarRange implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getLocation(): ?Location
|
||||||
|
{
|
||||||
|
return $this->location;
|
||||||
|
}
|
||||||
|
|
||||||
public function getStartDate(): ?DateTimeImmutable
|
public function getStartDate(): ?DateTimeImmutable
|
||||||
{
|
{
|
||||||
return $this->startDate;
|
return $this->startDate;
|
||||||
@ -136,6 +124,11 @@ class CalendarRange implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setLocation(?Location $location): void
|
||||||
|
{
|
||||||
|
$this->location = $location;
|
||||||
|
}
|
||||||
|
|
||||||
public function setStartDate(DateTimeImmutable $startDate): self
|
public function setStartDate(DateTimeImmutable $startDate): self
|
||||||
{
|
{
|
||||||
$this->startDate = $startDate;
|
$this->startDate = $startDate;
|
||||||
|
@ -196,7 +196,8 @@ class RemoteEventConverter
|
|||||||
$event['subject'],
|
$event['subject'],
|
||||||
'',
|
'',
|
||||||
$startDate,
|
$startDate,
|
||||||
$endDate
|
$endDate,
|
||||||
|
$event['isAllDay']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface
|
|||||||
'query' => [
|
'query' => [
|
||||||
'startDateTime' => $startDate->format(DateTimeImmutable::ATOM),
|
'startDateTime' => $startDate->format(DateTimeImmutable::ATOM),
|
||||||
'endDateTime' => $endDate->format(DateTimeImmutable::ATOM),
|
'endDateTime' => $endDate->format(DateTimeImmutable::ATOM),
|
||||||
'$select' => 'id,subject,start,end',
|
'$select' => 'id,subject,start,end,isAllDay',
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
)->toArray();
|
)->toArray();
|
||||||
|
@ -38,12 +38,18 @@ class RemoteEvent
|
|||||||
*/
|
*/
|
||||||
public string $title;
|
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->id = $id;
|
||||||
$this->title = $title;
|
$this->title = $title;
|
||||||
$this->description = $description;
|
$this->description = $description;
|
||||||
$this->startDate = $startDate;
|
$this->startDate = $startDate;
|
||||||
$this->endDate = $endDate;
|
$this->endDate = $endDate;
|
||||||
|
$this->isAllDay = $isAllDay;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,8 @@ export interface CalendarRemote {
|
|||||||
id: number;
|
id: number;
|
||||||
endDate: DateTime;
|
endDate: DateTime;
|
||||||
startDate: DateTime;
|
startDate: DateTime;
|
||||||
title: string
|
title: string;
|
||||||
|
isAllDay: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type EventInputCalendarRange = EventInput & {
|
export type EventInputCalendarRange = EventInput & {
|
||||||
|
@ -85,7 +85,7 @@ export const remoteToFullCalendarEvent = (entity: CalendarRemote): EventInput &
|
|||||||
title: entity.title,
|
title: entity.title,
|
||||||
start: entity.startDate.datetime8601,
|
start: entity.startDate.datetime8601,
|
||||||
end: entity.endDate.datetime8601,
|
end: entity.endDate.datetime8601,
|
||||||
allDay: false,
|
allDay: entity.isAllDay,
|
||||||
is: 'remote',
|
is: 'remote',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Chill is a software for social workers
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view
|
||||||
|
* the LICENSE file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Chill\Migrations\Calendar;
|
namespace Chill\Migrations\Calendar;
|
||||||
@ -9,6 +16,11 @@ use Doctrine\Migrations\AbstractMigration;
|
|||||||
|
|
||||||
final class Version20220629095515 extends AbstractMigration
|
final class Version20220629095515 extends AbstractMigration
|
||||||
{
|
{
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->addSql('alter table chill_calendar.calendar_range DROP COLUMN location_id');
|
||||||
|
}
|
||||||
|
|
||||||
public function getDescription(): string
|
public function getDescription(): string
|
||||||
{
|
{
|
||||||
return 'Add location on calendar range';
|
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('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)');
|
$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');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user