Przeglądaj źródła

Admin : filtre "Tout afficher

packProduct
Guillaume 3 lat temu
rodzic
commit
bce5c0613c
41 zmienionych plików z 497 dodań i 176 usunięć
  1. +0
    -1
      Builder/Order/OrderShopBuilder.php
  2. +10
    -1
      Container/Product/ProductCategoryContainer.php
  3. +9
    -1
      Container/Reduction/ReductionCartContainer.php
  4. +10
    -1
      Container/Reduction/ReductionCatalogContainer.php
  5. +2
    -2
      Context/SectionContextTrait.php
  6. +17
    -84
      Controller/AdminControllerTrait.php
  7. +1
    -1
      Controller/ControllerTrait.php
  8. +9
    -3
      Controller/Newsletter/NewsletterAdminController.php
  9. +4
    -17
      Controller/Product/ProductCategoryAdminController.php
  10. +22
    -11
      Controller/Section/OpeningAdminController.php
  11. +0
    -1
      Controller/Section/SectionAdminController.php
  12. +9
    -3
      Controller/Section/SwitchSectionAdminController.php
  13. +19
    -18
      Controller/Setting/SettingAdminController.php
  14. +2
    -2
      Controller/Site/NewsAdminController.php
  15. +3
    -3
      Controller/Site/PageAdminController.php
  16. +10
    -0
      Definition/Field/AbstractFieldDefinition.php
  17. +46
    -0
      Definition/Field/FieldDefinitionTrait.php
  18. +36
    -0
      Definition/Field/Newsletter/NewsletterFieldDefinition.php
  19. +11
    -1
      Definition/Field/Order/OrderShopFieldDefinition.php
  20. +79
    -0
      Definition/Field/Product/ProductCategoryFieldDefinition.php
  21. +27
    -0
      Definition/Field/Reduction/ReductionCartFieldDefinition.php
  22. +27
    -0
      Definition/Field/Reduction/ReductionCatalogFieldDefinition.php
  23. +31
    -0
      Definition/Field/Site/NewsFieldDefinition.php
  24. +30
    -0
      Definition/Field/Site/PageFieldDefinition.php
  25. +2
    -0
      Factory/Site/PageFactory.php
  26. +10
    -7
      Form/Section/SwitchSectionFormType.php
  27. +2
    -1
      Model/Site/PageModel.php
  28. +2
    -1
      Repository/Product/ProductStore.php
  29. +1
    -1
      Repository/Ticket/TicketStore.php
  30. +1
    -1
      Repository/User/UserStore.php
  31. +12
    -3
      Resolver/SectionResolver.php
  32. +2
    -0
      Resources/translations/admin.fr.yaml
  33. +3
    -1
      Resources/views/admin/product/field/product_family_sales.html.twig
  34. +7
    -0
      Resources/views/admin/product/field/product_family_section_properties.html.twig
  35. +7
    -0
      Resources/views/admin/section/field/section.html.twig
  36. +7
    -0
      Resources/views/admin/section/field/sections.html.twig
  37. +4
    -0
      Resources/views/admin/section/macros.html.twig
  38. +2
    -2
      Resources/views/admin/setting/edit_section.html.twig
  39. +14
    -8
      Resources/views/adminlte/layout.html.twig
  40. +6
    -0
      Solver/Section/SectionSolver.php
  41. +1
    -1
      Twig/StoreTwigExtension.php

+ 0
- 1
Builder/Order/OrderShopBuilder.php Wyświetl plik

@@ -646,7 +646,6 @@ class OrderShopBuilder
$orderShop->setDeclineComplementaryOrderShop(false);
}


public function getProductsSalesStatistic(SectionInterface $section, $entity, $nbWeek = 2)
{
$productsSalesStatistic = new ProductsSalesStatistic(

+ 10
- 1
Container/Product/ProductCategoryContainer.php Wyświetl plik

@@ -2,6 +2,7 @@

namespace Lc\CaracoleBundle\Container\Product;

use Lc\CaracoleBundle\Definition\Field\Product\ProductCategoryFieldDefinition;
use Lc\CaracoleBundle\Factory\Product\ProductCategoryFactory;
use Lc\CaracoleBundle\Repository\Product\ProductCategoryRepositoryQuery;
use Lc\CaracoleBundle\Repository\Product\ProductCategoryStore;
@@ -13,17 +14,20 @@ class ProductCategoryContainer
protected ProductCategorySolver $solver;
protected ProductCategoryRepositoryQuery $repositoryQuery;
protected ProductCategoryStore $store;
protected ProductCategoryFieldDefinition $fieldDefinition;

public function __construct(
ProductCategoryFactory $factory,
ProductCategorySolver $solver,
ProductCategoryRepositoryQuery $repositoryQuery,
ProductCategoryStore $store
ProductCategoryStore $store,
ProductCategoryFieldDefinition $fieldDefinition
) {
$this->factory = $factory;
$this->solver = $solver;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
$this->fieldDefinition = $fieldDefinition;
}

public function getFactory(): ProductCategoryFactory
@@ -48,4 +52,9 @@ class ProductCategoryContainer
return $this->store;
}

public function getFieldDefinition(): ProductCategoryFieldDefinition
{
return $this->fieldDefinition;
}

}

+ 9
- 1
Container/Reduction/ReductionCartContainer.php Wyświetl plik

@@ -2,6 +2,7 @@

namespace Lc\CaracoleBundle\Container\Reduction;

use Lc\CaracoleBundle\Definition\Field\Reduction\ReductionCartFieldDefinition;
use Lc\CaracoleBundle\Factory\Reduction\ReductionCartFactory;
use Lc\CaracoleBundle\Repository\Reduction\ReductionCartRepositoryQuery;
use Lc\CaracoleBundle\Repository\Reduction\ReductionCartStore;
@@ -11,15 +12,18 @@ class ReductionCartContainer
protected ReductionCartFactory $factory;
protected ReductionCartRepositoryQuery $repositoryQuery;
protected ReductionCartStore $store;
protected ReductionCartFieldDefinition $fieldDefinition;

