From aa53df8bb0be7f7625c96c94805f5380b0745009 Mon Sep 17 00:00:00 2001 From: nobohan Date: Fri, 19 Nov 2021 11:45:23 +0100 Subject: [PATCH] activity: avoid adding persons|Users|Thirdparty if not allowed --- .../ChillActivityBundle/Entity/Activity.php | 5 +- .../Entity/ActivityType.php | 6 + .../Activity/components/ConcernedGroups.vue | 49 +- .../Resources/public/vuejs/Activity/store.js | 479 ++++++++++-------- .../Resources/views/Activity/edit.html.twig | 20 +- 5 files changed, 332 insertions(+), 227 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Entity/Activity.php b/src/Bundle/ChillActivityBundle/Entity/Activity.php index 4ed654c85..995cf450d 100644 --- a/src/Bundle/ChillActivityBundle/Entity/Activity.php +++ b/src/Bundle/ChillActivityBundle/Entity/Activity.php @@ -22,6 +22,7 @@ use Doctrine\Common\Collections\ArrayCollection; use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Serializer\Annotation\Groups; use Symfony\Component\Serializer\Annotation\DiscriminatorMap; +use Symfony\Component\Serializer\Annotation\SerializedName; /** * Class Activity @@ -30,7 +31,7 @@ use Symfony\Component\Serializer\Annotation\DiscriminatorMap; * @ORM\Entity(repositoryClass="Chill\ActivityBundle\Repository\ActivityRepository") * @ORM\Table(name="activity") * @ORM\HasLifecycleCallbacks() - * @DiscriminatorMap(typeProperty="type", mapping={ + * @DiscriminatorMap(typeProperty="_type", mapping={ * "activity"=Activity::class * }) */ @@ -102,6 +103,8 @@ class Activity implements HasCenterInterface, HasScopeInterface, AccompanyingPer /** * @ORM\ManyToOne(targetEntity="Chill\ActivityBundle\Entity\ActivityType") + * @Groups({"read"}) + * @SerializedName("activityType") */ private ActivityType $type; diff --git a/src/Bundle/ChillActivityBundle/Entity/ActivityType.php b/src/Bundle/ChillActivityBundle/Entity/ActivityType.php index c8ae6ca07..835af284e 100644 --- a/src/Bundle/ChillActivityBundle/Entity/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Entity/ActivityType.php @@ -21,6 +21,7 @@ namespace Chill\ActivityBundle\Entity; use Doctrine\ORM\Mapping as ORM; +use Symfony\Component\Serializer\Annotation\Groups; /** * Class ActivityType @@ -45,11 +46,13 @@ class ActivityType /** * @ORM\Column(type="json") + * @Groups({"read"}) */ private array $name = []; /** * @ORM\Column(type="boolean") + * @Groups({"read"}) */ private bool $active = true; @@ -100,6 +103,7 @@ class ActivityType /** * @ORM\Column(type="smallint", nullable=false, options={"default"=1}) + * @Groups({"read"}) */ private int $personsVisible = self::FIELD_OPTIONAL; @@ -110,6 +114,7 @@ class ActivityType /** * @ORM\Column(type="smallint", nullable=false, options={"default"=1}) + * @Groups({"read"}) */ private int $thirdPartiesVisible = self::FIELD_INVISIBLE; @@ -190,6 +195,7 @@ class ActivityType /** * @ORM\Column(type="smallint", nullable=false, options={"default"=1}) + * @Groups({"read"}) */ private int $usersVisible = self::FIELD_OPTIONAL; diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/ConcernedGroups.vue b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/ConcernedGroups.vue index 42c6ee79e..9eaeef697 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/ConcernedGroups.vue +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/ConcernedGroups.vue @@ -1,5 +1,5 @@