review: fix stuffs on socialAction and socialIssue filters:

* filters call static entity method
* add renderString option to manage add_children
* add tests on new entity method getDescendantsWithThisFor..()
* rename function in repository
* rename 'Select2..' classes by 'Pick..' and replace all occurences
This commit is contained in:
2022-10-17 09:52:29 +02:00
parent 71f989f00e
commit 32ddc5465c
22 changed files with 244 additions and 151 deletions

View File

@@ -13,7 +13,8 @@ namespace Chill\ActivityBundle\Export\Filter\ACPFilters;
use Chill\ActivityBundle\Export\Declarations;
use Chill\MainBundle\Export\FilterInterface;
use Chill\PersonBundle\Form\Type\Select2SocialActionType;
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
use Chill\PersonBundle\Form\Type\PickSocialActionType;
use Chill\PersonBundle\Templating\Entity\SocialActionRender;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
@@ -41,8 +42,10 @@ class BySocialActionFilter implements FilterInterface
$clause = $qb->expr()->in('actsocialaction.id', ':socialactions');
$qb ->andWhere($clause)
->setParameter('socialactions', $data['accepted_socialactions']);
$qb->andWhere($clause)
->setParameter('socialactions',
SocialAction::getDescendantsWithThisForActions($data['accepted_socialactions'])
);
}
public function applyOn(): string
@@ -52,7 +55,7 @@ class BySocialActionFilter implements FilterInterface
public function buildForm(FormBuilderInterface $builder)
{
$builder->add('accepted_socialactions', Select2SocialActionType::class, [
$builder->add('accepted_socialactions', PickSocialActionType::class, [
'multiple' => true
]);
}
@@ -61,8 +64,10 @@ class BySocialActionFilter implements FilterInterface
{
$actions = [];
foreach ($data['accepted_socialactions'] as $sa) {
$actions[] = $this->actionRender->renderString($sa, []);
foreach ($data['accepted_socialactions'] as $action) {
$actions[] = $this->actionRender->renderString($action, [
'show_and_children' => true,
]);
}
return ['Filtered activity by linked socialaction: only %actions%', [

View File

@@ -13,7 +13,8 @@ namespace Chill\ActivityBundle\Export\Filter\ACPFilters;
use Chill\ActivityBundle\Export\Declarations;
use Chill\MainBundle\Export\FilterInterface;
use Chill\PersonBundle\Form\Type\Select2SocialIssueType;
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
use Chill\PersonBundle\Form\Type\PickSocialIssueType;
use Chill\PersonBundle\Templating\Entity\SocialIssueRender;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
@@ -41,8 +42,10 @@ class BySocialIssueFilter implements FilterInterface
$clause = $qb->expr()->in('actsocialissue.id', ':socialissues');
$qb ->andWhere($clause)
->setParameter('socialissues', $data['accepted_socialissues']);
$qb->andWhere($clause)
->setParameter('socialissues',
SocialIssue::getDescendantsWithThisForIssues($data['accepted_socialissues'])
);
}
public function applyOn(): string
@@ -52,7 +55,7 @@ class BySocialIssueFilter implements FilterInterface
public function buildForm(FormBuilderInterface $builder)
{
$builder->add('accepted_socialissues', Select2SocialIssueType::class, [
$builder->add('accepted_socialissues', PickSocialIssueType::class, [
'multiple' => true
]);
}
@@ -61,8 +64,10 @@ class BySocialIssueFilter implements FilterInterface
{
$issues = [];
foreach ($data['accepted_socialissues'] as $si) {
$issues[] = $this->issueRender->renderString($si, []);
foreach ($data['accepted_socialissues'] as $issue) {
$issues[] = $this->issueRender->renderString($issue, [
'show_and_children' => true,
]);
}
return ['Filtered activity by linked socialissue: only %issues%', [

View File

@@ -13,7 +13,7 @@ namespace Chill\ActivityBundle\Export\Filter\ACPFilters;
use Chill\ActivityBundle\Export\Declarations;
use Chill\MainBundle\Export\FilterInterface;
use Chill\MainBundle\Form\Type\Select2LocationTypeType;
use Chill\MainBundle\Form\Type\PickLocationTypeType;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Doctrine\ORM\Query\Expr\Andx;
use Doctrine\ORM\QueryBuilder;
@@ -60,7 +60,7 @@ class LocationTypeFilter implements FilterInterface
public function buildForm(FormBuilderInterface $builder)
{
$builder->add('accepted_locationtype', Select2LocationTypeType::class, [
$builder->add('accepted_locationtype', PickLocationTypeType::class, [
'multiple' => true,
//'label' => false,
]);