Merge remote-tracking branch 'origin/features/activity-form--marc' into features/activity-form

This commit is contained in:
Mathieu Jaumotte 2021-06-04 11:58:33 +02:00
commit 330234981c
8 changed files with 309 additions and 77 deletions

View File

@ -50,7 +50,7 @@ class ActivityController extends AbstractController
protected AuthorizationHelper $authorizationHelper; protected AuthorizationHelper $authorizationHelper;
protected LoggerInterface $logger; protected LoggerInterface $logger;
protected SerializerInterface $serializer; protected SerializerInterface $serializer;
public function __construct( public function __construct(
@ -191,6 +191,7 @@ class ActivityController extends AbstractController
'center' => $entity->getCenter(), 'center' => $entity->getCenter(),
'role' => new Role('CHILL_ACTIVITY_CREATE'), 'role' => new Role('CHILL_ACTIVITY_CREATE'),
'activityType' => $entity->getType(), 'activityType' => $entity->getType(),
'accompanyingPeriod' => $accompanyingPeriod,
])->handleRequest($request); ])->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) { if ($form->isSubmitted() && $form->isValid()) {
@ -210,7 +211,7 @@ class ActivityController extends AbstractController
} }
$activity_array = $this->serializer->normalize($entity, 'json', ['groups' => 'read']); $activity_array = $this->serializer->normalize($entity, 'json', ['groups' => 'read']);
return $this->render($view, [ return $this->render($view, [
'person' => $person, 'person' => $person,
'accompanyingCourse' => $accompanyingPeriod, 'accompanyingCourse' => $accompanyingPeriod,
@ -299,6 +300,7 @@ class ActivityController extends AbstractController
'center' => $entity->getCenter(), 'center' => $entity->getCenter(),
'role' => new Role('CHILL_ACTIVITY_UPDATE'), 'role' => new Role('CHILL_ACTIVITY_UPDATE'),
'activityType' => $entity->getType(), 'activityType' => $entity->getType(),
'accompanyingPeriod' => $accompanyingPeriod,
])->handleRequest($request); ])->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) { if ($form->isSubmitted() && $form->isValid()) {
@ -329,7 +331,7 @@ class ActivityController extends AbstractController
} }
$activity_array = $this->serializer->normalize($entity, 'json', ['groups' => 'read']); $activity_array = $this->serializer->normalize($entity, 'json', ['groups' => 'read']);
return $this->render($view, array( return $this->render($view, array(
'entity' => $entity, 'entity' => $entity,
'edit_form' => $form->createView(), 'edit_form' => $form->createView(),

View File

@ -2,27 +2,27 @@
/* /*
* Chill is a software for social workers * Chill is a software for social workers
* *
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS, * Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
* <http://www.champs-libres.coop>, <info@champs-libres.coop> * <http://www.champs-libres.coop>, <info@champs-libres.coop>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the * published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version. * License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details. * GNU Affero General Public License for more details.
* *
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
namespace Chill\ActivityBundle\DataFixtures\ORM; namespace Chill\ActivityBundle\DataFixtures\ORM;
use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface; use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Persistence\ObjectManager; use Doctrine\Persistence\ObjectManager;
use Chill\ActivityBundle\Entity\ActivityType; use Chill\ActivityBundle\Entity\ActivityType;
@ -32,36 +32,59 @@ use Chill\ActivityBundle\Entity\ActivityType;
* *
* @author Champs-Libres Coop * @author Champs-Libres Coop
*/ */
class LoadActivityType extends AbstractFixture implements OrderedFixtureInterface class LoadActivityType extends Fixture implements OrderedFixtureInterface
{ {
public function getOrder() public function getOrder()
{ {
return 16100; return 16100;
} }
public static $references = array(); public static $references = array();
public function load(ObjectManager $manager) public function load(ObjectManager $manager)
{ {
$types = [ $types = [
[ 'name' => # Exange
['fr' => 'Appel téléphonique', 'en' => 'Telephone call', 'nl' => 'Telefoon appel']], [
[ 'name' => 'name' =>
['fr' => 'Entretien', 'en' => 'Interview', 'nl' => 'Vraaggesprek']], ['fr' => 'Entretien physique avec l\'usager'],
[ 'name' => 'category' => 'exchange' ],
['fr' => 'Inspection', 'en' => 'Inspection', 'nl' => 'Inspectie']] [
'name' =>
['fr' => 'Appel téléphonique', 'en' => 'Telephone call', 'nl' => 'Telefoon appel'],
'category' => 'exchange' ],
[
'name' =>
['fr' => 'Courriel', 'en' => 'Email', 'nl' => 'Email'],
'category' => 'exchange' ],
# Meeting
[
'name' =>
['fr' => 'Point technique encadrant'],
'category' => 'meeting' ],
[
'name' =>
['fr' => 'Réunion avec des partenaires'],
'category' => 'meeting' ],
[
'name' =>
['fr' => 'Commission pluridisciplinaire et pluri-institutionnelle'],
'category' => 'meeting' ],
]; ];
foreach ($types as $t) { foreach ($types as $t) {
print "Creating activity type : " . $t['name']['en'] . "\n"; print "Creating activity type : " . $t['name']['fr'] . " (cat:". $t['category'] . " \n";
$activityType = (new ActivityType()) $activityType = (new ActivityType())
->setName(($t['name'])); ->setName(($t['name']))
->setCategory($this->getReference('activity_type_cat_'.$t['category']))
->setSocialIssuesVisible(1)
->setSocialActionsVisible(1);
$manager->persist($activityType); $manager->persist($activityType);
$reference = 'activity_type_'.$t['name']['en']; $reference = 'activity_type_'.$t['name']['fr'];
$this->addReference($reference, $activityType); $this->addReference($reference, $activityType);
static::$references[] = $reference; static::$references[] = $reference;
} }
$manager->flush(); $manager->flush();
} }
} }

View File

@ -0,0 +1,72 @@
<?php
/*
* Chill is a software for social workers
*
* Copyright (C) 2014-2021, Champs Libres Cooperative SCRLFS,
* <http://www.champs-libres.coop>, <info@champs-libres.coop>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Chill\ActivityBundle\DataFixtures\ORM;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Persistence\ObjectManager;
use Chill\ActivityBundle\Entity\ActivityTypeCategory;
/**
* Fixtures for ActivityTypeCategory
*
* @author Champs-Libres Coop
*/
class LoadActivityTypeCategory extends Fixture implements OrderedFixtureInterface
{
public static $references = array();
public function getOrder()
{
return 16050;
}
public function load(ObjectManager $manager)
{
$categories = [
[
'name' => ['fr' => 'Échange avec usager', 'en' => 'Exchange with user'],
'ref' => 'exchange',
],
[
'name' => ['fr' => 'Réunion', 'en' => 'Meeting'],
'ref' => 'meeting',
],
];
foreach ($categories as $cat) {
print "Creating activity type category : " . $cat['ref'] . "\n";
$newCat = (new ActivityTypeCategory())
->setName(($cat['name']));
$manager->persist($newCat);
$reference = 'activity_type_cat_'.$cat['ref'];
$this->addReference($reference, $newCat);
static::$references[] = $reference;
}
$manager->flush();
}
}

View File

@ -313,9 +313,11 @@ class ActivityType
return $this->category; return $this->category;
} }
public function setCategory(?ActivityTypeCategory $category): void public function setCategory(?ActivityTypeCategory $category): self
{ {
$this->category = $category; $this->category = $category;
return $this;
} }
public function getPersonVisible(): int public function getPersonVisible(): int
@ -323,9 +325,11 @@ class ActivityType
return $this->personVisible; return $this->personVisible;
} }
public function setPersonVisible(int $personVisible): void public function setPersonVisible(int $personVisible): self
{ {
$this->personVisible = $personVisible; $this->personVisible = $personVisible;
return $this;
} }
public function getPersonLabel(): string public function getPersonLabel(): string
@ -333,9 +337,11 @@ class ActivityType
return $this->personLabel; return $this->personLabel;
} }
public function setPersonLabel(string $personLabel): void public function setPersonLabel(string $personLabel): self
{ {
$this->personLabel = $personLabel; $this->personLabel = $personLabel;
return $this;
} }
public function getUserVisible(): int public function getUserVisible(): int
@ -343,9 +349,11 @@ class ActivityType
return $this->userVisible; return $this->userVisible;
} }
public function setUserVisible(int $userVisible): void public function setUserVisible(int $userVisible): self
{ {
$this->userVisible = $userVisible; $this->userVisible = $userVisible;
return $this;
} }
public function getUserLabel(): string public function getUserLabel(): string
@ -353,9 +361,11 @@ class ActivityType
return $this->userLabel; return $this->userLabel;
} }
public function setUserLabel(string $userLabel): void public function setUserLabel(string $userLabel): self
{ {
$this->userLabel = $userLabel; $this->userLabel = $userLabel;
return $this;
} }
public function getDateVisible(): int public function getDateVisible(): int
@ -363,9 +373,11 @@ class ActivityType
return $this->dateVisible; return $this->dateVisible;
} }
public function setDateVisible(int $dateVisible): void public function setDateVisible(int $dateVisible): self
{ {
$this->dateVisible = $dateVisible; $this->dateVisible = $dateVisible;
return $this;
} }
public function getDateLabel(): string public function getDateLabel(): string
@ -373,9 +385,11 @@ class ActivityType
return $this->dateLabel; return $this->dateLabel;
} }
public function setDateLabel(string $dateLabel): void public function setDateLabel(string $dateLabel): self
{ {
$this->dateLabel = $dateLabel; $this->dateLabel = $dateLabel;
return $this;
} }
public function getPlaceVisible(): int public function getPlaceVisible(): int
@ -383,9 +397,11 @@ class ActivityType
return $this->placeVisible; return $this->placeVisible;
} }
public function setPlaceVisible(int $placeVisible): void public function setPlaceVisible(int $placeVisible): self
{ {
$this->placeVisible = $placeVisible; $this->placeVisible = $placeVisible;
return $this;
} }
public function getPlaceLabel(): string public function getPlaceLabel(): string
@ -393,9 +409,11 @@ class ActivityType
return $this->placeLabel; return $this->placeLabel;
} }
public function setPlaceLabel(string $placeLabel): void public function setPlaceLabel(string $placeLabel): self
{ {
$this->placeLabel = $placeLabel; $this->placeLabel = $placeLabel;
return $this;
} }
public function getPersonsVisible(): int public function getPersonsVisible(): int
@ -403,9 +421,11 @@ class ActivityType
return $this->personsVisible; return $this->personsVisible;
} }
public function setPersonsVisible(int $personsVisible): void public function setPersonsVisible(int $personsVisible): self
{ {
$this->personsVisible = $personsVisible; $this->personsVisible = $personsVisible;
return $this;
} }
public function getPersonsLabel(): string public function getPersonsLabel(): string
@ -413,9 +433,11 @@ class ActivityType
return $this->personsLabel; return $this->personsLabel;
} }
public function setPersonsLabel(string $personsLabel): void public function setPersonsLabel(string $personsLabel): self
{ {
$this->personsLabel = $personsLabel; $this->personsLabel = $personsLabel;
return $this;
} }
public function getThirdPartiesVisible(): int public function getThirdPartiesVisible(): int
@ -423,9 +445,11 @@ class ActivityType
return $this->thirdPartiesVisible; return $this->thirdPartiesVisible;
} }
public function setThirdPartiesVisible(int $thirdPartiesVisible): void public function setThirdPartiesVisible(int $thirdPartiesVisible): self
{ {
$this->thirdPartiesVisible = $thirdPartiesVisible; $this->thirdPartiesVisible = $thirdPartiesVisible;
return $this;
} }
public function getThirdPartiesLabel(): string public function getThirdPartiesLabel(): string
@ -433,9 +457,11 @@ class ActivityType
return $this->thirdPartiesLabel; return $this->thirdPartiesLabel;
} }
public function setThirdPartiesLabel(string $thirdPartiesLabel): void public function setThirdPartiesLabel(string $thirdPartiesLabel): self
{ {
$this->thirdPartiesLabel = $thirdPartiesLabel; $this->thirdPartiesLabel = $thirdPartiesLabel;
return $this;
} }
public function getDurationTimeVisible(): int public function getDurationTimeVisible(): int
@ -443,9 +469,11 @@ class ActivityType
return $this->durationTimeVisible; return $this->durationTimeVisible;
} }
public function setDurationTimeVisible(int $durationTimeVisible): void public function setDurationTimeVisible(int $durationTimeVisible): self
{ {
$this->durationTimeVisible = $durationTimeVisible; $this->durationTimeVisible = $durationTimeVisible;
return $this;
} }
public function getDurationTimeLabel(): string public function getDurationTimeLabel(): string
@ -453,9 +481,11 @@ class ActivityType
return $this->durationTimeLabel; return $this->durationTimeLabel;
} }
public function setDurationTimeLabel(string $durationTimeLabel): void public function setDurationTimeLabel(string $durationTimeLabel): self
{ {
$this->durationTimeLabel = $durationTimeLabel; $this->durationTimeLabel = $durationTimeLabel;
return $this;
} }
public function getTravelTimeVisible(): int public function getTravelTimeVisible(): int
@ -463,9 +493,11 @@ class ActivityType
return $this->travelTimeVisible; return $this->travelTimeVisible;
} }
public function setTravelTimeVisible(int $TravelTimeVisible): void public function setTravelTimeVisible(int $TravelTimeVisible): self
{ {
$this->travelTimeVisible = $TravelTimeVisible; $this->travelTimeVisible = $TravelTimeVisible;
return $this;
} }
public function getTravelTimeLabel(): string public function getTravelTimeLabel(): string
@ -473,9 +505,11 @@ class ActivityType
return $this->travelTimeLabel; return $this->travelTimeLabel;
} }
public function setTravelTimeLabel(string $TravelTimeLabel): void public function setTravelTimeLabel(string $TravelTimeLabel): self
{ {
$this->travelTimeLabel = $TravelTimeLabel; $this->travelTimeLabel = $TravelTimeLabel;
return $this;
} }
public function getAttendeeVisible(): int public function getAttendeeVisible(): int
@ -483,9 +517,11 @@ class ActivityType
return $this->attendeeVisible; return $this->attendeeVisible;
} }
public function setAttendeeVisible(int $attendeeVisible): void public function setAttendeeVisible(int $attendeeVisible): self
{ {
$this->attendeeVisible = $attendeeVisible; $this->attendeeVisible = $attendeeVisible;
return $this;
} }
public function getAttendeeLabel(): string public function getAttendeeLabel(): string
@ -493,9 +529,11 @@ class ActivityType
return $this->attendeeLabel; return $this->attendeeLabel;
} }
public function setAttendeeLabel(string $attendeeLabel): void public function setAttendeeLabel(string $attendeeLabel): self
{ {
$this->attendeeLabel = $attendeeLabel; $this->attendeeLabel = $attendeeLabel;
return $this;
} }
public function getReasonsVisible(): int public function getReasonsVisible(): int
@ -503,9 +541,11 @@ class ActivityType
return $this->reasonsVisible; return $this->reasonsVisible;
} }
public function setReasonsVisible(int $reasonsVisible): void public function setReasonsVisible(int $reasonsVisible): self
{ {
$this->reasonsVisible = $reasonsVisible; $this->reasonsVisible = $reasonsVisible;
return $this;
} }
public function getReasonsLabel(): string public function getReasonsLabel(): string
@ -513,9 +553,11 @@ class ActivityType
return $this->reasonsLabel; return $this->reasonsLabel;
} }
public function setReasonsLabel(string $reasonsLabel): void public function setReasonsLabel(string $reasonsLabel): self
{ {
$this->reasonsLabel = $reasonsLabel; $this->reasonsLabel = $reasonsLabel;
return $this;
} }
public function getCommentVisible(): int public function getCommentVisible(): int
@ -523,9 +565,11 @@ class ActivityType
return $this->commentVisible; return $this->commentVisible;
} }
public function setCommentVisible(int $commentVisible): void public function setCommentVisible(int $commentVisible): self
{ {
$this->commentVisible = $commentVisible; $this->commentVisible = $commentVisible;
return $this;
} }
public function getCommentLabel(): string public function getCommentLabel(): string
@ -533,9 +577,11 @@ class ActivityType
return $this->commentLabel; return $this->commentLabel;
} }
public function setCommentLabel(string $commentLabel): void public function setCommentLabel(string $commentLabel): self
{ {
$this->commentLabel = $commentLabel; $this->commentLabel = $commentLabel;
return $this;
} }
public function getSentReceivedVisible(): int public function getSentReceivedVisible(): int
@ -543,9 +589,11 @@ class ActivityType
return $this->sentReceivedVisible; return $this->sentReceivedVisible;
} }
public function setSentReceivedVisible(int $sentReceivedVisible): void public function setSentReceivedVisible(int $sentReceivedVisible): self
{ {
$this->sentReceivedVisible = $sentReceivedVisible; $this->sentReceivedVisible = $sentReceivedVisible;
return $this;
} }
public function getSentReceivedLabel(): string public function getSentReceivedLabel(): string
@ -553,9 +601,11 @@ class ActivityType
return $this->sentReceivedLabel; return $this->sentReceivedLabel;
} }
public function setSentReceivedLabel(string $sentReceivedLabel): void public function setSentReceivedLabel(string $sentReceivedLabel): self
{ {
$this->sentReceivedLabel = $sentReceivedLabel; $this->sentReceivedLabel = $sentReceivedLabel;
return $this;
} }
public function getDocumentsVisible(): int public function getDocumentsVisible(): int
@ -563,9 +613,11 @@ class ActivityType
return $this->documentsVisible; return $this->documentsVisible;
} }
public function setDocumentsVisible(int $documentsVisible): void public function setDocumentsVisible(int $documentsVisible): self
{ {
$this->documentsVisible = $documentsVisible; $this->documentsVisible = $documentsVisible;
return $this;
} }
public function getDocumentsLabel(): string public function getDocumentsLabel(): string
@ -573,9 +625,11 @@ class ActivityType
return $this->documentsLabel; return $this->documentsLabel;
} }
public function setDocumentsLabel(string $documentsLabel): void public function setDocumentsLabel(string $documentsLabel): self
{ {
$this->documentsLabel = $documentsLabel; $this->documentsLabel = $documentsLabel;
return $this;
} }
public function getUsersVisible(): int public function getUsersVisible(): int
@ -583,9 +637,11 @@ class ActivityType
return $this->usersVisible; return $this->usersVisible;
} }
public function setUsersVisible(int $usersVisible): void public function setUsersVisible(int $usersVisible): self
{ {
$this->usersVisible = $usersVisible; $this->usersVisible = $usersVisible;
return $this;
} }
public function getUsersLabel(): string public function getUsersLabel(): string
@ -593,9 +649,11 @@ class ActivityType
return $this->usersLabel; return $this->usersLabel;
} }
public function setUsersLabel(string $usersLabel): void public function setUsersLabel(string $usersLabel): self
{ {
$this->usersLabel = $usersLabel; $this->usersLabel = $usersLabel;
return $this;
} }
public function getEmergencyVisible(): int public function getEmergencyVisible(): int
@ -603,9 +661,11 @@ class ActivityType
return $this->emergencyVisible; return $this->emergencyVisible;
} }
public function setEmergencyVisible(int $emergencyVisible): void public function setEmergencyVisible(int $emergencyVisible): self
{ {
$this->emergencyVisible = $emergencyVisible; $this->emergencyVisible = $emergencyVisible;
return $this;
} }
public function getEmergencyLabel(): string public function getEmergencyLabel(): string
@ -613,9 +673,11 @@ class ActivityType
return $this->emergencyLabel; return $this->emergencyLabel;
} }
public function setEmergencyLabel(string $emergencyLabel): void public function setEmergencyLabel(string $emergencyLabel): self
{ {
$this->emergencyLabel = $emergencyLabel; $this->emergencyLabel = $emergencyLabel;
return $this;
} }
public function getAccompanyingPeriodVisible(): int public function getAccompanyingPeriodVisible(): int
@ -623,9 +685,11 @@ class ActivityType
return $this->accompanyingPeriodVisible; return $this->accompanyingPeriodVisible;
} }
public function setAccompanyingPeriodVisible(int $accompanyingPeriodVisible): void public function setAccompanyingPeriodVisible(int $accompanyingPeriodVisible): self
{ {
$this->accompanyingPeriodVisible = $accompanyingPeriodVisible; $this->accompanyingPeriodVisible = $accompanyingPeriodVisible;
return $this;
} }
public function getAccompanyingPeriodLabel(): string public function getAccompanyingPeriodLabel(): string
@ -633,9 +697,11 @@ class ActivityType
return $this->accompanyingPeriodLabel; return $this->accompanyingPeriodLabel;
} }
public function setAccompanyingPeriodLabel(string $accompanyingPeriodLabel): void public function setAccompanyingPeriodLabel(string $accompanyingPeriodLabel): self
{ {
$this->accompanyingPeriodLabel = $accompanyingPeriodLabel; $this->accompanyingPeriodLabel = $accompanyingPeriodLabel;
return $this;
} }
public function getSocialDataVisible(): int public function getSocialDataVisible(): int
@ -643,9 +709,11 @@ class ActivityType
return $this->socialDataVisible; return $this->socialDataVisible;
} }
public function setSocialDataVisible(int $socialDataVisible): void public function setSocialDataVisible(int $socialDataVisible): self
{ {
$this->socialDataVisible = $socialDataVisible; $this->socialDataVisible = $socialDataVisible;
return $this;
} }
public function getSocialDataLabel(): string public function getSocialDataLabel(): string
@ -653,9 +721,11 @@ class ActivityType
return $this->socialDataLabel; return $this->socialDataLabel;
} }
public function setSocialDataLabel(string $socialDataLabel): void public function setSocialDataLabel(string $socialDataLabel): self
{ {
$this->socialDataLabel = $socialDataLabel; $this->socialDataLabel = $socialDataLabel;
return $this;
} }
public function isVisible(string $field): bool public function isVisible(string $field): bool

