Преглед изворни кода

Correctif sur les fitler

develop
Fab пре 3 година
родитељ
комит
e928c5d335
9 измењених фајлова са 34 додато и 23 уклоњено
  1. +2
    -1
      Field/Filter/AssociationFilter.php
  2. +2
    -1
      Field/Filter/CheckboxFilter.php
  3. +2
    -1
      Field/Filter/ChoiceFilter.php
  4. +2
    -1
      Field/Filter/DateFilter.php
  5. +7
    -16
      Field/Filter/FilterManager.php
  6. +13
    -0
      Field/Filter/FilterTrait.php
  7. +2
    -1
      Field/Filter/ImageFilter.php
  8. +2
    -1
      Field/Filter/IntegerFilter.php
  9. +2
    -1
      Field/Filter/TextFilter.php

+ 2
- 1
Field/Filter/AssociationFilter.php Прегледај датотеку

@@ -54,8 +54,9 @@ class AssociationFilter
);
}

public function applyFilter(RepositoryQueryInterface $repositoryQuery, FieldDto $fieldDto, string $fieldProperty, $filteredValue = null)
public function applyFilter(RepositoryQueryInterface $repositoryQuery, FieldDto $fieldDto, $filteredValue = null)
{
$fieldProperty = $this->getFieldProperty($fieldDto);
if ($filteredValue !== null) {

if ($fieldDto->getFormTypeOption('multiple')) {

+ 2
- 1
Field/Filter/CheckboxFilter.php Прегледај датотеку

@@ -35,8 +35,9 @@ class CheckboxFilter
));
}

