svg
This commit is contained in:
parent
f417f86684
commit
ee2732d329
|
@ -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();
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
<table class="table table-striped table-bordered table-hover" id="dataTables" style="width:100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="70px">Action</th>
|
||||
<th width="200px">Permission</th>
|
||||
<th >Action</th>
|
||||
<th width="150px">Permission</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
|
@ -24,7 +24,10 @@
|
|||
<tr>
|
||||
<td>{{ permmodo.label}}</td>
|
||||
<td>
|
||||
{% if permmodo.visible %} oui {%else%} non {%endif %}
|
||||
{% set checked="" %}
|
||||
{% if permmodo.visible %} {% set checked="checked" %} {%endif %}
|
||||
<input type="checkbox" class="switch" onChange="switchModo({{ permmodo.id }});" {{ checked }}>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
{% 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 %}
|
||||
|
|
Loading…
Reference in New Issue