]> git.agnieray.net Git - galette.git/blob - galette/templates/default/elements/group.html.twig
19fef5c643d38df596c2f83a4aa298162d9262ed
[galette.git] / galette / templates / default / elements / group.html.twig
1 {% set can_edit = group.canEdit(login) %}
2
3 {% set managers = group.getManagers() %}
4 {% set members = group.getMembers() %}
5
6 <div class="ui stackable pointing inverted menu tabbed">
7 <div class="item header">
8 <i class="users cog icon"></i>
9 {{ group.getFullName() }} :
10 </div>
11 <a href="{{ url_for('groups', {'id': group.getId()}) }}?tab=group_information" class="item{{ tab == 'group_information' ? ' active' }}" data-tab="group_information">{{ _T("Information") }}</a>
12 <a href="{{ url_for('groups', {'id': group.getId()}) }}?tab=group_managers" class="item{{ tab == 'group_managers' ? ' active' }}" data-tab="group_managers">{{ _T("Managers") }} ({{ managers|length }})</a>
13 <a href="{{ url_for('groups', {'id': group.getId()}) }}?tab=group_members" class="item{{ tab == 'group_members' ? ' active' }}" data-tab="group_members">{{ _T("Members") }} ({{ members|length }})</a>
14 </div>
15 <form class="ui form" action="{{ url_for("doEditGroup", {"id": group.getId()}) }}" method="post" enctype="multipart/form-data" id="group_form">
16 <div class="ui{{ tab == 'group_information' ? ' active' }} tab segment" data-tab="group_information">
17 <div class="ui basic segment">
18 {% if group.getId() %}
19 <div class="inline field">
20 <label>{{ _T("Creation date:") }}</label>
21 <span>{{ group.getCreationDate() }}</span>
22 </div>
23 {% endif %}
24 <div class="inline field{% if can_edit %} required{% endif %}">
25 <label for="group_name">{{ _T("Name:") }}</label>
26 {% if can_edit %}
27 <input type="text" name="group_name" id="group_name" value="{{ group.getName() }}" maxlength="250" required/>
28 {% else %}
29 <span>{{ group.getName() }}</span>
30 {% endif %}
31 </div>
32
33 {% if group.getParentGroup() %}
34 {% set pgroup = group.getParentGroup() %}
35 {% endif %}
36 <div class="inline field">
37 <label for="parent_group">{{ _T("Parent group:") }}</label>
38 {% if can_edit and parent_groups|length > 0 %}
39 {% if pgroup is defined and not login.isGroupManager(pgroup.getId()) %}
40 {{ pgroup.getName() }}
41 <input type="hidden" name="parent_group" value="{{ pgroup.getId() }}"/>
42 {% else %}
43 <select name="parent_group" id="parent_group" class="ui search dropdown nochosen">
44 <option value="none">{{ _T("None") }}</option>
45 {% for g in parent_groups %}
46 <option value="{{ g.getId() }}"{% if pgroup is defined and pgroup.getId() == g.getId() %} selected="selected"{% endif %}>{{ g.getIndentName()|raw }}</option>
47 {% endfor %}
48 </select>
49 {% endif %}
50 {% else %}
51 <span>
52 {% if pgroup is defined %}
53 {{ pgroup.getName() }}
54 <input type="hidden" name="parent_group" value="{{ pgroup.getId() }}"/>
55 {% else %}
56 {{ _T("None") }}
57 <input type="hidden" name="parent_group" value=""/>
58 {% endif %}
59 </span>
60 {% endif %}
61 </div>
62 </div>
63 </div>
64
65 <div id="group_managers" class="ui{{ tab == 'group_managers' ? ' active' }} tab segment" data-tab="group_managers">
66 <div class="ui basic segment">
67 {% if group %}
68 {% if login.isAdmin() or login.isStaff() %}
69 <a href="#" class="jsonly disabled ui labeled icon button" id="btnmanagers_small">
70 <i class="user shield icon" aria-hidden="true"></i>
71 {{ _T("Manage managers") }}
72 </a>
73 {% endif %}
74 {% include "elements/group_persons.html.twig" with {'person_mode': "managers", 'persons': managers} %}
75 {% endif %}
76 </div>
77 </div>
78
79 <div id="group_members" class="ui{{ tab == 'group_members' ? ' active' }} tab segment" data-tab="group_members">
80 <div class="ui basic segment">
81 {% if group %}
82 {% if login.isAdmin() or login.isStaff() %}
83 <a href="#" class="jsonly disabled ui labeled icon button" id="btnusers_small">
84 <i class="user icon" aria-hidden="true"></i>
85 {{ _T("Manage members") }}
86 </a>
87 {% endif %}
88 {% include "elements/group_persons.html.twig" with {'person_mode': "members", 'persons': members} %}
89 {% endif %}
90 </div>
91 </div>
92
93 <div class="ui basic center aligned segment">
94 <div class="ui wrapping spaced buttons">
95 {% if can_edit %}
96 <button type="submit" name="valid" class="ui labeled icon primary button action">
97 <i class="save icon"></i> {{ _T("Save") }}
98 </button>
99 <input type="hidden" name="id_group" id="id_group" value="{{ group.getId() }}"/>
100 <input type="hidden" name="tab" id="tab" value="{{ tab }}"/>
101 {% include "components/forms/csrf.html.twig" %}
102 {% endif %}
103 {% if can_export %}
104 <a href="{{ url_for("pdf_groups", {"id": group.getId()}) }}" class="ui labeled icon button tooltip" title="{{ _T("Current group (and attached people) as PDF") }}">
105 <i class="file pdf red icon" aria-hidden="true"></i>
106 {{ _T("Group PDF") }}
107 </a>
108 {% endif %}
109 {% if login.isAdmin() or login.isStaff() %}
110 <a class="ui labeled icon button delete" id="delete" href="{{ url_for("removeGroup", {"id": group.getId()}) }}">
111 <i class="trash alt red icon" aria-hidden="true"></i>
112 {{ _T("Delete") }}
113 </a>
114 {% endif %}
115 </div>
116 </div>
117 </form>
118 <script type="text/javascript">
119 $(function() {
120 var _btnaid = '#newgroup';
121 var _btnuid = '#btnusers_small';
122 var _btnmid = '#btnmanagers_small';
123
124 {# Tabs #}
125 $('.menu.tabbed .item').tab({
126 onFirstLoad: function(tabPath) {
127 {% if login.isAdmin() or login.isStaff() %}
128 if (tabPath == 'group_managers') {
129 $(_btnaid).addClass('displaynone');
130 $(_btnuid).addClass('displaynone');
131 } else if ( tabPath == 'group_members' ) {
132 $(_btnaid).addClass('displaynone');
133 $(_btnmid).addClass('displaynone');
134 } else if ( tabPath == 'group_information' ) {
135 $(_btnuid).addClass('displaynone');
136 $(_btnmid).addClass('displaynone');
137 }
138 {% endif %}
139 },
140 onVisible: function(tabPath) {
141 document.getElementById('tab').value = tabPath;
142 {% if login.isAdmin() or login.isStaff() %}
143 if ( tabPath == 'group_managers' ) {
144 $(_btnmid).removeClass('displaynone');
145 $(_btnaid).addClass('displaynone');
146 if ( !$(_btnuid).hasClass('displaynone') ) {
147 $(_btnuid).addClass('displaynone');
148 }
149 } else if ( tabPath == 'group_members' ) {
150 $(_btnuid).removeClass('displaynone');
151 $(_btnaid).addClass('displaynone');
152 if ( !$(_btnmid).hasClass('displaynone') ) {
153 $(_btnmid).addClass('displaynone');
154 }
155 } else if ( tabPath == 'group_information' ) {
156 $(_btnaid).removeClass('displaynone');
157 $(_btnuid).addClass('displaynone');
158 $(_btnmid).addClass('displaynone');
159 }
160 {% endif %}
161 }
162 }).tab('change tab', '{{ tab }}');
163 });
164 </script>