public function applyFilter(RepositoryQueryInterface $repositoryQuery, string $fieldProperty, string $filteredValue= null)
public function applyFilter(RepositoryQueryInterface $repositoryQuery, FieldDto $fieldDto, string $filteredValue= null)
{
$fieldProperty = $this->getFieldProperty($fieldDto);
if ($filteredValue !== null) {
if ($this->isRelationField($fieldProperty)) {
// $aliasRelation = $this->getFieldPropertyRelationAlias($fieldProperty);

+ 2
- 1
Field/Filter/ChoiceFilter.php Прегледај датотеку

@@ -49,8 +49,9 @@ class ChoiceFilter
);
}

public function applyFilter(RepositoryQueryInterface $repositoryQuery , string $fieldProperty, string $filteredValue = null)
public function applyFilter(RepositoryQueryInterface $repositoryQuery , FieldDto $fieldDto, string $filteredValue = null)
{
$fieldProperty = $this->getFieldProperty($fieldDto);
if ($filteredValue !== null) {
// if ($this->isRelationField($fieldProperty)) {
// $aliasRelation = $this->getFieldPropertyRelationAlias($fieldProperty);

+ 2
- 1
Field/Filter/DateFilter.php Прегледај датотеку

@@ -44,8 +44,9 @@ class DateFilter
);
}

public function applyFilter(RepositoryQueryInterface $repositoryQuery, string $fieldProperty, \DateTime $dateStart = null, \DateTime $dateEnd = null)
public function applyFilter(RepositoryQueryInterface $repositoryQuery, FieldDto $fieldDto, \DateTime $dateStart = null, \DateTime $dateEnd = null)
{
$fieldProperty = $this->getFieldProperty($fieldDto);
if ($dateStart) {
$repositoryQuery->andWhere(
'.' . $fieldProperty . ' >= :dateStart'

+ 7
- 16
Field/Filter/FilterManager.php Прегледај датотеку

@@ -78,15 +78,6 @@ class FilterManager
}
}

public function getFieldProperty(FieldDto $fieldDto)
{
$property = $fieldDto->getProperty();
//TODO pas forcément utile, à discuter
if ($fieldDto->getCustomOption('filter_on')) {
$property = $property . '.' . $fieldDto->getCustomOption('filter_on');
}
return $property;
}

public function applyFilter(RepositoryQueryInterface $repositoryQuery, FieldDto $fieldDto, array $filteredValue)
{
@@ -94,38 +85,38 @@ class FilterManager
$filterFqcn = $fieldDto->getCustomOption('filter_fqcn');
$customFilter = new $filterFqcn;

$customFilter->applyFilter($repositoryQuery, $this->getFieldProperty($fieldDto), $filteredValue['value']);
$customFilter->applyFilter($repositoryQuery, $fieldDto, $filteredValue['value']);
} else {

switch ($this->guessFormType($fieldDto)) {

case CheckboxType::class:
$checkboxFilter = new CheckboxFilter();
$checkboxFilter->applyFilter($repositoryQuery, $this->getFieldProperty($fieldDto), $filteredValue['value']);
$checkboxFilter->applyFilter($repositoryQuery, $fieldDto, $filteredValue['value']);
break;
case ChoiceType::class:
$choiceFilter = new ChoiceFilter();
$choiceFilter->applyFilter($repositoryQuery, $this->getFieldProperty($fieldDto), $filteredValue['value']);
$choiceFilter->applyFilter($repositoryQuery, $fieldDto, $filteredValue['value']);
break;
case IntegerType::class:
$integerFilter = new IntegerFilter();
$integerFilter->applyFilter($repositoryQuery, $this->getFieldProperty($fieldDto), $filteredValue['value']);
$integerFilter->applyFilter($repositoryQuery, $fieldDto, $filteredValue['value']);
break;
case TextareaType::class:
case TextType::class:
$textFilter = new TextFilter();
$textFilter->applyFilter($repositoryQuery, $this->getFieldProperty($fieldDto), $filteredValue['value']);
$textFilter->applyFilter($repositoryQuery, $fieldDto, $filteredValue['value']);
break;
case EntityType::class:
$textFilter = new AssociationFilter();
$textFilter->applyFilter($repositoryQuery, $fieldDto, $this->getFieldProperty($fieldDto), $filteredValue['value']);
$textFilter->applyFilter($repositoryQuery, $fieldDto, $filteredValue['value']);
break;
case DateTimeType::class:
case DateType::class:
$textFilter = new DateFilter();
$textFilter->applyFilter(
$repositoryQuery,
$this->getFieldProperty($fieldDto),
$fieldDto,
$filteredValue['dateStart'],
$filteredValue['dateEnd']
);

+ 13
- 0
Field/Filter/FilterTrait.php Прегледај датотеку

@@ -3,6 +3,8 @@
namespace Lc\SovBundle\Field\Filter;


use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto;

/**
* @author La clic ! <contact@laclic.fr>
*/
@@ -34,4 +36,15 @@ trait FilterTrait
return substr($fieldName, 0, strpos($fieldName, $needle));
}


public function getFieldProperty(FieldDto $fieldDto)
{
$property = $fieldDto->getProperty();
//TODO pas forcément utile, à discuter
if ($fieldDto->getCustomOption('filter_on')) {
$property = $property . '.' . $fieldDto->getCustomOption('filter_on');
}
return $property;
}

}

+ 2
- 1
Field/Filter/ImageFilter.php Прегледај датотеку

@@ -37,8 +37,9 @@ class ImageFilter
}


public function applyFilter(RepositoryQueryInterface $repositoryQuery, string $fieldProperty, $filteredValue = null)
public function applyFilter(RepositoryQueryInterface $repositoryQuery, FieldDto $fieldDto, $filteredValue = null)
{
$fieldProperty = $this->getFieldProperty($fieldDto);
if ($filteredValue !== null) {
if($filteredValue === 1){
$repositoryQuery->andWhere(

+ 2
- 1
Field/Filter/IntegerFilter.php Прегледај датотеку

@@ -31,8 +31,9 @@ class IntegerFilter
);
}

public function applyFilter(RepositoryQueryInterface $repositoryQuery, string $fieldProperty, string $filteredValue= null)
public function applyFilter(RepositoryQueryInterface $repositoryQuery, FieldDto $fieldDto, string $filteredValue= null)
{
$fieldProperty = $this->getFieldProperty($fieldDto);
if ($filteredValue !== null) {
$repositoryQuery->andWhere(
'.'.$fieldProperty.' = :'.$fieldProperty.''

+ 2
- 1
Field/Filter/TextFilter.php Прегледај датотеку

@@ -31,8 +31,9 @@ class TextFilter
);
}

public function applyFilter(RepositoryQueryInterface $repositoryQuery, string $fieldProperty, string $filteredValue = null)
public function applyFilter(RepositoryQueryInterface $repositoryQuery, FieldDto $fieldDto, string $filteredValue = null)
{
$fieldProperty = $this->getFieldProperty($fieldDto);

if ($filteredValue !== null) {
// if ($this->isRelationField($fieldProperty)) {

Loading…
Откажи
Сачувај