public function __construct(
ReductionCartFactory $factory,
ReductionCartRepositoryQuery $repositoryQuery,
ReductionCartStore $store
ReductionCartStore $store,
ReductionCartFieldDefinition $fieldDefinition
) {
$this->factory = $factory;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
$this->fieldDefinition = $fieldDefinition;
}

public function getFactory(): ReductionCartFactory
@@ -39,4 +43,8 @@ class ReductionCartContainer
return $this->store;
}

public function getFieldDefinition(): ReductionCartFieldDefinition
{
return $this->fieldDefinition;
}
}

+ 10
- 1
Container/Reduction/ReductionCatalogContainer.php Wyświetl plik

@@ -2,6 +2,7 @@

namespace Lc\CaracoleBundle\Container\Reduction;

use Lc\CaracoleBundle\Definition\Field\Reduction\ReductionCatalogFieldDefinition;
use Lc\CaracoleBundle\Factory\Reduction\ReductionCatalogFactory;
use Lc\CaracoleBundle\Repository\Reduction\ReductionCatalogRepositoryQuery;
use Lc\CaracoleBundle\Repository\Reduction\ReductionCatalogStore;
@@ -11,15 +12,18 @@ class ReductionCatalogContainer
protected ReductionCatalogFactory $factory;
protected ReductionCatalogRepositoryQuery $repositoryQuery;
protected ReductionCatalogStore $store;
protected ReductionCatalogFieldDefinition $fieldDefinition;

public function __construct(
ReductionCatalogFactory $factory,
ReductionCatalogRepositoryQuery $repositoryQuery,
ReductionCatalogStore $store
ReductionCatalogStore $store,
ReductionCatalogFieldDefinition $fieldDefinition
) {
$this->factory = $factory;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
$this->fieldDefinition = $fieldDefinition;
}

public function getFactory(): ReductionCatalogFactory
@@ -39,4 +43,9 @@ class ReductionCatalogContainer
return $this->store;
}

public function getFieldDefinition(): ReductionCatalogFieldDefinition
{
return $this->fieldDefinition;
}

}

+ 2
- 2
Context/SectionContextTrait.php Wyświetl plik

@@ -6,9 +6,9 @@ use Lc\CaracoleBundle\Model\Section\SectionInterface;

