mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
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:
@@ -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%', [
|
||||
|
@@ -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%', [
|
||||
|
@@ -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,
|
||||
]);
|
||||
|
Reference in New Issue
Block a user