mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
add validation on calendar
This commit is contained in:
parent
9c1324e9ec
commit
93c5e83454
@ -31,6 +31,7 @@ use Doctrine\Common\Collections\Criteria;
|
|||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
use LogicException;
|
use LogicException;
|
||||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||||
|
use Symfony\Component\Validator\Constraints as Assert;
|
||||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||||
|
|
||||||
use Symfony\Component\Validator\Constraints\Range;
|
use Symfony\Component\Validator\Constraints\Range;
|
||||||
@ -113,6 +114,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
/**
|
/**
|
||||||
* @ORM\Column(type="datetime_immutable", nullable=false)
|
* @ORM\Column(type="datetime_immutable", nullable=false)
|
||||||
* @Serializer\Groups({"calendar:read", "read"})
|
* @Serializer\Groups({"calendar:read", "read"})
|
||||||
|
* @Assert\NotNull(message="calendar.An end date is required")
|
||||||
*/
|
*/
|
||||||
private ?DateTimeImmutable $endDate = null;
|
private ?DateTimeImmutable $endDate = null;
|
||||||
|
|
||||||
@ -139,12 +141,14 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Location")
|
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Location")
|
||||||
* @Serializer\Groups({"read"})
|
* @Serializer\Groups({"read"})
|
||||||
|
* @Assert\NotNull(message="calendar.A location is required")
|
||||||
*/
|
*/
|
||||||
private ?Location $location = null;
|
private ?Location $location = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
|
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
|
||||||
* @Serializer\Groups({"calendar:read", "read"})
|
* @Serializer\Groups({"calendar:read", "read"})
|
||||||
|
* @Assert\NotNull(message="calendar.A main user is mandatory")
|
||||||
*/
|
*/
|
||||||
private ?User $mainUser = null;
|
private ?User $mainUser = null;
|
||||||
|
|
||||||
@ -152,6 +156,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
* @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\Person")
|
* @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\Person")
|
||||||
* @ORM\JoinTable(name="chill_calendar.calendar_to_persons")
|
* @ORM\JoinTable(name="chill_calendar.calendar_to_persons")
|
||||||
* @Serializer\Groups({"calendar:read", "read"})
|
* @Serializer\Groups({"calendar:read", "read"})
|
||||||
|
* @Assert\Count(min=1, minMessage="calendar.At least {{ limit }} person is required.")
|
||||||
*/
|
*/
|
||||||
private Collection $persons;
|
private Collection $persons;
|
||||||
|
|
||||||
@ -181,6 +186,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
/**
|
/**
|
||||||
* @ORM\Column(type="datetime_immutable", nullable=false)
|
* @ORM\Column(type="datetime_immutable", nullable=false)
|
||||||
* @Serializer\Groups({"calendar:read", "read"})
|
* @Serializer\Groups({"calendar:read", "read"})
|
||||||
|
* @Assert\NotNull(message="calendar.A start date is required")
|
||||||
*/
|
*/
|
||||||
private ?DateTimeImmutable $startDate = null;
|
private ?DateTimeImmutable $startDate = null;
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ class CalendarType extends AbstractType
|
|||||||
return $res;
|
return $res;
|
||||||
},
|
},
|
||||||
static function (?string $dateAsString): ?DateTimeImmutable {
|
static function (?string $dateAsString): ?DateTimeImmutable {
|
||||||
if ('' === $dateAsString) {
|
if ('' === $dateAsString || null === $dateAsString) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ class CalendarType extends AbstractType
|
|||||||
return $res;
|
return $res;
|
||||||
},
|
},
|
||||||
static function (?string $dateAsString): ?DateTimeImmutable {
|
static function (?string $dateAsString): ?DateTimeImmutable {
|
||||||
if ('' === $dateAsString) {
|
if ('' === $dateAsString || null === $dateAsString) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,11 +82,14 @@
|
|||||||
} %}
|
} %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% if calendar.comment.comment is not empty %}
|
{% if calendar.comment.comment is not empty %}
|
||||||
|
<div class="item-row details separator">
|
||||||
<div class="item-col comment">
|
<div class="item-col comment">
|
||||||
{{ calendar.comment|chill_entity_render_box( { 'limit_lines': 3, 'metadata': false } ) }}
|
{{ calendar.comment|chill_entity_render_box( { 'limit_lines': 3, 'metadata': false } ) }}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
calendar:
|
||||||
|
At least {{ limit }} person is required.: Au moins {{ limit }} personne doit être associée à ce rendez-vous
|
||||||
|
An end date is required: Indiquez une date et heure de fin
|
||||||
|
A start date is required: Indiquez une date et heure de début
|
||||||
|
A location is required: Indiquez un lieu
|
||||||
|
A main user is mandator: Indiquez un utilisateur principal
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user