mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 21:34:25 +00:00
more attempts to make dynamic form work
This commit is contained in:
parent
01f6eb1a8f
commit
5060906591
@ -6,9 +6,11 @@ use Chill\MainBundle\Export\FilterInterface;
|
|||||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
use Chill\PersonBundle\Entity\SocialWork\Goal;
|
use Chill\PersonBundle\Entity\SocialWork\Goal;
|
||||||
use Chill\PersonBundle\Export\Declarations;
|
use Chill\PersonBundle\Export\Declarations;
|
||||||
|
use Chill\PersonBundle\Repository\SocialWork\SocialActionRepository;
|
||||||
use Doctrine\ORM\Query\Expr\Andx;
|
use Doctrine\ORM\Query\Expr\Andx;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
|
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
|
||||||
use Chill\PersonBundle\Templating\Entity\SocialActionRender;
|
use Chill\PersonBundle\Templating\Entity\SocialActionRender;
|
||||||
@ -26,17 +28,26 @@ class SocialWorkTypeFilter implements FilterInterface
|
|||||||
|
|
||||||
private TranslatableStringHelper $translatableStringHelper;
|
private TranslatableStringHelper $translatableStringHelper;
|
||||||
|
|
||||||
public function __construct(SocialActionRender $socialActionRender, TranslatableStringHelper $translatableStringHelper)
|
private SocialActionRepository $socialActionRepository;
|
||||||
|
|
||||||
|
public function __construct
|
||||||
|
(
|
||||||
|
SocialActionRender $socialActionRender,
|
||||||
|
TranslatableStringHelper $translatableStringHelper,
|
||||||
|
SocialActionRepository $socialActionRepository
|
||||||
|
)
|
||||||
{
|
{
|
||||||
$this->socialActionRender = $socialActionRender;
|
$this->socialActionRender = $socialActionRender;
|
||||||
$this->translatableStringHelper = $translatableStringHelper;
|
$this->translatableStringHelper = $translatableStringHelper;
|
||||||
|
$this->socialActionRepository = $socialActionRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder)
|
public function buildForm(FormBuilderInterface $builder)
|
||||||
{
|
{
|
||||||
|
$socialActions = $this->socialActionRepository->findAll();
|
||||||
|
|
||||||
$builder->add('actionType', EntityType::class, [
|
$builder->add('actionType', ChoiceType::class, [
|
||||||
'class' => SocialAction::class,
|
'choices' => $socialActions,
|
||||||
'choice_label' => function (SocialAction $sa) {
|
'choice_label' => function (SocialAction $sa) {
|
||||||
return $this->socialActionRender->renderString($sa, []);
|
return $this->socialActionRender->renderString($sa, []);
|
||||||
},
|
},
|
||||||
@ -48,8 +59,7 @@ class SocialWorkTypeFilter implements FilterInterface
|
|||||||
|
|
||||||
$goals = null === $actionType ? [] : $actionType->getGoals();
|
$goals = null === $actionType ? [] : $actionType->getGoals();
|
||||||
|
|
||||||
$form->add('goal', EntityType::class, [
|
$form->add('goal', ChoiceType::class, [
|
||||||
'class' => Goal::class,
|
|
||||||
'placeholder' => '',
|
'placeholder' => '',
|
||||||
'choices' => $goals,
|
'choices' => $goals,
|
||||||
'choice_label' => function (Goal $g) {
|
'choice_label' => function (Goal $g) {
|
||||||
@ -58,22 +68,18 @@ class SocialWorkTypeFilter implements FilterInterface
|
|||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
|
|
||||||
$builder->addEventListener(FormEvents::POST_SUBMIT, function (PostSubmitEvent $event) use ($refreshGoals) {
|
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($refreshGoals) {
|
||||||
dump($event);
|
|
||||||
$form = $event->getForm();
|
|
||||||
$data = $event->getData();
|
$data = $event->getData();
|
||||||
|
dump($data);
|
||||||
|
|
||||||
$refreshGoals($form, $data);
|
$refreshGoals($event->getForm(), $data);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$builder->get('actionType')->addEventListener(
|
$builder->get('actionType')->addEventListener(
|
||||||
FormEvents::POST_SUBMIT,
|
FormEvents::POST_SUBMIT,
|
||||||
function (FormEvent $event) use ($refreshGoals) {
|
function (FormEvent $event) use ($refreshGoals) {
|
||||||
$actionType = $event->getForm()->getData();
|
$actionType = $event->getForm()->getData();
|
||||||
dump('after submit listener');
|
|
||||||
dump($actionType);
|
dump($actionType);
|
||||||
|
|
||||||
$refreshGoals($event->getForm()->getParent(), $actionType);
|
$refreshGoals($event->getForm()->getParent(), $actionType);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -129,4 +135,4 @@ class SocialWorkTypeFilter implements FilterInterface
|
|||||||
{
|
{
|
||||||
return Declarations::SOCIAL_WORK_ACTION_TYPE;
|
return Declarations::SOCIAL_WORK_ACTION_TYPE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
services:
|
services:
|
||||||
|
|
||||||
chill.person.export.count_social_work_actions:
|
chill.person.export.count_social_work_actions:
|
||||||
class: Chill\PersonBundle\Export\Export\CountSocialWorkActions
|
class: Chill\PersonBundle\Export\Export\CountSocialWorkActions
|
||||||
@ -6,15 +6,15 @@ services:
|
|||||||
autoconfigure: true
|
autoconfigure: true
|
||||||
tags:
|
tags:
|
||||||
- { name: chill.export, alias: count_social_work_actions }
|
- { name: chill.export, alias: count_social_work_actions }
|
||||||
|
|
||||||
## FILTERS
|
## FILTERS
|
||||||
|
|
||||||
# chill.person.export.filter_social_work_type:
|
chill.person.export.filter_social_work_type:
|
||||||
# class: Chill\PersonBundle\Export\Filter\SocialWorkFilters\SocialWorkTypeFilter
|
class: Chill\PersonBundle\Export\Filter\SocialWorkFilters\SocialWorkTypeFilter
|
||||||
# autowire: true
|
autowire: true
|
||||||
# autoconfigure: true
|
autoconfigure: true
|
||||||
# tags:
|
tags:
|
||||||
# - { name: chill.export_filter, alias: social_work_type_filter }
|
- { name: chill.export_filter, alias: social_work_type_filter }
|
||||||
|
|
||||||
chill.person.export.filter_scope:
|
chill.person.export.filter_scope:
|
||||||
class: Chill\PersonBundle\Export\Filter\SocialWorkFilters\ScopeFilter
|
class: Chill\PersonBundle\Export\Filter\SocialWorkFilters\ScopeFilter
|
||||||
@ -36,7 +36,7 @@ services:
|
|||||||
autoconfigure: true
|
autoconfigure: true
|
||||||
tags:
|
tags:
|
||||||
- { name: chill.export_filter, alias: social_work_actions_treatingagent_filter }
|
- { name: chill.export_filter, alias: social_work_actions_treatingagent_filter }
|
||||||
|
|
||||||
## AGGREGATORS
|
## AGGREGATORS
|
||||||
chill.person.export.aggregator_action_type:
|
chill.person.export.aggregator_action_type:
|
||||||
class: Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\ActionTypeAggregator
|
class: Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\ActionTypeAggregator
|
||||||
@ -65,14 +65,14 @@ services:
|
|||||||
autoconfigure: true
|
autoconfigure: true
|
||||||
tags:
|
tags:
|
||||||
- { name: chill.export_aggregator, alias: social_work_actions_treatingagent_aggregator }
|
- { name: chill.export_aggregator, alias: social_work_actions_treatingagent_aggregator }
|
||||||
|
|
||||||
chill.person.export.aggregator_goal:
|
chill.person.export.aggregator_goal:
|
||||||
class: Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\GoalAggregator
|
class: Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\GoalAggregator
|
||||||
autowire: true
|
autowire: true
|
||||||
autoconfigure: true
|
autoconfigure: true
|
||||||
tags:
|
tags:
|
||||||
- { name: chill.export_aggregator, alias: social_work_actions_goal_aggregator }
|
- { name: chill.export_aggregator, alias: social_work_actions_goal_aggregator }
|
||||||
|
|
||||||
chill.person.export.aggregator_result:
|
chill.person.export.aggregator_result:
|
||||||
class: Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\ResultAggregator
|
class: Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\ResultAggregator
|
||||||
autowire: true
|
autowire: true
|
||||||
|
@ -352,6 +352,7 @@ Exports of social work actions: Exports des actions d'accompangement
|
|||||||
Count social work actions: Nombre d'actions d'accompagnement
|
Count social work actions: Nombre d'actions d'accompagnement
|
||||||
Count social work actions by various parameters: Compte le nombre d'actions d'accompagnement en fonction de différents filtres.
|
Count social work actions by various parameters: Compte le nombre d'actions d'accompagnement en fonction de différents filtres.
|
||||||
|
|
||||||
|
|
||||||
Exports of evaluations: Exports des évaluations
|
Exports of evaluations: Exports des évaluations
|
||||||
Count evaluations: Nombre d'évaluations
|
Count evaluations: Nombre d'évaluations
|
||||||
Count evaluation by various parameters.: Compte le nombre d'évaluations selon différents filtres.
|
Count evaluation by various parameters.: Compte le nombre d'évaluations selon différents filtres.
|
||||||
@ -448,6 +449,7 @@ Filter by socialaction: Filtrer les parcours par action d'accompagnement
|
|||||||
Accepted socialactions: Actions d'accompagnement
|
Accepted socialactions: Actions d'accompagnement
|
||||||
"Filtered by socialactions: only %socialactions%": "Filtré par action d'accompagnement: uniquement %socialactions%"
|
"Filtered by socialactions: only %socialactions%": "Filtré par action d'accompagnement: uniquement %socialactions%"
|
||||||
Group by social action: Grouper les parcours par action d'accompagnement
|
Group by social action: Grouper les parcours par action d'accompagnement
|
||||||
|
Filter by type of action, objectives and results: "Filtrer par type d'action, objectif et résultat"
|
||||||
|
|
||||||
Filter by evaluation: Filtrer les parcours par évaluation
|
Filter by evaluation: Filtrer les parcours par évaluation
|
||||||
Accepted evaluations: Évaluations
|
Accepted evaluations: Évaluations
|
||||||
|
Loading…
x
Reference in New Issue
Block a user