first commit after reset
[mixstore.git] / src / Mixstore / UserBundle / Resources / views / Admin / users.html.twig
CommitLineData
929ca066
BA
1{% extends "::base.html.twig" %}
2
3{% block title %}{{ parent() }}users{% endblock %}
4
5{% block header %}
6{{ parent() }}
7<link rel="stylesheet" href="{{ asset('mixstore/css/user/admin.css') }}">
8{% endblock %}
9
10{% block content %}
11
12{% if is_granted('ROLE_SUPER_ADMIN') %}
13
14<div class="center">
15<h2>All users</h2>
16<h4>Click on a line to toggle privileges. Admins in <span class="blue">blue</span>. Super-admin(s) in <span class="red">red</span></h4>
17<table>
18 <thead>
19 <th>First name</th>
20 <th>Last name</th>
21 <th>Email</th>
22 <th></th>
23 </thead>
24 <tbody>
25 {% for user in users %}
26 <tr id="{{ user.id }}"
27 {% if 'ROLE_SUPER_ADMIN' in user.roles %}
28 {{ 'class="red"' }}
29 {% elseif 'ROLE_ADMIN' in user.roles %}
30 {{ 'class="user blue"' }}
31 {% else %}
32 {{ 'class="user"' }}
33 {% endif %}
34 >
35 <td>{{ user.name }}</td>
36 <td>{{ user.surname }}</td>
37 <td>{{ user.email }}</td>
38 <td><a href="{{ path('mixstore_user_admin_delete', { id: user.id }) }}">Delete</a></td>
39 </tr>
40 {% endfor %}
41 </tbody>
42</table>
43</div>
44
45{% endif %}
46
47{% endblock %}
48
49{% block javascripts %}
50{{ parent() }}
51<script>
52$( "tr" ).click(function()
53{
54 //do nothing if super-admin is clicked
55 if ($(this).attr('class').indexOf("red") >= 0)
56 return;
57
58 //save id for use in AJAX call
59 id = $(this).attr('id');
60
61 //http://stackoverflow.com/questions/13584591/how-to-integrate-ajax-with-symfony2
62 $.post(
63 "{{ path('mixstore_user_admin_toggle') }}",
64 {id: id},
65 function(response)
66 {
67 $('#' + id).toggleClass("blue");
68 },
69 "text");
70});
71</script>
72{% endblock %}