From ee2732d32990ceb600bcdd1a2614a1667ef85cc7 Mon Sep 17 00:00:00 2001 From: afornerot Date: Wed, 19 Jun 2019 11:54:36 +0200 Subject: [PATCH] svg --- .../Controller/ConfigController.php | 24 ++++++++++++++++++- .../CoreBundle/Resources/config/routing.yml | 5 ++++ .../Resources/views/Config/permmodo.html.twig | 22 ++++++++++++++--- 3 files changed, 47 insertions(+), 4 deletions(-) diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/ConfigController.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/ConfigController.php index 2e27a13b..3a3c99d5 100755 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/ConfigController.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/ConfigController.php @@ -4,6 +4,7 @@ namespace Cadoles\CoreBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; use Cadoles\CoreBundle\Entity\Config; use Cadoles\CoreBundle\Form\ConfigType; @@ -149,7 +150,7 @@ class ConfigController extends Controller foreach($sidebar["childs"] as $child) { $permmod=$em->getRepository("CadolesCoreBundle:PermModo")->findOneBy(["route"=>$child["path"]]); if($permmod) { - array_push($perms,['label'=>$sidebar['label'].' >> '.$child['label'],'visible'=>$permmod->getVisible()]); + array_push($perms,['id' => $permmod->getId(), 'label'=>$sidebar['label'].' >> '.$child['label'],'visible'=>$permmod->getVisible()]); } } } @@ -162,6 +163,27 @@ class ConfigController extends Controller ]); } + public function permmodoupdateAction(Request $request) + { + // S'assurer que c'est un appel ajax + if (!$request->isXmlHttpRequest()) return new JsonResponse(array('message' => 'Interdit'), 400); + + $output=array(); + $id = $request->request->get('id'); + + $em = $this->getDoctrine()->getManager(); + $permmodo = $this->getDoctrine()->getRepository("CadolesCoreBundle:PermModo")->find($id); + if (!$permmodo) throw $this->createNotFoundException('Unable to find entity.'); + + $permmodo->setVisible(!$permmodo->getVisible()); + $em->persist($permmodo); + $em->flush(); + + $response = new Response(json_encode($output)); + $response->headers->set('Content-Type', 'application/json'); + return $response; + } + protected function getErrorForm($form,$request,$data) { if ($form->get('submit')->isClicked() && !$form->isValid()) { $this->get('session')->getFlashBag()->clear(); diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/config/routing.yml b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/config/routing.yml index 485307ad..f0a750cb 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/config/routing.yml +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/config/routing.yml @@ -153,6 +153,11 @@ cadoles_core_config_permmodo: path: /config/commun/permmodo defaults: { _controller: CadolesCoreBundle:Config:permmodo } +cadoles_core_config_permmodo_update: + path: /config/commun/permmodo/update + defaults: { _controller: CadolesCoreBundle:Config:permmodoupdate } + + #== Registration ========================================================================================================= #-- Access config cadoles_core_config_registration: diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/Config/permmodo.html.twig b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/Config/permmodo.html.twig index bf27e211..7d0922af 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/Config/permmodo.html.twig +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/Config/permmodo.html.twig @@ -14,8 +14,8 @@ - - + + @@ -24,7 +24,10 @@ {% endfor %} @@ -45,5 +48,18 @@ $('#dataTables').DataTable({ responsive: true, }); + + $(".switch").bootstrapSwitch(); }); + + function switchModo(id) { + $.ajax({ + method: "POST", + url: "{{ path('cadoles_core_config_permmodo_update') }}", + data: { + "id": id, + } + }); + } + {% endblock %}
ActionPermissionActionPermission
{{ permmodo.label}} - {% if permmodo.visible %} oui {%else%} non {%endif %} + {% set checked="" %} + {% if permmodo.visible %} {% set checked="checked" %} {%endif %} + +