Commit ba4047f9 by Julien Jorry

Fix admin : on cache le bouton 'Afficher' si on utilise le module wordpress sur…

Fix admin : on cache le bouton 'Afficher' si on utilise le module wordpress sur les groupes, prestas, groupeprestas et comptoirs
parent 41937918
...@@ -4,6 +4,7 @@ namespace App\Admin; ...@@ -4,6 +4,7 @@ namespace App\Admin;
use App\Entity\ContactComptoir; use App\Entity\ContactComptoir;
use App\Entity\Geoloc; use App\Entity\Geoloc;
use App\Entity\GlobalParameter;
use App\Entity\Groupe; use App\Entity\Groupe;
use App\Form\Type\ContactEntityFormType; use App\Form\Type\ContactEntityFormType;
use App\Form\Type\GeolocFormType; use App\Form\Type\GeolocFormType;
...@@ -215,20 +216,35 @@ class ComptoirAdmin extends AbstractAdmin ...@@ -215,20 +216,35 @@ class ComptoirAdmin extends AbstractAdmin
protected function configureListFields(ListMapper $listMapper) protected function configureListFields(ListMapper $listMapper)
{ {
unset($this->listModes['mosaic']); unset($this->listModes['mosaic']);
$isWordpressActivated = $this->getConfigurationPool()->getContainer()->get('doctrine')->getRepository(GlobalParameter::class)->val(GlobalParameter::USE_WORDPRESS);
if ($isWordpressActivated == 'false') {
$actions = [
'show' => ['template' => '@SonataAdmin/CRUD/list__action_showonfront.html.twig'],
'edit' => []
];
} else {
$actions = [
'edit' => []
];
}
$listMapper $listMapper
->addIdentifier('name') ->addIdentifier('name')
->addIdentifier('groupe', null, array(
'label' => 'Groupe',
'sortable' => true,
'sort_field_mapping' => array('fieldName' => 'name'),
'sort_parent_association_mappings' => array(array('fieldName' => 'groupe'))
))
->add('compte', null, array('label' => 'Solde')) ->add('compte', null, array('label' => 'Solde'))
->add('geoloc', null, array('label' => 'Adresse')) ->add('geoloc', null, array('label' => 'Adresse'))
->add('tel', null, array('label' => 'Téléphone'))
->add('enabled', null, array( ->add('enabled', null, array(
'label' => 'Activé', 'label' => 'Activé',
'editable' => true 'editable' => true
)) ))
->add('_action', null, [ ->add('_action', null, [
'actions' => [ 'actions' => $actions
'show' => ['template' => '@SonataAdmin/CRUD/list__action_showonfront.html.twig'],
'edit' => []
]
]) ])
; ;
} }
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace App\Admin; namespace App\Admin;
use App\Entity\Comptoir; use App\Entity\Comptoir;
use App\Entity\GlobalParameter;
use App\Entity\Siege; use App\Entity\Siege;
use FOS\CKEditorBundle\Form\Type\CKEditorType; use FOS\CKEditorBundle\Form\Type\CKEditorType;
use Sonata\AdminBundle\Admin\AbstractAdmin; use Sonata\AdminBundle\Admin\AbstractAdmin;
...@@ -153,6 +154,19 @@ class GroupeAdmin extends AbstractAdmin ...@@ -153,6 +154,19 @@ class GroupeAdmin extends AbstractAdmin
protected function configureListFields(ListMapper $listMapper) protected function configureListFields(ListMapper $listMapper)
{ {
unset($this->listModes['mosaic']); unset($this->listModes['mosaic']);
$isWordpressActivated = $this->getConfigurationPool()->getContainer()->get('doctrine')->getRepository(GlobalParameter::class)->val(GlobalParameter::USE_WORDPRESS);
if ($isWordpressActivated == 'false') {
$actions = [
'show' => ['template' => '@SonataAdmin/CRUD/list__action_showonfront.html.twig'],
'edit' => []
];
} else {
$actions = [
'edit' => []
];
}
$listMapper $listMapper
->addIdentifier('name', null, array('label' => 'Nom du groupe')) ->addIdentifier('name', null, array('label' => 'Nom du groupe'))
->add('gestionnaires', null, array('label' => 'Gestionnaires')) ->add('gestionnaires', null, array('label' => 'Gestionnaires'))
...@@ -192,10 +206,7 @@ class GroupeAdmin extends AbstractAdmin ...@@ -192,10 +206,7 @@ class GroupeAdmin extends AbstractAdmin
'editable' => true 'editable' => true
)) ))
->add('_action', null, [ ->add('_action', null, [
'actions' => [ 'actions' => $actions
'show' => ['template' => '@SonataAdmin/CRUD/list__action_showonfront.html.twig'],
'edit' => []
]
]) ])
; ;
} }
......
...@@ -430,6 +430,25 @@ class PrestataireAdmin extends AbstractAdmin ...@@ -430,6 +430,25 @@ class PrestataireAdmin extends AbstractAdmin
{ {
unset($this->listModes['mosaic']); unset($this->listModes['mosaic']);
$user = $this->security->getUser(); $user = $this->security->getUser();
$isWordpressActivated = $this->getConfigurationPool()->getContainer()->get('doctrine')->getRepository(GlobalParameter::class)->val(GlobalParameter::USE_WORDPRESS);
if ($isWordpressActivated == 'false') {
$actions = [
'show' => ['template' => '@SonataAdmin/CRUD/list__action_showonfront.html.twig'],
'edit' => [
// You may add custom link parameters used to generate the action url
'link_parameters' => [
'full' => true,
]
]];
} else {
$actions = [
'edit' => [
// You may add custom link parameters used to generate the action url
'link_parameters' => [
'full' => true,
]
]];
}
$listMapper $listMapper
->addIdentifier('raison') ->addIdentifier('raison')
->add('groupe', null, array( ->add('groupe', null, array(
...@@ -458,15 +477,7 @@ class PrestataireAdmin extends AbstractAdmin ...@@ -458,15 +477,7 @@ class PrestataireAdmin extends AbstractAdmin
)) ))
// You may also specify the actions you want to be displayed in the list // You may also specify the actions you want to be displayed in the list
->add('_action', null, [ ->add('_action', null, [
'actions' => [ 'actions' => $actions
'show' => ['template' => '@SonataAdmin/CRUD/list__action_showonfront.html.twig'],
'edit' => [
// You may add custom link parameters used to generate the action url
'link_parameters' => [
'full' => true,
]
],
]
]) ])
; ;
} }
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace App\Admin; namespace App\Admin;
use App\Entity\Comptoir; use App\Entity\Comptoir;
use App\Entity\GlobalParameter;
use App\Entity\Prestataire; use App\Entity\Prestataire;
use App\Entity\Siege; use App\Entity\Siege;
use App\Entity\Rubrique; use App\Entity\Rubrique;
...@@ -142,6 +143,19 @@ class RubriqueAdmin extends AbstractAdmin ...@@ -142,6 +143,19 @@ class RubriqueAdmin extends AbstractAdmin
protected function configureListFields(ListMapper $listMapper) protected function configureListFields(ListMapper $listMapper)
{ {
unset($this->listModes['mosaic']); unset($this->listModes['mosaic']);
$isWordpressActivated = $this->getConfigurationPool()->getContainer()->get('doctrine')->getRepository(GlobalParameter::class)->val(GlobalParameter::USE_WORDPRESS);
if ($isWordpressActivated == 'false') {
$actions = [
'show' => ['template' => '@SonataAdmin/CRUD/list__action_showonfront.html.twig'],
'edit' => [],
'delete' => [],
];
} else {
$actions = [
'edit' => [],
'delete' => [],
];
}
$listMapper $listMapper
->add('file', null, array('label' => 'Icône', 'template' => '@SonataAdmin/Image/preview_image_o.html.twig')) ->add('file', null, array('label' => 'Icône', 'template' => '@SonataAdmin/Image/preview_image_o.html.twig'))
->add('name', null, array('editable' => true, 'truncate' => array('length' => 80), 'label' => 'Nom du groupe')) ->add('name', null, array('editable' => true, 'truncate' => array('length' => 80), 'label' => 'Nom du groupe'))
...@@ -155,11 +169,7 @@ class RubriqueAdmin extends AbstractAdmin ...@@ -155,11 +169,7 @@ class RubriqueAdmin extends AbstractAdmin
'editable' => true 'editable' => true
)) ))
->add('_action', null, [ ->add('_action', null, [
'actions' => [ 'actions' => $actions
'show' => ['template' => '@SonataAdmin/CRUD/list__action_showonfront.html.twig'],
'edit' => [],
'delete' => [],
]
]) ])
; ;
} }
......
...@@ -81,6 +81,7 @@ class Comptoir ...@@ -81,6 +81,7 @@ class Comptoir
public function __construct() public function __construct()
{ {
$this->gestionnaires = new ArrayCollection(); $this->gestionnaires = new ArrayCollection();
$this->contacts = new ArrayCollection();
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment