浏览代码

[Backend] Correctifs parrainages

develop
Fab 3 年前
父节点
当前提交
1525fbb3cc
共有 4 个文件被更改,包括 74 次插入12 次删除
  1. +9
    -11
      ShopBundle/Controller/Backend/AdminController.php
  2. +17
    -0
      ShopBundle/Form/Backend/Common/EntityType.php
  3. +42
    -0
      ShopBundle/Form/Backend/Common/NewslettersType.php
  4. +6
    -1
      ShopBundle/Resources/public/js/backend/script/default/init-list.js

+ 9
- 11
ShopBundle/Controller/Backend/AdminController.php 查看文件

@@ -212,8 +212,8 @@ class AdminController extends EasyAdminController
if ($filter !== null) {
if ($this->utils->hasFilterAssociation($field['initProperty'])) {
$aliasRelation = $this->utils->getFilterAssociationAlias($field['initProperty']);
if(array_search($aliasRelation, $queryBuilder->getAllAliases())===false){
$queryBuilder->innerJoin('entity.'.$aliasRelation, $aliasRelation);
if (array_search($aliasRelation, $queryBuilder->getAllAliases()) === false) {
$queryBuilder->innerJoin('entity.' . $aliasRelation, $aliasRelation);
}
$queryBuilder->andWhere($field['initProperty'] . ' LIKE :' . $field['property'] . '');
$queryBuilder->setParameter($field['property'], '%' . $filter . '%');
@@ -231,23 +231,20 @@ class AdminController extends EasyAdminController
if ($filter !== null) {

//TODO Faut généraliser avec TreeInterface, ça ne doit pas être ici
if($field['property'] == 'productCategories') {
if ($field['property'] == 'productCategories') {

$queryBuilder->andWhere(':' . $field['property'] . ' MEMBER OF entity.' . $field['property'].' OR product_categories.parent = :' . $field['property']);
$queryBuilder->andWhere(':' . $field['property'] . ' MEMBER OF entity.' . $field['property'] . ' OR product_categories.parent = :' . $field['property']);
$queryBuilder->setParameter($field['property'], $filter);
}
else {
} else {
if ($field['type_options']['multiple']) {
$queryBuilder->andWhere(':' . $field['property'] . ' MEMBER OF entity.' . $field['property'] . '');
}
else {
} else {
$queryBuilder->andWhere('entity.' . $field['property'] . ' = :' . $field['property'] . '');
}

if ($filter instanceof TreeInterface && $filter->getParent() == null) {
$queryBuilder->setParameter($field['property'], array_merge(array($filter), $filter->getChildrens()->toArray()));
}
else {
} else {
$queryBuilder->setParameter($field['property'], $filter);
}
}
@@ -603,7 +600,8 @@ class AdminController extends EasyAdminController
$isFilterMerchantInterface = in_array('Lc\ShopBundle\Context\FilterMerchantInterface', $classImplements);
$isFilterMultipleMerchantsInterface = in_array('Lc\ShopBundle\Context\FilterMultipleMerchantsInterface', $classImplements);

if ($isFilterMerchantInterface || $isFilterMultipleMerchantsInterface) {
if (($isFilterMerchantInterface || $isFilterMultipleMerchantsInterface) && (!isset($passedOptions['merchant_filter']) || $passedOptions['merchant_filter'] === true)) {


if (in_array('Lc\ShopBundle\Context\StatusInterface', $classImplements)) {
$statusInterface = true;

+ 17
- 0
ShopBundle/Form/Backend/Common/EntityType.php 查看文件

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

namespace Lc\ShopBundle\Form\Backend\Common;

use Symfony\Bridge\Doctrine\Form\Type\EntityType as DefaultEntityType;
use Symfony\Component\OptionsResolver\OptionsResolver;

class EntityType extends DefaultEntityType
{
public function configureOptions(OptionsResolver $resolver)
{
parent::configureOptions($resolver);
$resolver->setDefaults([
'merchant_filter' => true
]);
}
}

+ 42
- 0
ShopBundle/Form/Backend/Common/NewslettersType.php 查看文件

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

namespace Lc\ShopBundle\Form\Backend\Common;

use Doctrine\ORM\EntityManagerInterface;

use Lc\ShopBundle\Context\NewsletterInterface;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;

class NewslettersType extends AbstractType
{
protected $em;
public function __construct(EntityManagerInterface $entityManager){
$this->em = $entityManager;
}

public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
$builder = $event->getForm()->getParent();
$newsletterClass = $this->em->getClassMetadata(NewsletterInterface::class);

$builder->add('newsletters', EntityType::class, [
'class' => $newsletterClass->getName(),
'multiple' =>true,
'required' => false,
'merchant_filter'=> false
]);
});
}

public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'merchant_filter' => false
]);
}
}

+ 6
- 1
ShopBundle/Resources/public/js/backend/script/default/init-list.js 查看文件

@@ -26,9 +26,14 @@ function initDeleteAction() {
});


/* $('.action-confirm').each(function () {
$(this).on('click', function (e) {
return confirm("Êtes vous sur de vouloir effectuer cette action ?");
});
});*/
$('.action-duplicate').each(function () {
$(this).on('click', function (e) {
return confirm("Press a button!");
return confirm("Êtes vous sur de vouloir effectuer cette action ?");
});
});
}

正在加载...
取消
保存