trait SectionContextTrait
{
protected SectionInterface $section;
protected ?SectionInterface $section;

public function setSection(SectionInterface $section)
public function setSection(?SectionInterface $section)
{
$this->section = $section;


+ 17
- 84
Controller/AdminControllerTrait.php Wyświetl plik

@@ -3,7 +3,6 @@
namespace Lc\CaracoleBundle\Controller;

use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\QueryBuilder;
use EasyCorp\Bundle\EasyAdminBundle\Collection\FieldCollection;
use EasyCorp\Bundle\EasyAdminBundle\Collection\FilterCollection;
use EasyCorp\Bundle\EasyAdminBundle\Config\Action;
@@ -15,36 +14,6 @@ use EasyCorp\Bundle\EasyAdminBundle\Exception\ForbiddenActionException;
use EasyCorp\Bundle\EasyAdminBundle\Exception\InsufficientEntityPermissionException;
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator;
use EasyCorp\Bundle\EasyAdminBundle\Security\Permission;
use Lc\CaracoleBundle\Container\Address\AddressContainer;
use Lc\CaracoleBundle\Container\Config\TaxRateContainer;
use Lc\CaracoleBundle\Container\Config\UnitContainer;
use Lc\CaracoleBundle\Container\Credit\CreditHistoryContainer;
use Lc\CaracoleBundle\Container\File\DocumentContainer;
use Lc\CaracoleBundle\Container\Merchant\MerchantContainer;
use Lc\CaracoleBundle\Container\Order\OrderPaymentContainer;
use Lc\CaracoleBundle\Container\Order\OrderProductContainer;
use Lc\CaracoleBundle\Container\Order\OrderProductReductionCatalogContainer;
use Lc\CaracoleBundle\Container\Order\OrderProductRefundContainer;
use Lc\CaracoleBundle\Container\Order\OrderReductionCartContainer;
use Lc\CaracoleBundle\Container\Order\OrderReductionCreditContainer;
use Lc\CaracoleBundle\Container\Order\OrderRefundContainer;
use Lc\CaracoleBundle\Container\Order\OrderShopContainer;
use Lc\CaracoleBundle\Container\Order\OrderStatusContainer;
use Lc\CaracoleBundle\Container\Order\OrderStatusHistoryContainer;
use Lc\CaracoleBundle\Container\PointSale\PointSaleContainer;
use Lc\CaracoleBundle\Container\Product\ProductCategoryContainer;
use Lc\CaracoleBundle\Container\Product\ProductContainer;
use Lc\CaracoleBundle\Container\Product\ProductFamilyContainer;
use Lc\CaracoleBundle\Container\Reduction\ReductionCartContainer;
use Lc\CaracoleBundle\Container\Reduction\ReductionCatalogContainer;
use Lc\CaracoleBundle\Container\Reduction\ReductionCreditContainer;
use Lc\CaracoleBundle\Container\Section\OpeningContainer;
use Lc\CaracoleBundle\Container\Section\SectionContainer;
use Lc\CaracoleBundle\Container\Setting\MerchantSettingContainer;
use Lc\CaracoleBundle\Container\Setting\SectionSettingContainer;
use Lc\CaracoleBundle\Container\User\UserMerchantContainer;
use Lc\CaracoleBundle\Container\User\UserPointSaleContainer;
use Lc\CaracoleBundle\Container\User\VisitorContainer;
use Lc\CaracoleBundle\Definition\ActionDefinition;
use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface;
use Lc\CaracoleBundle\Doctrine\Extension\FilterMultipleMerchantsInterface;
@@ -63,66 +32,27 @@ use Symfony\Component\HttpFoundation\Response;

trait AdminControllerTrait
{

use ControllerTrait;

//TODO doit implementer ControllerTrait
/*public static function getSubscribedServices()
{
return array_merge(
parent::getSubscribedServices(),
self::getSubscribedServicesList()
);
}

public static function getSubscribedServicesList()
{
return [
MerchantResolver::class => MerchantResolver::class,
SectionResolver::class => SectionResolver::class,
AddressContainer::class => AddressContainer::class,
TaxRateContainer::class => TaxRateContainer::class,
UnitContainer::class => UnitContainer::class,
CreditHistoryContainer::class => CreditHistoryContainer::class,
DocumentContainer::class => DocumentContainer::class,
MerchantContainer::class => MerchantContainer::class,
OrderPaymentContainer::class => OrderPaymentContainer::class,
OrderProductContainer::class => OrderProductContainer::class,
OrderProductReductionCatalogContainer::class => OrderProductReductionCatalogContainer::class,
OrderProductRefundContainer::class => OrderProductRefundContainer::class,
OrderReductionCartContainer::class => OrderReductionCartContainer::class,
OrderReductionCreditContainer::class => OrderReductionCreditContainer::class,
OrderRefundContainer::class => OrderRefundContainer::class,
OrderShopContainer::class => OrderShopContainer::class,
OrderStatusContainer::class => OrderStatusContainer::class,
OrderStatusHistoryContainer::class => OrderStatusHistoryContainer::class,
PointSaleContainer::class => PointSaleContainer::class,
ProductCategoryContainer::class => ProductCategoryContainer::class,
ProductContainer::class => ProductContainer::class,
ProductFamilyContainer::class => ProductFamilyContainer::class,
ReductionCartContainer::class => ReductionCartContainer::class,
ReductionCatalogContainer::class => ReductionCatalogContainer::class,
ReductionCreditContainer::class => ReductionCreditContainer::class,
OpeningContainer::class => OpeningContainer::class,
SectionContainer::class => SectionContainer::class,
MerchantSettingContainer::class => MerchantSettingContainer::class,
SectionSettingContainer::class => SectionSettingContainer::class,
UserMerchantContainer::class => UserMerchantContainer::class,
UserPointSaleContainer::class => UserPointSaleContainer::class,
VisitorContainer::class => VisitorContainer::class
];
}*/

public function configureResponseParameters(KeyValueStore $responseParameters): KeyValueStore
{
$responseParameters = parent::configureResponseParameters($responseParameters);

// affichage du filtre sur section
$this->configureResponseParametersFilterSection($responseParameters);

return $responseParameters;
}

public function configureResponseParametersFilterSection(KeyValueStore $responseParameters)
{
if ($this->isInstanceOf(FilterSectionInterface::class)) {
$responseParameters->set('display_switch_section', true);
}
}

return $responseParameters;
public function configureResponseParametersDisableShowAllSections(KeyValueStore $responseParameters)
{
$responseParameters->set('replace_content_with_message', "Vous devez sélectionner une section pour afficher ces données.");
}

public function createIndexRepositoryQuery(
@@ -138,12 +68,15 @@ trait AdminControllerTrait
$filters
);

if ($this->isInstanceOf(FilterMerchantInterface::class) || $this->isInstanceOf(FilterMultipleMerchantsInterface::class)) {
$sectionCurrent = $this->get(SectionResolver::class)->getCurrent();

if ($this->isInstanceOf(FilterMerchantInterface::class)
|| $this->isInstanceOf(FilterMultipleMerchantsInterface::class)) {
$repositoryQuery->filterByMerchant($this->get(MerchantResolver::class)->getCurrent());
}

if ($this->isInstanceOf(FilterSectionInterface::class)) {
$repositoryQuery->filterBySection($this->get(SectionResolver::class)->getCurrent());
if ($sectionCurrent && $this->isInstanceOf(FilterSectionInterface::class)) {
$repositoryQuery->filterBySection($sectionCurrent);
}

return $repositoryQuery;

+ 1
- 1
Controller/ControllerTrait.php Wyświetl plik

@@ -149,7 +149,7 @@ trait ControllerTrait
return $this->get(MerchantResolver::class)->getMerchantUser($this->getUserCurrent());
}

public function getSectionCurrent(): SectionInterface
public function getSectionCurrent(): ?SectionInterface
{
return $this->get(SectionResolver::class)->getCurrent();
}

+ 9
- 3
Controller/Newsletter/NewsletterAdminController.php Wyświetl plik

@@ -3,10 +3,8 @@
namespace Lc\CaracoleBundle\Controller\Newsletter;

use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Resolver\SectionResolver;
use Lc\SovBundle\Container\Newsletter\NewsletterContainer;
use Lc\SovBundle\Controller\Newsletter\NewsletterAdminController as SovNewsletterAdminController;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

abstract class NewsletterAdminController extends SovNewsletterAdminController
{
@@ -16,7 +14,15 @@ abstract class NewsletterAdminController extends SovNewsletterAdminController
{
return $this->get(NewsletterContainer::class)
->getFactory()
->setSection($this->get(SectionResolver::class)->getCurrent())
->setSection($this->getSectionCurrent())
->create();
}

public function configureFields(string $pageName): iterable
{
return $this->getNewsletterContainer()->getFieldDefinition()
->setMerchant($this->getMerchantCurrent())
->setSection($this->getSectionCurrent())
->getFields($pageName);
}
}

+ 4
- 17
Controller/Product/ProductCategoryAdminController.php Wyświetl plik

@@ -28,23 +28,10 @@ abstract class ProductCategoryAdminController extends AbstractAdminController

public function configureFields(string $pageName): iterable
{
return array_merge(
[
FormField::addPanel('general'),
IntegerField::new('id')->onlyOnIndex()->setSortable(true),
TextField::new('title')->setSortable(true),
NumberField::new('position')->hideOnForm()->setSortable(true),
AssociationField::new('parent')->hideOnIndex(),
DateTimeField::new('createdAt')->setFormat('short')->setSortable(true),
CKEditorField::new('description')->hideOnIndex(),
StatusField::new('status')->setSortable(true),
ToggleField::new('saleStatus')->setSortable(true),
ToggleField::new('isEligibleTicketRestaurant')->setSortable(true),

],
$this->getSeoPanel(),
$this->getConfPanel()
);
return $this->getProductCategoryContainer()->getFieldDefinition()
->setMerchant($this->getMerchantCurrent())
->setSection($this->getSectionCurrent())
->getFields($pageName);
}

}

+ 22
- 11
Controller/Section/OpeningAdminController.php Wyświetl plik

@@ -3,6 +3,7 @@
namespace Lc\CaracoleBundle\Controller\Section;

use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStore;
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TimeField;
@@ -17,11 +18,27 @@ abstract class OpeningAdminController extends AbstractAdminController
{
use AdminControllerTrait;

public function createEntity(string $entityFqcn)
{
return $this->getOpeningContainer()
->getFactory()
->create($this->getSectionCurrent());
}

public function getRepositoryQuery() :RepositoryQueryInterface
{
return $this->get(OpeningContainer::class)->getRepositoryQuery();
}

public function configureCrud(Crud $crud): Crud
{
$crud = parent::configureCrud($crud);

$crud->setDefaultSort(['day' => 'ASC']);

return $crud;
}

public function configureFields(string $pageName): iterable
{
return [
@@ -48,19 +65,13 @@ abstract class OpeningAdminController extends AbstractAdminController
];
}

public function configureCrud(Crud $crud): Crud
public function configureResponseParameters(KeyValueStore $responseParameters): KeyValueStore
{
$crud = parent::configureCrud($crud);
$responseParameters = parent::configureResponseParameters($responseParameters);

$crud->setDefaultSort(['day' => 'ASC']);
$this->configureResponseParametersFilterSection($responseParameters);
$this->configureResponseParametersDisableShowAllSections($responseParameters);

return $crud;
}

public function createEntity(string $entityFqcn)
{
return $this->getOpeningContainer()
->getFactory()
->create($this->getSectionCurrent());
return $responseParameters;
}
}

+ 0
- 1
Controller/Section/SectionAdminController.php Wyświetl plik

@@ -17,7 +17,6 @@ use Lc\SovBundle\Repository\RepositoryQueryInterface;

abstract class SectionAdminController extends AbstractAdminController
{

public function getRepositoryQuery() :RepositoryQueryInterface
{
return $this->get(SectionContainer::class)->getRepositoryQuery();

+ 9
- 3
Controller/Section/SwitchSectionAdminController.php Wyświetl plik

@@ -27,13 +27,19 @@ class SwitchSectionAdminController extends AbstractController
$form->handleRequest($request);

if ($form->isSubmitted() && $form->isValid()) {

// valeur par défaut de $section : Tout afficher
$section = null;
$idSection = $form->get('id_section')->getData();
$section = $sectionContainer->getStore()->getOneById($idSection);
$userMerchant = $merchantResolver->getUserMerchant();

if ($section && $userMerchant) {
if($userMerchant) {
if($idSection) {
$section = $sectionContainer->getStore()->getOneById($idSection);
}

$userMerchant->setCurrentAdminSection($section);
$entityManager->update($section);
$entityManager->update($userMerchant);
$entityManager->flush();
}
}

+ 19
- 18
Controller/Setting/SettingAdminController.php Wyświetl plik

@@ -2,19 +2,11 @@

namespace Lc\CaracoleBundle\Controller\Setting;

use Lc\CaracoleBundle\Container\Setting\MerchantSettingContainer;
use Lc\CaracoleBundle\Container\Setting\SectionSettingContainer;
use Lc\CaracoleBundle\Controller\ControllerTrait;
use Lc\CaracoleBundle\Resolver\MerchantResolver;
use Lc\CaracoleBundle\Resolver\SectionResolver;
use Lc\SovBundle\Container\Setting\SiteSettingContainer;
use Lc\SovBundle\Container\Site\SiteContainer;
use Lc\SovBundle\Controller\Setting\SettingAdminController as SovSettingController;
use Doctrine\ORM\EntityManagerInterface;
use Lc\CaracoleBundle\Form\Setting\MerchantSettingsFormType;
use Lc\CaracoleBundle\Form\Setting\SectionSettingsFormType;
use Lc\SovBundle\Form\Setting\SiteSettingsFormType;
use Lc\SovBundle\Translation\TranslatorAdmin;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;

@@ -25,18 +17,16 @@ class SettingAdminController extends SovSettingController
/**
* @Route("/admin/setting/merchant", name="carac_admin_setting_merchant")
*/
public function manageMerchant(
Request $request
) {
public function manageMerchant(Request $request)
{
return $this->manage($request, 'merchant');
}

/**
* @Route("/admin/setting/section", name="carac_admin_setting_section")
*/
public function manageSection(
Request $request
) {
public function manageSection(Request $request)
{
return $this->manage($request, 'section');
}

@@ -58,6 +48,8 @@ class SettingAdminController extends SovSettingController
}

$entity = $resolver->getCurrent();
$displaySwitchSection = ($type == 'section') ? true : false;
$view = '@LcCaracole/admin/setting/edit_' . $type . '.html.twig';

if ($entity) {
$form = $this->createForm($formClass, $entity);
@@ -68,19 +60,28 @@ class SettingAdminController extends SovSettingController
$entityManager->update($entity);
$entityManager->flush();

$this->addFlashTranslator('success','updated');
$this->addFlashTranslator('success', 'updated');
}

return $this->render(
'@LcCaracole/admin/setting/edit_' . $type . '.html.twig',
$view,
[
'display_switch_section' => ($type == 'section') ? true : false,
'display_switch_section' => $displaySwitchSection,
'resolver' => $resolver,
'setting_definition' => $settingDefinition,
'form' => $form->createView()
]
);
}
else {
return $this->render(
$view,
[
'display_switch_section' => $displaySwitchSection,
'replace_content_with_message' => "Vous devez sélectionner une section pour afficher ces données."
]
);
}
}

/**
@@ -98,7 +99,7 @@ class SettingAdminController extends SovSettingController
$entityManager->update($site);
$entityManager->flush();

$this->addFlashTranslator('success','updated');
$this->addFlashTranslator('success', 'updated');
}

return $this->render(

+ 2
- 2
Controller/Site/NewsAdminController.php Wyświetl plik

@@ -2,12 +2,12 @@

namespace Lc\CaracoleBundle\Controller\Site;

use Lc\CaracoleBundle\Controller\ControllerTrait;
use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\SovBundle\Controller\Site\NewsAdminController as SovNewsAdminController;

abstract class NewsAdminController extends SovNewsAdminController
{
use ControllerTrait;
use AdminControllerTrait;

public function createEntity(string $entityFqcn)
{

+ 3
- 3
Controller/Site/PageAdminController.php Wyświetl plik

@@ -2,18 +2,18 @@

namespace Lc\CaracoleBundle\Controller\Site;

use Lc\CaracoleBundle\Controller\ControllerTrait;
use Lc\CaracoleBundle\Resolver\SectionResolver;
use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\SovBundle\Controller\Site\PageAdminController as SovPageAdminController;

abstract class PageAdminController extends SovPageAdminController
{
use ControllerTrait;
use AdminControllerTrait;

public function createEntity(string $entityFqcn)
{
return $this->getPageContainer()
->getFactory()
->setMerchant($this->getMerchantCurrent())
->setSection($this->getSectionCurrent())
->create();
}

+ 10
- 0
Definition/Field/AbstractFieldDefinition.php Wyświetl plik

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

namespace Lc\CaracoleBundle\Definition\Field;

use Lc\SovBundle\Definition\Field\AbstractFieldDefinition as SovAbstractFieldDefinition;

abstract class AbstractFieldDefinition extends SovAbstractFieldDefinition
{
use FieldDefinitionTrait;
}

+ 46
- 0
Definition/Field/FieldDefinitionTrait.php Wyświetl plik

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

namespace Lc\CaracoleBundle\Definition\Field;

use Lc\CaracoleBundle\Context\MerchantContextTrait;
use Lc\CaracoleBundle\Context\SectionContextTrait;
use Lc\CaracoleBundle\Field\AssociationField;
use Lc\CaracoleBundle\Model\Section\SectionInterface;

trait FieldDefinitionTrait
{
use MerchantContextTrait;
use SectionContextTrait;

public function configureFieldsBase(): array
{
$sectionArray = $this->sectionStore->setMerchant($this->merchant)->get();

return array_merge(parent::configureFieldsBase(), [
'section' => AssociationField::new('section')
->setTemplatePath('@LcCaracole/admin/section/field/section.html.twig')
->setFormTypeOption('choices', $sectionArray)
]);
}

public function addSectionToFieldArrayIfOutOfSection(?SectionInterface $sectionCurrent, array $fieldArray)
{
$asObject = true;
if(is_string($fieldArray[array_key_first($fieldArray)])) {
$asObject = false;
}

$fieldSectionArray = [];
if($sectionCurrent == null) {
if($asObject) {
$allFieldArray = $this->getAllFields();
$fieldSectionArray = [$allFieldArray['section']];
}
else {
$fieldSectionArray = ['section'];
}
}

return array_merge($fieldSectionArray, $fieldArray);
}
}

+ 36
- 0
Definition/Field/Newsletter/NewsletterFieldDefinition.php Wyświetl plik

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

namespace Lc\CaracoleBundle\Definition\Field\Newsletter;

use Lc\CaracoleBundle\Definition\Field\FieldDefinitionTrait;
use Lc\CaracoleBundle\Repository\Section\SectionStore;
use Lc\SovBundle\Definition\Field\Newsletter\NewsletterFieldDefinition as SovNewsletterFieldDefinition;
use Lc\SovBundle\Translation\TranslatorAdmin;

class NewsletterFieldDefinition extends SovNewsletterFieldDefinition
{
use FieldDefinitionTrait;

protected SectionStore $sectionStore;

public function __construct(TranslatorAdmin $translatorAdmin, SectionStore $sectionStore)
{
parent::__construct($translatorAdmin);
$this->sectionStore = $sectionStore;
}

public function configureIndex(): array
{
return $this->addSectionToFieldArrayIfOutOfSection($this->section, [
'id',
'title',
'isMain',
'status'
]);
}

public function configurePanelMain(): array
{
return array_merge(['section'], parent::configurePanelMain());
}
}

+ 11
- 1
Definition/Field/Order/OrderShopFieldDefinition.php Wyświetl plik

@@ -9,14 +9,24 @@ use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextareaField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\CaracoleBundle\Context\MerchantContextTrait;
use Lc\CaracoleBundle\Definition\Field\AbstractFieldDefinition;
use Lc\CaracoleBundle\Field\AssociationField;
use Lc\SovBundle\Definition\Field\AbstractFieldDefinition;
use Lc\CaracoleBundle\Repository\Section\SectionStore;
use Lc\SovBundle\Translation\TranslatorAdmin;
use Symfony\Component\Form\Extension\Core\Type\TextType;

class OrderShopFieldDefinition extends AbstractFieldDefinition
{
use MerchantContextTrait;

protected SectionStore $sectionStore;

public function __construct(TranslatorAdmin $translatorAdmin, SectionStore $sectionStore)
{
parent::__construct($translatorAdmin);
$this->sectionStore = $sectionStore;
}

public function configureFieldsIndex(): array
{
return ['id'];

+ 79
- 0
Definition/Field/Product/ProductCategoryFieldDefinition.php Wyświetl plik

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

namespace Lc\CaracoleBundle\Definition\Field\Product;

use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\CaracoleBundle\Definition\Field\AbstractFieldDefinition;
use Lc\CaracoleBundle\Repository\Product\ProductCategoryStore;
use Lc\CaracoleBundle\Repository\Section\SectionStore;
use Lc\SovBundle\Field\CKEditorField;
use Lc\SovBundle\Field\ToggleField;
use Lc\SovBundle\Translation\TranslatorAdmin;

class ProductCategoryFieldDefinition extends AbstractFieldDefinition
{
protected SectionStore $sectionStore;
protected ProductCategoryStore $productCategoryStore;

public function __construct(
TranslatorAdmin $translatorAdmin,
SectionStore $sectionStore,
ProductCategoryStore $productCategoryStore
) {
parent::__construct($translatorAdmin);
$this->sectionStore = $sectionStore;
$this->productCategoryStore = $productCategoryStore;
}

public function configureIndex(): array
{
$fieldArray = ($this->section == null) ? ['section'] : [];

return array_merge($fieldArray, [
'id',
'title',
'status'
]);
}

public function configurePanels(): array
{
return [
'main',
'seo',
'conf'
];
}

public function configurePanelMain()
{
return [
'section',
'title',
'parent',
'description',
'isEligibleTicketRestaurant',
'saleStatus',
'status',
];
}

public function configureFields(): array
{
$productCategoryArray = $this->productCategoryStore
->setSection($this->section)
->getParents();

return [
'title' => TextField::new('title')->setSortable(true),
'position' => NumberField::new('position')->setSortable(true),
'parent' => AssociationField::new('parent')
->setFormTypeOption('choices', $productCategoryArray),
'description' => CKEditorField::new('description'),
'saleStatus' => ToggleField::new('saleStatus')->setSortable(true),
'isEligibleTicketRestaurant' => ToggleField::new('isEligibleTicketRestaurant')->setSortable(true),
];
}
}

+ 27
- 0
Definition/Field/Reduction/ReductionCartFieldDefinition.php Wyświetl plik

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

namespace Lc\CaracoleBundle\Definition\Field\Reduction;

use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\CaracoleBundle\Definition\Field\AbstractFieldDefinition;
use Lc\CaracoleBundle\Repository\Section\SectionStore;
use Lc\SovBundle\Translation\TranslatorAdmin;

class ReductionCartFieldDefinition extends AbstractFieldDefinition
{
protected SectionStore $sectionStore;

public function __construct(TranslatorAdmin $translatorAdmin, SectionStore $sectionStore)
{
parent::__construct($translatorAdmin);
$this->sectionStore = $sectionStore;
}

public function configureFields(): array
{
return [
'title' => TextField::new('title')->setSortable(true)
// @TODO : à faire
];
}
}

+ 27
- 0
Definition/Field/Reduction/ReductionCatalogFieldDefinition.php Wyświetl plik

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

namespace Lc\CaracoleBundle\Definition\Field\Reduction;

use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\CaracoleBundle\Definition\Field\AbstractFieldDefinition;
use Lc\CaracoleBundle\Repository\Section\SectionStore;
use Lc\SovBundle\Translation\TranslatorAdmin;

class ReductionCatalogFieldDefinition extends AbstractFieldDefinition
{
protected SectionStore $sectionStore;

public function __construct(TranslatorAdmin $translatorAdmin, SectionStore $sectionStore)
{
parent::__construct($translatorAdmin);
$this->sectionStore = $sectionStore;
}

public function configureFields(): array
{
return [
'title' => TextField::new('title')->setSortable(true)
// @TODO : à faire
];
}
}

+ 31
- 0
Definition/Field/Site/NewsFieldDefinition.php Wyświetl plik

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

namespace Lc\CaracoleBundle\Definition\Field\Site;

use Lc\CaracoleBundle\Definition\Field\FieldDefinitionTrait;
use Lc\CaracoleBundle\Repository\Section\SectionStore;
use Lc\SovBundle\Definition\Field\Site\NewsFieldDefinition as SovNewsFieldDefinition;
use Lc\SovBundle\Translation\TranslatorAdmin;

class NewsFieldDefinition extends SovNewsFieldDefinition
{
use FieldDefinitionTrait;

protected SectionStore $sectionStore;

public function __construct(TranslatorAdmin $translatorAdmin, SectionStore $sectionStore)
{
parent::__construct($translatorAdmin);
$this->sectionStore = $sectionStore;
}

public function configureIndex(): array
{
return $this->addSectionToFieldArrayIfOutOfSection($this->section, parent::configureIndex());
}

public function configurePanelMain(): array
{
return array_merge(['section'], parent::configurePanelMain());
}
}

+ 30
- 0
Definition/Field/Site/PageFieldDefinition.php Wyświetl plik

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

namespace Lc\CaracoleBundle\Definition\Field\Site;

use Lc\CaracoleBundle\Definition\Field\FieldDefinitionTrait;
use Lc\CaracoleBundle\Repository\Section\SectionStore;
use Lc\SovBundle\Definition\Field\Site\PageFieldDefinition as SovPageFieldDefinition;
use Lc\SovBundle\Translation\TranslatorAdmin;

class PageFieldDefinition extends SovPageFieldDefinition
{
use FieldDefinitionTrait;

protected SectionStore $sectionStore;

public function __construct(TranslatorAdmin $translatorAdmin, SectionStore $sectionStore)
{
parent::__construct($translatorAdmin);
$this->sectionStore = $sectionStore;
}

public function configureIndex(): array
{
return [
'id',
'title',
'status'
];
}
}

+ 2
- 0
Factory/Site/PageFactory.php Wyświetl plik

@@ -10,12 +10,14 @@ use Lc\SovBundle\Model\Site\PageInterface;

class PageFactory extends SovPageFactory
{
use MerchantContextTrait;
use SectionContextTrait;

public function create(): PageInterface
{
$page = parent::create();

$page->setMerchant($this->merchant);
$page->setSection($this->section);

return $page;

+ 10
- 7
Form/Section/SwitchSectionFormType.php Wyświetl plik

@@ -6,6 +6,7 @@ use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Repository\Section\SectionRepository;
use Lc\CaracoleBundle\Resolver\MerchantResolver;
use Lc\CaracoleBundle\Resolver\SectionResolver;
use Lc\CaracoleBundle\Solver\Section\SectionSolver;
use Lc\SovBundle\Doctrine\EntityManager;
use Lc\SovBundle\Model\User\UserInterface;
use Lc\SovBundle\Translation\TranslatorAdmin;
@@ -19,18 +20,21 @@ use Symfony\Component\OptionsResolver\OptionsResolver;

class SwitchSectionFormType extends AbstractType
{
protected $em;
protected $translatorAdmin;
protected $sectionResolver;
protected EntityManager $em;
protected TranslatorAdmin $translatorAdmin;
protected SectionResolver $sectionResolver;
protected SectionSolver $sectionSolver;

public function __construct(
EntityManager $em,
TranslatorAdmin $translatorAdmin,
SectionResolver $sectionResolver
SectionResolver $sectionResolver,
SectionSolver $sectionSolver
) {
$this->em = $em;
$this->translatorAdmin = $translatorAdmin;
$this->sectionResolver = $sectionResolver;
$this->sectionSolver = $sectionSolver;
}

public function buildForm(FormBuilderInterface $builder, array $options)
@@ -49,15 +53,14 @@ class SwitchSectionFormType extends AbstractType
$styleButton = '';
$classButton = 'btn-section';
if ($section == $currentSection) {
$classButton .= ' btn-section-current section-'.$currentSection->getDevAlias();
//$styleButton = 'color: white; background-color: ' . $currentSection->getColor() . ';';
$classButton .= ' btn-section-current '.$this->sectionSolver->getHtmlClass($currentSection);
}

$builder->add(
'submit',
SubmitType::class,
[
'label' => $section ? $section->getTitle() : '',
'label' => $section ? $section->getTitle() : 'Tout afficher',
'attr' => [
'class' => $classButton,
'style' => $styleButton,

+ 2
- 1
Model/Site/PageModel.php Wyświetl plik

@@ -3,6 +3,7 @@
namespace Lc\CaracoleBundle\Model\Site;

use Doctrine\ORM\Mapping as ORM;
use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface;
use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
@@ -11,7 +12,7 @@ use Lc\SovBundle\Model\Site\PageModel as SovPageModel;
/**
* @ORM\MappedSuperclass()
*/
abstract class PageModel extends SovPageModel implements FilterSectionInterface
abstract class PageModel extends SovPageModel implements FilterMerchantInterface, FilterSectionInterface
{
/**
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface")

+ 2
- 1
Repository/Product/ProductStore.php Wyświetl plik

@@ -24,8 +24,9 @@ class ProductStore extends AbstractStore

public function filtersDefault($query):RepositoryQueryInterface
{
$this->addFilterBySectionOptionnal($query);
$query->filterIsOnlineAndOffline();
$query->filterBySection($this->section);
return $query;
}


+ 1
- 1
Repository/Ticket/TicketStore.php Wyświetl plik

@@ -14,7 +14,7 @@ class TicketStore extends SovTicketStore

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->filterBySection($this->section);
$this->addFilterBySectionOptionnal($query);
return $query;
}


+ 1
- 1
Repository/User/UserStore.php Wyświetl plik

@@ -14,7 +14,7 @@ class UserStore extends SovUserStore

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$this->addFilterByMerchantOptionnal($this->merchant);
$this->addFilterByMerchantOptionnal($query);

return $query;
}

+ 12
- 3
Resolver/SectionResolver.php Wyświetl plik

@@ -15,6 +15,7 @@ use Symfony\Component\Security\Core\Security;

class SectionResolver
{
protected bool $isCachedSection = false;
protected ?SectionInterface $section = null;

protected EntityManagerInterface $entityManager;
@@ -44,7 +45,7 @@ class SectionResolver

// admin
if (isset($requestAttributesArray['easyadmin_context'])) {
if ($this->section === null) {
if (!$this->isCachedSection) {
$currentAdminSection = null;
$userMerchant = $this->merchantResolver->getUserMerchant();

@@ -52,7 +53,7 @@ class SectionResolver
$currentAdminSection = $userMerchant->getCurrentAdminSection();
}

if ($currentAdminSection === null) {
/*if ($currentAdminSection === null) {
$currentAdminSection = $this->sectionStore
->setMerchant($userMerchant->getMerchant())
->getOneDefault();
@@ -60,8 +61,11 @@ class SectionResolver
if ($currentAdminSection === null) {
throw new \ErrorException('Aucune section par défaut définie pour ce merchant');
}
}
}*/

$this->isCachedSection = true;
$this->section = $currentAdminSection;

return $currentAdminSection;
}else{
return $this->section;
@@ -87,6 +91,11 @@ class SectionResolver
}
}

public function isOutOfSection(): bool
{
return $this->getCurrent() == null;
}

public function getDefault(): SectionInterface
{
return $this->sectionStore->setMerchant($this->merchantResolver->getCurrent())->getOneDefault();

+ 2
- 0
Resources/translations/admin.fr.yaml Wyświetl plik

@@ -64,6 +64,7 @@ entity:
taxRate: Règle de taxe
merchants: Marchands
sections: Sections
section: Section
behaviorTaxRate: Avec ou sans TVA
behaviorTaxRateChoices:
tax-excluded: TVA exclue
@@ -185,6 +186,7 @@ entity:
priceWithTax: Prix de vente
sales: Historique des ventes
propertyQualityLabelActive: Marquer le produit comme labellisé
productFamilySectionProperties: Sections

QualityLabel:
label: Label de qualité

+ 3
- 1
Resources/views/admin/product/field/product_family_sales.html.twig Wyświetl plik

@@ -2,4 +2,6 @@

{% import '@LcCaracole/admin/product/macro/product_family_macro.html.twig' as pfm %}
{% set section_current = section_container.resolver.getCurrent() %}
{{ pfm.product_family_sales_statistic(order_shop_container.builder.getProductsSalesStatistic(section_current, entity.instance, 2), entity.instance) }}
{% if section_current %}
{{ pfm.product_family_sales_statistic(order_shop_container.builder.getProductsSalesStatistic(section_current, entity.instance, 2), entity.instance) }}
{% endif %}

+ 7
- 0
Resources/views/admin/product/field/product_family_section_properties.html.twig Wyświetl plik

@@ -0,0 +1,7 @@
{% import '@LcCaracole/admin/section/macros.html.twig' as macros_section %}
{% set item = entity.instance %}
{% for section_property in item.productFamilySectionProperties %}
{{ macros_section.section_badge(section_property.section) }}
{% else %}
<span class="badge badge-secondary">Aucune</span>
{% endfor %}

+ 7
- 0
Resources/views/admin/section/field/section.html.twig Wyświetl plik

@@ -0,0 +1,7 @@
{% import '@LcCaracole/admin/section/macros.html.twig' as macros_section %}
{% set item = entity.instance %}
{% if item.section %}
{{ macros_section.section_badge(item.section) }}
{% else %}
<span class="badge badge-secondary">Aucune</span>
{% endif %}

+ 7
- 0
Resources/views/admin/section/field/sections.html.twig Wyświetl plik

@@ -0,0 +1,7 @@
{% import '@LcCaracole/admin/section/macros.html.twig' as macros_section %}
{% set item = entity.instance %}
{% for section in item.sections %}
{{ macros_section.section_badge(section) }}
{% else %}
<span class="badge badge-secondary">Aucune</span>
{% endfor %}

+ 4
- 0
Resources/views/admin/section/macros.html.twig Wyświetl plik

@@ -0,0 +1,4 @@

{% macro section_badge(section) %}
<span class="badge badge-secondary {{ section_container.solver.getHtmlClass(section) }}">{{ section.title }}</span>
{% endmacro %}

+ 2
- 2
Resources/views/admin/setting/edit_section.html.twig Wyświetl plik

@@ -1,8 +1,8 @@
{% extends '@LcCaracole/adminlte/layout.html.twig' %}

{% block content_title %}
{% set current_section = resolver.getCurrent() %}
Paramètres section &gt; {{ current_section.title }}
{% if resolver is defined %}{% set current_section = resolver.getCurrent() %}{% endif %}
Paramètres section{% if current_section is defined and current_section %} &gt; {{ current_section.title }}{% endif %}
{% endblock %}

{% block main %}

+ 14
- 8
Resources/views/adminlte/layout.html.twig Wyświetl plik

@@ -6,17 +6,16 @@
{% set section_current = section_current() %}
{% set is_display_switch_section = display_switch_section is defined and display_switch_section %}

<nav class="carac navbar navbar-expand navbar-light main-header{% if is_display_switch_section %} display-section-switch section-{{ section_current.devAlias }}{% endif %}">
<nav class="carac navbar navbar-expand navbar-light main-header{% if is_display_switch_section %} display-section-switch {{ section_container.solver.getHtmlClass(section_current()) }}{% endif %}">

{% if is_display_switch_section %}
<ul class="navbar-nav left">
<li class="nav-item d-none d-sm-inline-block">
{{ _self.form_switch_section(null) }}
</li>
{% for section in carac_sections() %}
<li class="nav-item d-none d-sm-inline-block">
{% set form_switch_section = carac_form_switch_section(section) %}
{% form_theme form_switch_section '@LcSov/adminlte/crud/form_theme.html.twig' %}
{{ form_start(form_switch_section) }}
{{ form(form_switch_section) }}
{{ form_end(form_switch_section) }}
{{ _self.form_switch_section(section) }}
</li>
{% endfor %}
</ul>
@@ -39,7 +38,6 @@
{% include '@LcSov/admin/reminder/block.html.twig' %}
{% endblock %}


{% block append_body %}
{# modal switch merchant #}
{% set user = app.user %}
@@ -49,4 +47,12 @@
{# modal affichée uniquement si la sessionStorage.visit_merchant n'est pas défini (js) #}
{% include '@LcCaracole/admin/merchant/modal/switch_merchant.html.twig' %}
{% endif %}
{% endblock %}
{% endblock %}

{% macro form_switch_section(section) %}
{% set form_switch_section = carac_form_switch_section(section) %}
{% form_theme form_switch_section '@LcSov/adminlte/crud/form_theme.html.twig' %}
{{ form_start(form_switch_section) }}
{{ form(form_switch_section) }}
{{ form_end(form_switch_section) }}
{% endmacro %}

+ 6
- 0
Solver/Section/SectionSolver.php Wyświetl plik

@@ -7,5 +7,11 @@ use Lc\CaracoleBundle\Model\Section\SectionModel;

class SectionSolver
{
public function getHtmlClass(?SectionInterface $section): string
{
$htmlClass = 'section-';
$htmlClass .= $section ? $section->getDevAlias() : 'all';

return $htmlClass;
}
}

+ 1
- 1
Twig/StoreTwigExtension.php Wyświetl plik

@@ -106,7 +106,7 @@ class StoreTwigExtension extends AbstractExtension
return $this->merchantStore->getOnline();
}

public function getSectionCurrent(): SectionInterface
public function getSectionCurrent(): ?SectionInterface
{
return $this->sectionResolver->getCurrent();
}

Ładowanie…
Anuluj
Zapisz