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;
use App\Entity\ContactComptoir;
use App\Entity\Geoloc;
use App\Entity\GlobalParameter;
use App\Entity\Groupe;
use App\Form\Type\ContactEntityFormType;
use App\Form\Type\GeolocFormType;
......@@ -215,20 +216,35 @@ class ComptoirAdmin extends AbstractAdmin
protected function configureListFields(ListMapper $listMapper)
{
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
->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('geoloc', null, array('label' => 'Adresse'))
->add('tel', null, array('label' => 'Téléphone'))
->add('enabled', null, array(
'label' => 'Activé',
'editable' => true
))
->add('_action', null, [
'actions' => [
'show' => ['template' => '@SonataAdmin/CRUD/list__action_showonfront.html.twig'],
'edit' => []
]
'actions' => $actions
])
;
}
......
......@@ -3,6 +3,7 @@
namespace App\Admin;
use App\Entity\Comptoir;
use App\Entity\GlobalParameter;
use App\Entity\Siege;
use FOS\CKEditorBundle\Form\Type\CKEditorType;
use Sonata\AdminBundle\Admin\AbstractAdmin;
......@@ -153,6 +154,19 @@ class GroupeAdmin extends AbstractAdmin
protected function configureListFields(ListMapper $listMapper)
{
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
->addIdentifier('name', null, array('label' => 'Nom du groupe'))
->add('gestionnaires', null, array('label' => 'Gestionnaires'))
......@@ -192,10 +206,7 @@ class GroupeAdmin extends AbstractAdmin
'editable' => true
))
->add('_action', null, [
'actions' => [
'show' => ['template' => '@SonataAdmin/CRUD/list__action_showonfront.html.twig'],
'edit' => []
]
'actions' => $actions
])
;
}
......
......@@ -430,6 +430,25 @@ class PrestataireAdmin extends AbstractAdmin
{
unset($this->listModes['mosaic']);
$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
->addIdentifier('raison')
->add('groupe', null, array(
......@@ -458,15 +477,7 @@ class PrestataireAdmin extends AbstractAdmin
))
// You may also specify the actions you want to be displayed in the list
->add('_action', null, [
'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,
]
],
]
'actions' => $actions
])
;
}
......
......@@ -3,6 +3,7 @@
namespace App\Admin;
use App\Entity\Comptoir;
use App\Entity\GlobalParameter;
use App\Entity\Prestataire;
use App\Entity\Siege;
use App\Entity\Rubrique;
......@@ -142,6 +143,19 @@ class RubriqueAdmin extends AbstractAdmin
protected function configureListFields(ListMapper $listMapper)
{
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
->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'))
......@@ -155,11 +169,7 @@ class RubriqueAdmin extends AbstractAdmin
'editable' => true
))
->add('_action', null, [
'actions' => [
'show' => ['template' => '@SonataAdmin/CRUD/list__action_showonfront.html.twig'],
'edit' => [],
'delete' => [],
]
'actions' => $actions
])
;
}
......
......@@ -81,6 +81,7 @@ class Comptoir
public function __construct()
{
$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