-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathusers-table.twig
141 lines (138 loc) · 5.66 KB
/
users-table.twig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
{% import "@core/multidelete-macro.twig" as multidelete %}
{{ include_javascript('javascripts/vendor/datatables-full/jquery.dataTables.min.js') }}
{{ include_css('styles/vendor/datatables-full/dataTables.bootstrap.min.css') }}
{{ include_javascript('javascripts/users-table.js') }}
{{ postActionMessages|raw }}
{# order on #time desc #}
<div id='users-table-action'>
{% if isAdmin %}
<form class="form-inline pull-left" method="post" action="#">
<div class="form-row">
<div class="form-group col-sm-3">
<label for="newUserName" class="sr-only">{{ _t('NAME') }}</label>
<input id="newUserName" class="form-control" name="name" size="10" value="" placeholder="{{ _t('NAME') }}"
pattern="[^!#@\\\/]{1}[^\\\/]{2,}"/>{# pattern for not special characters #}
</div>
<div class="form-group col-sm-4">
<label for="newUserEmail" class="sr-only">{{ _t('EMAIL') }}</label>
<input id="newUserEmail" class="form-control" name="email" size="15" value="" placeholder="{{ _t('EMAIL') }}"
pattern="[!#-'*+/-9=?A-Za-z^-~-]+(?:\.[!#-'*+/-9=?A-Z^-~-]+)*@(?:[!#-'*+/-9=?A-Z^-~-]+\.[!#-'*+/-9=?A-Z^-~-]+)*"/>
{# pattern inspired from RFC 5322 #}
</div>
<div class="form-group col-sm-2">
<button class="btn btn-primary btn-xs create-user" title="{{ _t('USERSTABLE_CREATE_USER_HINT') }}" data-toggle="tooltip" data-placement="bottom"><i class="fa fa-user-plus"></i> {{ _t('USERSTABLE_CREATE_USER') }}</button>
</div>
</div>
</form>
<div class="clearfix"></div>
<div id='users-table-link-change-password' class="form-row"></div>
{% endif %}
<table class="table table-striped" data-order='[[ {{ isAdmin ? 4 : 2 }}, "desc" ]]'>
<thead>
<tr>
{% if isAdmin %}
{{ multidelete.insertSelectAll('users-table-action','top') }}
{% endif %}
<th>{{ _t('NAME') }}</th>
<th>{{ _t('GROUP_S') }}</th>
{% if isAdmin %}
<th>{{ _t('EMAIL') }}</th>
{% endif %}
<th>{{ _t('SUBSCRIPTION') }}</th>
<th></th>
</tr>
</thead>
<tbody>
{% for user in users %}
{% set userIsTheOneConnected = (connectedUserName is not empty and connectedUserName == user.name)%}
<tr>
{% if isAdmin %}
{{ multidelete.insertSelectLine(
'users-table-action',
user.name,
not(isAdmin and not userIsTheOneConnected),
'users') }}
{% endif %}
<td>{{ user.name }}</td>
<td class="users-table-break-word">{{ (isAdmin or userIsTheOneConnected) ? user.groups|join(', ') : ((user.groups is not empty) ? '***' : '') }}</td>
{% if isAdmin %} {# Email only shown to admins #}
<td>{{ user.email }}</td>
{% endif %}
<td>{{ user.#time }}</td>
<td>
{% if userIsTheOneConnected %}
<a href="{{ url({tag:'ParametresUtilisateur'}) }}"
class="btn btn-sm btn-icon btn-primary" role="button" title="{{ _t('MODIFY') }}">
<i class="fa fa-pencil-alt"></i>
</a>
{% elseif isAdmin %}
{# not the current user, then can be modified #}
<a href="{{ url({tag:'ParametresUtilisateur',params:{user:user.name,from:tag}}) }}"
class="btn btn-sm btn-icon btn-warning" role="button" title="{{ _t('MODIFY') }}">
<i class="fa fa-pencil-alt"></i>
</a>
{% endif %}
{% if isAdmin and not userIsTheOneConnected %}
<a
data-toggle="modal"
role="button"
href="#userTableDeleteModal"
class="btn btn-sm btn-icon btn-danger"
data-name="{{ user.name }}"
title="{{ _t('USER_DELETE') }}">
<i class="fa fa-trash"></i>
</a>
{% endif %}
</td>
{% endfor %}
{% if isAdmin %}
<tfoot>
<tr>
{{ multidelete.insertSelectAll('users-table-action','bottom') }}
<th></th>
<th></th>
{% if isAdmin %}
<th></th>
{% endif %}
<th></th>
<th></th>
</tr>
</tfoot>
{% endif %}
</tbody>
</table>
{% if isAdmin %}
{{ multidelete.insertButton('users-table-action','users') }}
<div class="modal fade"
id="userTableDeleteModal"
tabindex="-1"
role="dialog"
aria-labelledby="userTableDeleteModalLabel"
aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="userTableDeleteModalLabel">{{ _t('USER_DELETE') }} :<span id="userNameToDelete"></span></h3>
</div>
<div class="modal-body">
<div class="alert alert-warning">
{{ _t('USER_CONFIRM_DELETE') }}
</div>
<button class="btn btn-sm btn-warning start-btn-delete-user">{{ _t('DELETE') }}</button>
<br/><br/>
<div class="multi-delete-results"></div>
</div>
<div class="modal-footer">
<div class="progressbar progress">
<div class="progress-bar" role="progressbar"
style="width: 0%;"
aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">
</div>
</div>
</div>
</div>{# .modal-content #}
</div>{# .modal-dialog #}
</div>
{% endif %}
</div>