mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
SocialAction & Issues in Activity form
This commit is contained in:
parent
32b3d74a1b
commit
0f635ca51a
@ -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,
|
||||||
@ -294,6 +295,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()) {
|
||||||
@ -324,7 +326,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(),
|
||||||
|
@ -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,42 @@ 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($accompanyingPeriod) {
|
||||||
|
dump($accompanyingPeriod->getSocialActions()->toArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
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 +351,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'])
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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) }}
|
||||||
|
@ -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 %}
|
||||||
|
|
||||||
|
@ -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
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user