Selaa lähdekoodia

Merge branch 'develop' of https://forge.laclic.fr/Laclic/CaracoleBundle into develop

packProduct
Fabien Normand 3 vuotta sitten
vanhempi
commit
ec51ce2dc2
6 muutettua tiedostoa jossa 139 lisäystä ja 1 poistoa
  1. +38
    -0
      Field/Filter/User/UserExtraInfoCityFilter.php
  2. +38
    -0
      Field/Filter/User/UserExtraInfoZipFilter.php
  3. +11
    -1
      Repository/Product/ProductFamilyRepositoryQuery.php
  4. +30
    -0
      Repository/User/UserRepositoryQuery.php
  5. +11
    -0
      Resources/views/admin/user/field/extra_infos_city.html.twig
  6. +11
    -0
      Resources/views/admin/user/field/extra_infos_zip.html.twig

+ 38
- 0
Field/Filter/User/UserExtraInfoCityFilter.php Näytä tiedosto

@@ -0,0 +1,38 @@
<?php

namespace Lc\CaracoleBundle\Field\Filter\User;

use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto;
use Lc\SovBundle\Field\Filter\AssociationFilter;
use Lc\SovBundle\Repository\RepositoryQueryInterface;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;

/**
* @author La clic ! <contact@laclic.fr>
*/
class UserExtraInfoCityFilter extends AssociationFilter
{
public function buildProperty(FormBuilderInterface $builder, FieldDto $fieldDto, $options = array())
{
$builder->add(
$this->getFieldPropertySnake($fieldDto->getProperty()),
TextType::class,
array(
'required' => false,
'attr' => array(
'class' => ' input-sm',
'form' => 'filters-form',
),
)
);
}

public function applyFilter(RepositoryQueryInterface $repositoryQuery, FieldDto $fieldDto, $filteredValue = null)
{
if ($filteredValue !== null) {
$repositoryQuery->filterByExtraInfoCity('%' . $filteredValue . '%');
}
}

}

+ 38
- 0
Field/Filter/User/UserExtraInfoZipFilter.php Näytä tiedosto

@@ -0,0 +1,38 @@
<?php

namespace Lc\CaracoleBundle\Field\Filter\User;

use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto;
use Lc\SovBundle\Field\Filter\AssociationFilter;
use Lc\SovBundle\Repository\RepositoryQueryInterface;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;

/**
* @author La clic ! <contact@laclic.fr>
*/
class UserExtraInfoZipFilter extends AssociationFilter
{
public function buildProperty(FormBuilderInterface $builder, FieldDto $fieldDto, $options = array())
{
$builder->add(
$this->getFieldPropertySnake($fieldDto->getProperty()),
TextType::class,
array(
'required' => false,
'attr' => array(
'class' => ' input-sm',
'form' => 'filters-form',
),
)
);
}

public function applyFilter(RepositoryQueryInterface $repositoryQuery, FieldDto $fieldDto, $filteredValue = null)
{
if ($filteredValue !== null) {
$repositoryQuery->filterByExtraInfoZip('%' . $filteredValue . '%');
}
}

}

+ 11
- 1
Repository/Product/ProductFamilyRepositoryQuery.php Näytä tiedosto

@@ -25,6 +25,15 @@ class ProductFamilyRepositoryQuery extends AbstractRepositoryQuery
parent::__construct($repository, 'productFamily', $paginator);
}

public function resetRelationsJoin(): void
{
$this->isJoinSections = false;
$this->isJoinProductCategories = false;
$this->isJoinProductFamilySectionProperties = false;
$this->isJoinProducts = false;
$this->isJoinQualityLabels = false;
}

public function joinProductFamilySectionProperties(bool $addSelect = true): self
{
if (!$this->isJoinProductFamilySectionProperties) {
@@ -178,7 +187,8 @@ class ProductFamilyRepositoryQuery extends AbstractRepositoryQuery

$this->innerJoin('.products', 'products');
if ($addSelect) {
$this->addSelect('products');
// Décommenté sinon doctrine n'hydrate pas correctement les produits liés au ProductFamily (exemple : un seul sur deux)
// $this->addSelect('products');
}
}
return $this;

+ 30
- 0
Repository/User/UserRepositoryQuery.php Näytä tiedosto

@@ -11,6 +11,7 @@ class UserRepositoryQuery extends SovUserRepositoryQuery
use MerchantRepositoryQueryTrait;

protected $isJoinUserMerchants = false;
protected $isJoinAddresses = false;


public function joinUserMerchants(): self
@@ -24,6 +25,17 @@ class UserRepositoryQuery extends SovUserRepositoryQuery
return $this;
}

public function joinAddresses(): self
{
if (!$this->isJoinAddresses) {
$this->isJoinAddresses = true;

return $this
->innerJoin('.addresses', 'addresses');
}
return $this;
}

public function filterMerchantIsActive(): self
{
$this->joinUserMerchants();
@@ -38,4 +50,22 @@ class UserRepositoryQuery extends SovUserRepositoryQuery
->andWhere('userMerchants.merchant = :merchant')
->setParameter('merchant', $merchant);
}

public function filterByExtraInfoZip(string $zip)
{
$this->joinAddresses();

return $this
->andWhere('.extraInfoZip LIKE :extraInfoZip OR addresses.zip LIKE :extraInfoZip')
->setParameter('extraInfoZip', $zip);
}

public function filterByExtraInfoCity(string $city)
{
$this->joinAddresses();

return $this
->andWhere('.extraInfoCity LIKE :extraInfoCity OR addresses.city LIKE :extraInfoCity')
->setParameter('extraInfoCity', $city);
}
}

+ 11
- 0
Resources/views/admin/user/field/extra_infos_city.html.twig Näytä tiedosto

@@ -0,0 +1,11 @@
{% set user = entity.instance %}
{% set city = user.extraInfoCity %}
{% if city is not empty %}
<span class="badge badge-secondary">{{ city }}</span>
{% elseif user.addresses is not empty %}
{% for addresse in user.addresses %}
<span class="badge badge-secondary">{{ addresse.city }}</span>
{% endfor %}
{% else %}
<span class="badge badge-secondary">Aucun(e)</span>
{% endif %}

+ 11
- 0
Resources/views/admin/user/field/extra_infos_zip.html.twig Näytä tiedosto

@@ -0,0 +1,11 @@
{% set user = entity.instance %}
{% set zip = user.extraInfoZip %}
{% if zip is not empty %}
<span class="badge badge-secondary">{{ zip }}</span>
{% elseif user.addresses is not empty %}
{% for addresse in user.addresses %}
<span class="badge badge-secondary">{{ addresse.zip }}</span>
{% endfor %}
{% else %}
<span class="badge badge-secondary">Aucun(e)</span>
{% endif %}

Loading…
Peruuta
Tallenna