Browse Source

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

packProduct
Charly 2 years ago
parent
commit
79e75f34fe
5 changed files with 67 additions and 13 deletions
  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 View File

use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface; use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\CaracoleBundle\Repository\Product\ProductFamilySectionPropertyStore; use Lc\CaracoleBundle\Repository\Product\ProductFamilySectionPropertyStore;
use Lc\CaracoleBundle\Solver\Product\ProductFamilySectionPropertySolver;


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


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


public function enable(ProductFamilyInterface $productFamily, SectionInterface $section, bool $flush = true): void 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) {
if (!$productFamilySectionProperty->getStatus()) { if (!$productFamilySectionProperty->getStatus()) {
} else { } else {
$productFamilySectionProperty = $this->productFamilySectionPropertyFactory->create($section, $productFamily); $productFamilySectionProperty = $this->productFamilySectionPropertyFactory->create($section, $productFamily);
$productFamilySectionProperty->setStatus(1); $productFamilySectionProperty->setStatus(1);
$productFamily->addProductFamilySectionProperty($productFamilySectionProperty);
$this->entityManager->create($productFamilySectionProperty); $this->entityManager->create($productFamilySectionProperty);
$this->entityManager->update($productFamily);
} }


if($flush) { if($flush) {

+ 48
- 0
Controller/Merchant/FavoriteMerchantAdminController.php View File

<?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 View File

use Lc\CaracoleBundle\Doctrine\Extension\ReductionPropertyTrait; use Lc\CaracoleBundle\Doctrine\Extension\ReductionPropertyTrait;
use Lc\CaracoleBundle\Doctrine\Extension\ReductionTrait; use Lc\CaracoleBundle\Doctrine\Extension\ReductionTrait;
use Lc\CaracoleBundle\Doctrine\Extension\ReductionPropertyInterface; use Lc\CaracoleBundle\Doctrine\Extension\ReductionPropertyInterface;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\Product\ProductCategoryInterface; use Lc\CaracoleBundle\Model\Product\ProductCategoryInterface;
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
use Lc\CaracoleBundle\Model\Product\ProductFamilyModel; use Lc\CaracoleBundle\Model\Product\ProductFamilyModel;
return $this; return $this;
} }



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


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



+ 1
- 1
Resources/assets/app/admin/switchmerchant/switchmerchant.js View File

}) ; }) ;


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

+ 8
- 3
Resources/views/admin/merchant/modal/switch_merchant.html.twig View File

comme marchand favoris ou simplement indiquer que vous visitez ce marchand pour aujourd'hui.</p> comme marchand favoris ou simplement indiquer que vous visitez ce marchand pour aujourd'hui.</p>
{% endblock %} {% endblock %}
{% block footer %} {% 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_theme form_switch_merchant '@LcSov/adminlte/crud/form_theme.html.twig' %}
{{ form_start(form_switch_merchant) }} {{ 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) }} {{ form_end(form_switch_merchant) }}
<button id="carac-button-visit-merchant" type="button" class="btn btn-default" <button id="carac-button-visit-merchant" type="button" class="btn btn-default"
data-dismiss="modal">Visiter</button>
data-dismiss="modal">Visiter
</button>
{% endblock %} {% endblock %}
{% endembed %} {% endembed %}

Loading…
Cancel
Save