View File

@ -9,6 +9,8 @@ use Chill\DocStoreBundle\Form\StoredObjectType;
use Chill\MainBundle\Form\Type\ChillCollectionType; use Chill\MainBundle\Form\Type\ChillCollectionType;
use Chill\MainBundle\Form\Type\CommentType; use Chill\MainBundle\Form\Type\CommentType;
use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
use Chill\ThirdPartyBundle\Entity\ThirdParty; use Chill\ThirdPartyBundle\Entity\ThirdParty;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bridge\Doctrine\Form\Type\EntityType;
@ -94,6 +96,38 @@ class ActivityType extends AbstractType
]); ]);
} }
/** @var ? \Chill\PersonBundle\Entity\AccompanyingPeriod $accompanyingPeriod */
$accompanyingPeriod = NULL;
if ($options['accompanyingPeriod']) {
$accompanyingPeriod = $options['accompanyingPeriod'];
}
if ($activityType->isVisible('socialIssues') && $accompanyingPeriod) {
$builder->add('socialIssues', EntityType::class, [
'label' => $activityType->getLabel('socialIssues'),
'required' => $activityType->isRequired('socialIssues'),
'class' => SocialIssue::class,
'choice_label' => function (SocialIssue $socialIssue) {
return $this->translatableStringHelper->localize($socialIssue->getTitle());
},
'multiple' => true,
'choices' => $accompanyingPeriod->getSocialIssues(),
]);
}
if ($activityType->isVisible('socialActions') && $accompanyingPeriod) {
$builder->add('socialActions', EntityType::class, [
'label' => $activityType->getLabel('socialActions'),
'required' => $activityType->isRequired('socialActions'),
'class' => SocialAction::class,
'choice_label' => function (SocialAction $socialAction) {
return $this->translatableStringHelper->localize($socialAction->getTitle());
},
'multiple' => true,
'choices' => $accompanyingPeriod->getSocialActions(),
]);
}
if ($activityType->isVisible('date')) { if ($activityType->isVisible('date')) {
$builder->add('date', ChillDateType::class, [ $builder->add('date', ChillDateType::class, [
'label' => $activityType->getLabel('date'), 'label' => $activityType->getLabel('date'),
@ -313,10 +347,11 @@ class ActivityType extends AbstractType
]); ]);
$resolver $resolver
->setRequired(['center', 'role', 'activityType']) ->setRequired(['center', 'role', 'activityType', 'accompanyingPeriod'])
->setAllowedTypes('center', ['null', 'Chill\MainBundle\Entity\Center']) ->setAllowedTypes('center', ['null', 'Chill\MainBundle\Entity\Center'])
->setAllowedTypes('role', 'Symfony\Component\Security\Core\Role\Role') ->setAllowedTypes('role', 'Symfony\Component\Security\Core\Role\Role')
->setAllowedTypes('activityType', \Chill\ActivityBundle\Entity\ActivityType::class) ->setAllowedTypes('activityType', \Chill\ActivityBundle\Entity\ActivityType::class)
->setAllowedTypes('accompanyingPeriod', [\Chill\PersonBundle\Entity\AccompanyingPeriod::class, 'null'])
; ;
} }

