Explorar el Código

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

packProduct
Charly hace 3 años
padre
commit
79e75f34fe
Se han modificado 5 ficheros con 67 adiciones y 13 borrados
  1. +7
    -6
      Builder/Product/ProductFamilySectionPropertyBuilder.php
  2. +48
    -0
      Controller/Merchant/FavoriteMerchantAdminController.php
  3. +3
    -3
      Model/Reduction/ReductionCatalogModel.php
  4. +1
    -1
      Resources/assets/app/admin/switchmerchant/switchmerchant.js
  5. +8
    -3
      Resources/views/admin/merchant/modal/switch_merchant.html.twig

+ 7
- 6
Builder/Product/ProductFamilySectionPropertyBuilder.php Ver fichero

@@ -7,28 +7,27 @@ use Lc\CaracoleBundle\Factory\Product\ProductFamilySectionPropertyFactory;
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\CaracoleBundle\Repository\Product\ProductFamilySectionPropertyStore;
use Lc\CaracoleBundle\Solver\Product\ProductFamilySectionPropertySolver;

class ProductFamilySectionPropertyBuilder
{
protected EntityManagerInterface $entityManager;
protected ProductFamilySectionPropertyFactory $productFamilySectionPropertyFactory;
protected ProductFamilySectionPropertyStore $productFamilySectionPropertyStore;
protected ProductFamilySectionPropertySolver $productFamilySectionPropertySolver;

public function __construct(
EntityManagerInterface $entityManager,
ProductFamilySectionPropertyFactory $productFamilySectionPropertyFactory,
ProductFamilySectionPropertyStore $productFamilySectionPropertyStore
ProductFamilySectionPropertySolver $productFamilySectionPropertySolver
) {
$this->entityManager = $entityManager;
$this->productFamilySectionPropertyFactory = $productFamilySectionPropertyFactory;
$this->productFamilySectionPropertyStore = $productFamilySectionPropertyStore;
$this->productFamilySectionPropertySolver = $productFamilySectionPropertySolver;
}

public function enable(ProductFamilyInterface $productFamily, SectionInterface $section, bool $flush = true): void
{
$productFamilySectionProperty = $this->productFamilySectionPropertyStore
->setSection($section)
->getOneByProductFamily($productFamily);
$productFamilySectionProperty = $this->productFamilySectionPropertySolver->getProductFamilySectionProperty($productFamily, $section);

if ($productFamilySectionProperty) {
if (!$productFamilySectionProperty->getStatus()) {
@@ -38,7 +37,9 @@ class ProductFamilySectionPropertyBuilder
} else {
$productFamilySectionProperty = $this->productFamilySectionPropertyFactory->create($section, $productFamily);
$productFamilySectionProperty->setStatus(1);
$productFamily->addProductFamilySectionProperty($productFamilySectionProperty);
$this->entityManager->create($productFamilySectionProperty);
$this->entityManager->update($productFamily);
}

if($flush) {

+ 48
- 0
Controller/Merchant/FavoriteMerchantAdminController.php Ver fichero

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

namespace Lc\CaracoleBundle\Controller\Merchant;

use Doctrine\ORM\EntityManagerInterface;
use Lc\CaracoleBundle\Container\Merchant\MerchantContainer;
use Lc\CaracoleBundle\Controller\AbstractController;
use Lc\CaracoleBundle\Definition\MerchantSettingDefinition;
use Lc\CaracoleBundle\Form\Merchant\SwitchMerchantFormType;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Routing\Annotation\Route;

class FavoriteMerchantAdminController extends AbstractController
{
/**
* @Route("/admin/merchant/favorite", name="carac_merchant_favorite_admin")
*/
public function favoriteMerchant(Request $request, Security $security, EntityManagerInterface $entityManager)
{
$form = $this->createForm(SwitchMerchantFormType::class);
$form->handleRequest($request);

if ($form->isSubmitted() && $form->isValid()) {
$merchant = $form->get('merchant')->getData();

if ($merchant) {

$user = $security->getUser();
if($user) {
$user->setFavoriteMerchant($merchant);
$entityManager->update($user);
$entityManager->flush();
}

// @TODO : à fignoler, hein gamin ?
$url = $this->getSettingSolver()->getSettingValue(
$merchant,
MerchantSettingDefinition::SETTING_URL
) . 'admin';

if ($url) {
return $this->redirect($url);
}
}
}
}
}

+ 3
- 3
Model/Reduction/ReductionCatalogModel.php Ver fichero

@@ -9,6 +9,7 @@ use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface;
use Lc\CaracoleBundle\Doctrine\Extension\ReductionPropertyTrait;
use Lc\CaracoleBundle\Doctrine\Extension\ReductionTrait;
use Lc\CaracoleBundle\Doctrine\Extension\ReductionPropertyInterface;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\Product\ProductCategoryInterface;
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
use Lc\CaracoleBundle\Model\Product\ProductFamilyModel;
@@ -113,13 +114,12 @@ abstract class ReductionCatalogModel extends AbstractLightEntity implements Redu
return $this;
}


public function getProductFamily(): ?ProductFamilyModel
public function getProductFamily(): ?ProductFamilyInterface
{
return $this->productFamily;
}

public function setProductFamily(?ProductFamilyModel $productFamily): self
public function setProductFamily(?ProductFamilyInterface $productFamily): self
{
$this->productFamily = $productFamily;


+ 1
- 1
Resources/assets/app/admin/switchmerchant/switchmerchant.js Ver fichero

@@ -4,7 +4,7 @@ $(document).ready(function() {
}) ;

function initSwitchMerchant() {
let $form = $('form.switch-merchant') ;
let $form = $('.nav-switch-merchant form.switch-merchant') ;
$form.find('select').change(function() {
$form.submit() ;
}) ;

+ 8
- 3
Resources/views/admin/merchant/modal/switch_merchant.html.twig Ver fichero

@@ -15,12 +15,17 @@
comme marchand favoris ou simplement indiquer que vous visitez ce marchand pour aujourd'hui.</p>
{% endblock %}
{% block footer %}
{% set form_switch_merchant = carac_form_switch_merchant('admin', 'carac_merchant_favorite') %}
{% set form_switch_merchant = carac_form_switch_merchant('admin', 'carac_merchant_favorite_admin') %}
{% form_theme form_switch_merchant '@LcSov/adminlte/crud/form_theme.html.twig' %}
{{ form_start(form_switch_merchant) }}
{{ form(form_switch_merchant) }}
<div class="hidden">
{{ form_widget(form_switch_merchant.merchant, {attr:{'class': 'disable-select2'}}) }}
</div>
{{ form_rest(form_switch_merchant) }}

{{ form_end(form_switch_merchant) }}
<button id="carac-button-visit-merchant" type="button" class="btn btn-default"
data-dismiss="modal">Visiter</button>
data-dismiss="modal">Visiter
</button>
{% endblock %}
{% endembed %}

Cargando…
Cancelar
Guardar