vue activity: fix backend when hidden return empty string

This commit is contained in:
Mathieu Jaumotte 2021-06-29 14:31:56 +02:00
parent 2a974e1269
commit 9d9be7f831
3 changed files with 10 additions and 8 deletions

View File

@ -108,14 +108,14 @@ class Activity implements HasCenterInterface, HasScopeInterface
* @ORM\JoinTable(name="chill_activity_activity_chill_person_socialissue") * @ORM\JoinTable(name="chill_activity_activity_chill_person_socialissue")
* @Groups({"read"}) * @Groups({"read"})
*/ */
private ?Collection $socialIssues = null; private Collection $socialIssues;
/** /**
* @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\SocialWork\SocialAction") * @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\SocialWork\SocialAction")
* @ORM\JoinTable(name="chill_activity_activity_chill_person_socialaction") * @ORM\JoinTable(name="chill_activity_activity_chill_person_socialaction")
* @Groups({"read"}) * @Groups({"read"})
*/ */
private ?Collection $socialActions = null; private Collection $socialActions;
/** /**
* @ORM\ManyToOne(targetEntity="Chill\ActivityBundle\Entity\ActivityType") * @ORM\ManyToOne(targetEntity="Chill\ActivityBundle\Entity\ActivityType")
@ -298,9 +298,6 @@ class Activity implements HasCenterInterface, HasScopeInterface
return $this; return $this;
} }
/**
* @return Collection|SocialAction[]
*/
public function getSocialActions(): Collection public function getSocialActions(): Collection
{ {
return $this->socialActions; return $this->socialActions;

View File

@ -123,13 +123,16 @@ class ActivityType extends AbstractType
return implode(',', $socialIssueIds); return implode(',', $socialIssueIds);
}, },
function (?string $socialIssuesAsString): array { function (?string $socialIssuesAsString): array {
if (null === $socialIssuesAsString) {
return [];
}
return array_map( return array_map(
fn(string $id): ?SocialIssue => $this->om->getRepository(SocialIssue::class)->findOneBy(['id' => (int) $id]), fn(string $id): ?SocialIssue => $this->om->getRepository(SocialIssue::class)->findOneBy(['id' => (int) $id]),
explode(',', $socialIssuesAsString) explode(',', $socialIssuesAsString)
); );
} }
)) ))
; ;
} }
if ($activityType->isVisible('socialActions') && $accompanyingPeriod) { if ($activityType->isVisible('socialActions') && $accompanyingPeriod) {
@ -144,13 +147,16 @@ class ActivityType extends AbstractType
return implode(',', $socialActionIds); return implode(',', $socialActionIds);
}, },
function (?string $socialActionsAsString): array { function (?string $socialActionsAsString): array {
if (null === $socialActionsAsString) {
return [];
}
return array_map( return array_map(
fn(string $id): ?SocialAction => $this->om->getRepository(SocialAction::class)->findOneBy(['id' => (int) $id]), fn(string $id): ?SocialAction => $this->om->getRepository(SocialAction::class)->findOneBy(['id' => (int) $id]),
explode(',', $socialActionsAsString) explode(',', $socialActionsAsString)
); );
} }
)) ))
; ;
} }
if ($activityType->isVisible('date')) { if ($activityType->isVisible('date')) {

View File

@ -64,7 +64,6 @@
{{ $t('activity.select_first_a_social_issue') }} {{ $t('activity.select_first_a_social_issue') }}
</span> </span>
</div> </div>
</div> </div>