Browse Source

Correctif backoffice

master
Fab 4 years ago
parent
commit
62f1c70256
5 changed files with 80 additions and 16 deletions
  1. +1
    -2
      ShopBundle/Controller/Backend/AdminController.php
  2. +1
    -8
      ShopBundle/Controller/Backend/MerchantController.php
  3. +47
    -0
      ShopBundle/EventSubscriber/InitializeEventSubscriber.php
  4. +4
    -0
      ShopBundle/Resources/public/js/backend/script/default/init-common.js
  5. +27
    -6
      ShopBundle/Resources/views/backend/default/block/flash_messages.html.twig

+ 1
- 2
ShopBundle/Controller/Backend/AdminController.php View File

@@ -636,8 +636,7 @@ class AdminController extends EasyAdminController
$this->em->persist($newEntity) ;
$this->em->flush() ;

$this->utils->addFlash('warning', "Vous êtes maintenant sur le hub de ".$hub->getTitle());
$redirectUrl = $hub->getMerchantConfig('url').substr($this->generateUrl('easyadmin', ['entity' => $easyadmin['entity']['name'], 'action' => 'edit', 'id' =>$newEntity->getId(), 'referer' =>$refererUrl ]),1);
$redirectUrl = $hub->getMerchantConfig('url').substr($this->generateUrl('easyadmin', ['entity' => $easyadmin['entity']['name'], 'action' => 'edit', 'id' =>$newEntity->getId(), 'referer' =>$refererUrl ]),1).'&hubredirection=true';

return $this->redirect($redirectUrl) ;
}

+ 1
- 8
ShopBundle/Controller/Backend/MerchantController.php View File

@@ -96,18 +96,11 @@ class MerchantController extends AdminController
->find($idMerchant);

if ($merchant) {
dump($merchant);
dump('NICHE');
$user->setMerchant($merchant);
$em->persist($user);
$em->flush();


$this->utils->addFlash('warning', "Vous êtes maintenant sur le hub de ".$idMerchant);



return $this->redirect($merchant->getMerchantConfig('url').'admin/dashboard') ;
return $this->redirect($merchant->getMerchantConfig('url').'admin/dashboard?hubredirection=true') ;
}
}


+ 47
- 0
ShopBundle/EventSubscriber/InitializeEventSubscriber.php View File

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

namespace Lc\ShopBundle\EventSubscriber;

use Lc\ShopBundle\Context\FilterMerchantInterface;
use Lc\ShopBundle\Context\FilterMultipleMerchantsInterface;
use Lc\ShopBundle\Context\MerchantUtilsInterface;
use Lc\ShopBundle\Context\SortableInterface;
use Lc\ShopBundle\Context\StatusInterface;
use Lc\ShopBundle\Context\TreeInterface;
use Lc\ShopBundle\Services\Utils;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\EventDispatcher\GenericEvent;


class InitializeEventSubscriber implements EventSubscriberInterface
{
public $merchantUtils;
public $utils;

public function __construct(MerchantUtilsInterface $merchantUtils, Utils $utils)
{
$this->merchantUtils = $merchantUtils;
$this->utils = $utils;
}

public static function getSubscribedEvents()
{
return array(
'easy_admin.post_initialize' => array('initialize'),
'easy_admin.post_update' => array('updateCommonProperty'),
);
}


public function initialize(GenericEvent $event)
{
$request = $event->getArgument('request');

if($request->query->get('hubredirection')){
$this->utils->addFlash('alert', "Vous êtes maintenant sur le hub de ".$this->merchantUtils->getMerchantCurrent()->getTitle());

}
}


}

+ 4
- 0
ShopBundle/Resources/public/js/backend/script/default/init-common.js View File

@@ -18,6 +18,10 @@ function initNotice() {
$('#lc-flash-messages .notice').each(function (i, notice) {
generateNotice($(notice).find('.type').html(), $(notice).find('.message').html());
});

$('#lc-flash-alert .modal').each(function (i, modal) {
$(modal).modal('show');
});
}

function initButtonConfirm() {

+ 27
- 6
ShopBundle/Resources/views/backend/default/block/flash_messages.html.twig View File

@@ -1,15 +1,36 @@
{% if app.session is not null and app.session.started %}
{% set _flash_messages = app.session.flashbag.all %}
{% if _flash_messages['alert'] is defined and _flash_messages['alert']|length > 0 %}
<div id="lc-flash-alert">
{% for alert in _flash_messages['alert'] %}

<div class="modal fade">
<div class="modal-dialog">
<div class="modal-content bg-danger">
<div class="modal-header">
<h4 class="modal-title">{{ alert|trans|striptags }}</h4>
</div>
<div class="modal-footer align-right">
<button type="button" data-dismiss="modal" class="btn btn-outline-light">OK</button>
</div>
</div>
</div>
</div>
{% endfor %}
</div>

{% endif %}
{% if _flash_messages|length > 0 %}
<div id="lc-flash-messages">
{% for label, messages in _flash_messages %}
{% for message in messages %}
<div class="notice">
<span class="type">{{ label }}</span>
<span class="message"> {{ message|trans|striptags }}</span>
</div>
{% endfor %}
{% if label != 'alert' %}
{% for message in messages %}
<div class="notice">
<span class="type">{{ label }}</span>
<span class="message"> {{ message|trans|striptags }}</span>
</div>
{% endfor %}
{% endif %}
{% endfor %}
</div>
{% endif %}

Loading…
Cancel
Save