View File

@ -19,7 +19,13 @@
{{ form_row(edit_form.scope) }} {{ form_row(edit_form.scope) }}
{% endif %} {% endif %}
.. type {%- if form.socialActions is defined -%}
{{ form_row(form.socialActions) }}
{% endif %}
{%- if form.socialIssues is defined -%}
{{ form_row(form.socialIssues) }}
{% endif %}
{%- if edit_form.reasons is defined -%} {%- if edit_form.reasons is defined -%}
{{ form_row(edit_form.reasons) }} {{ form_row(edit_form.reasons) }}

View File

@ -20,9 +20,16 @@
{{ form_row(form.scope) }} {{ form_row(form.scope) }}
{% endif %} {% endif %}
.. type {%- if form.socialActions is defined -%}
{{ form_row(form.socialActions) }}
{% endif %}
{%- if form.reasons is defined -%} {%- if form.socialIssues is defined -%}
{{ form_row(form.socialIssues) }}
{% endif %}
{%- if form.reasons is defined -%}
{{ form_row(form.reasons) }} {{ form_row(form.reasons) }}
{% endif %} {% endif %}

View File

@ -53,36 +53,36 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
{ {
/** /**
* Mark an accompanying period as "occasional" * Mark an accompanying period as "occasional"
* *
* used in INTENSITY * used in INTENSITY
*/ */
public const INTENSITY_OCCASIONAL = 'occasional'; public const INTENSITY_OCCASIONAL = 'occasional';
/** /**
* Mark an accompanying period as "regular" * Mark an accompanying period as "regular"
* *
* used in INTENSITY * used in INTENSITY
*/ */
public const INTENSITY_REGULAR = 'regular'; public const INTENSITY_REGULAR = 'regular';
public const INTENSITIES = [self::INTENSITY_OCCASIONAL, self::INTENSITY_REGULAR]; public const INTENSITIES = [self::INTENSITY_OCCASIONAL, self::INTENSITY_REGULAR];
/** /**
* Mark an accompanying period as "draft". * Mark an accompanying period as "draft".
* *
* This means that the accompanying period is not yet * This means that the accompanying period is not yet
* confirmed by the creator * confirmed by the creator
*/ */
public const STEP_DRAFT = 'DRAFT'; public const STEP_DRAFT = 'DRAFT';
/** /**
* Mark an accompanying period as "confirmed". * Mark an accompanying period as "confirmed".
* *
* This means that the accompanying period **is** * This means that the accompanying period **is**
* confirmed by the creator * confirmed by the creator
*/ */
public const STEP_CONFIRMED = 'CONFIRMED'; public const STEP_CONFIRMED = 'CONFIRMED';
/** /**
* @var integer * @var integer
* *
@ -176,7 +176,7 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
* @Groups({"read"}) * @Groups({"read"})
*/ */
private $step = self::STEP_DRAFT; private $step = self::STEP_DRAFT;
/** /**
* @ORM\ManyToOne(targetEntity=Origin::class) * @ORM\ManyToOne(targetEntity=Origin::class)
* @ORM\JoinColumn(nullable=true) * @ORM\JoinColumn(nullable=true)
@ -274,7 +274,7 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
* ) * )
*/ */
private User $updatedBy; private User $updatedBy;
/** /**
* @ORM\Column(type="datetime", nullable=true, options={"default": NULL}) * @ORM\Column(type="datetime", nullable=true, options={"default": NULL})
*/ */
@ -416,7 +416,7 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
{ {
if (NULL !== $this->initialComment) { if (NULL !== $this->initialComment) {
$this->removeComment($this->initialComment); $this->removeComment($this->initialComment);
} }
if ($comment instanceof Comment) { if ($comment instanceof Comment) {
$this->addComment($comment); $this->addComment($comment);
} }
@ -473,7 +473,7 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
} }
/** /**
* Return true if the accompanying period contains a person. * Return true if the accompanying period contains a person.
* *
* **Note**: this participation can be opened or not. * **Note**: this participation can be opened or not.
*/ */
@ -520,7 +520,7 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
return $participation; return $participation;
} }
/** /**
* Remove Person * Remove Person
@ -823,6 +823,23 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
$this->socialIssues->removeElement($socialIssue); $this->socialIssues->removeElement($socialIssue);
} }
/**
* List of all the social actions of the accompanyingPeriod
* i.e. social actions From social issues from the accompanyingPeriod
*/
public function getSocialActions(): Collection
{
$ret = new ArrayCollection();
$this->socialIssues->forAll(function($key, $socialIssue) use ($ret) {
$socialIssue->getSocialActions()->forAll(function($key, $socialAction) use ($ret) {
$ret->add($socialAction);
});
});
return $ret;
}
/** /**
* Get a list of all persons which are participating to this course * Get a list of all persons which are participating to this course
*/ */