]> git.agnieray.net Git - galette.git/blob - galette/templates/default/elements/list.html.twig
5cc3357d907d68c4f5dbfdf7ebe9d76807a87cff
[galette.git] / galette / templates / default / elements / list.html.twig
1 {% set mode = mode|default('') %}
2 {% set is_paginated = is_paginated ?? (nb > 0) %}
3 {% set is_public = is_public ?? false %}
4
5 {% extends (mode == 'ajax') ? "ajax.html.twig" : is_public ? "public_page.html.twig" : "page.html.twig" %}
6 {% import "macros.twig" as macros %}
7
8 {% block content %}
9 {% if mode == 'ajax' %}
10 <div id="main-container">
11 {% endif %}
12 {% block search %}{% endblock %}
13 {% block infoline %}
14 <form action="{% if infoline.route is defined %}{{ url_for(infoline.route.name, infoline.route.args|default([])) }}{% endif %}" method="post" class="ui form">
15 <div class="infoline">
16 <div class="ui basic horizontal segments">
17 <div class="ui basic fitted segment">
18 <div class="ui label">{{ infoline.label }}</div>
19 {% block infoline_actions %}{% endblock %}
20 </div>
21 {% if infoline.route is defined %}
22 <div class="ui basic right aligned fitted segment">
23 <div class="inline field">
24 <label for="nbshow">{{ _T('Records per page:') }}</label>
25 <div class="ui dropdown selection autosubmit">
26 <input type="hidden" name="nbshow" value="{{ numrows }}">
27 <i class="dropdown icon"></i>
28 <div class="text">{% if numrows == 0 %}{{ _T('All') }}{% else %}{{ numrows }}{% endif %}</div>
29 <div class="menu">
30 {% for key, value in nbshow_options %}
31 <div class="item{% if key == numrows %} active selected {% endif %}" data-value="{{ key }}">{{ value }}</div>
32 {% endfor %}
33 </div>
34 </div>
35 </div>
36 </div>
37 {% endif %}
38 </div>
39 </div>
40 {% if mode != 'ajax' %}
41 {% include "components/forms/csrf.html.twig" %}
42 {% endif %}
43 </form>
44 {% endblock %}
45 {% if form is defined %}
46 <form action="{% if form.route is defined %}{{ url_for(form.route.name, form.route.args|default([])) }}{% endif %}" method="post" id="listform" class="ui form">
47 <div class="ui basic fitted segment">
48
49 {% if mode != 'ajax' and batch_actions is defined and batch_actions|length > 0 %}
50 {{ macros.drawBatchActionsList(batch_actions) }}
51 {% endif %}
52 {% endif %}
53
54 {% if list_type is defined and list_type == 'cards' %}
55 <div class="{% if nb %}ui doubling {% if cards_columns is defined %}{{ cards_columns }}{% else %}six{% endif %} column cards loader_selector{% endif %}">
56 {% else %}
57 <div class="ui basic fitted segment loader_selector">
58 <table class="listing ui celled{% if basic_table is not defined %} striped{% endif %} table">
59 <thead>
60 <tr>
61 {% block header %}
62 {% for column in columns %}
63 <th class="left">
64 {% if form is defined and column.order is defined %}
65 <a href="{{ url_for(form.order.name, form.order.args|default([])|merge({"option": "order", "value": column.order})) }}">
66 {{ column.label }}
67 {% if filters.orderby == column.order %}
68 {% if filters.ordered == constant('Galette\\Core\\Pagination::ORDER_ASC') %}
69 <i class="ui angle down icon tooltip" aria-hidden="true"></i>
70 {% else %}
71 <i class="ui angle up icon tooltip" aria-hidden="true"></i>
72 {% endif %}
73 {% endif %}
74 </a>
75 {% else %}
76 {{ column.label }}
77 {% endif %}
78 </th>
79 {% endfor %}
80 {% if mode != 'ajax' and no_action is not defined or no_action == false %}
81 <th class="actions_row">{{ _T('Actions') }}</th>
82 {% endif %}
83 {% endblock %}
84 </tr>
85 </thead>
86 <tbody>
87 {% endif %}
88 {% block body %}{% endblock %}
89 {% if list_type is not defined %}
90 </tbody>
91 <tfoot>
92 {% block footer %}{% endblock %}
93 </tfoot>
94 </table>
95 {% endif %}
96
97 {% if form is defined and mode != 'ajax' and batch_actions is defined and batch_actions|length > 0 %}
98 {{ macros.drawBatchActionsList(batch_actions) }}
99 {% endif %}
100
101 </div>
102
103 {% if is_paginated %}
104 <div class="ui basic center aligned fitted segment">
105 <div class="ui inverted pagination stackable menu">
106 <div class="header item">
107 {{ _T('Pages:') }}
108 </div>
109 {{ pagination|raw }}
110 </div>
111 </div>
112 {% endif %}
113
114 {% if form is defined %}
115 {% block extra_form %}{% endblock %}
116 {% include "components/forms/csrf.html.twig" %}
117 </form>
118 {% endif %}
119 {% block legend %}{% endblock %}
120 {% if mode == 'ajax' %}
121 </div>
122 {% endif %}
123 {% endblock %}
124
125 {% set _legend_block = block('legend') %}
126
127 {% block javascripts %}
128 <script type="text/javascript">
129 {% if batch is defined and batch_actions is defined and batch_actions|length > 0 %}
130 var _checkselection = function() {
131 var _checked = $('#listform').find('input[type=checkbox]:checked').length;
132 if ( _checked == 0 ) {
133 {% include "elements/js/modal.js.twig" with {
134 modal_title_twig: batch.modal.title|e("js"),
135 modal_content_twig: batch.modal.content|e("js"),
136 modal_class: "tiny",
137 modal_deny_only: true,
138 modal_cancel_text: _T("Close")|e("js"),
139 modal_classname: "redalert",
140 } %}
141 return false;
142 } else {
143 return true;
144 }
145 }
146 {% endif %}
147 $(function(){
148 {% if batch is defined and batch_actions is defined and batch_actions|length > 0 %}
149 var _init_page = function(res){
150 {% if login.isAdmin() or login.isStaff() or login.isGroupManager() %}
151 {# Use of Javascript to draw specific elements that are not relevant if JS is inactive #}
152 var _checklinks = '<a href="#" class="checkall ui blue tertiary button">{{ _T("(Un)Check all")|e('js') }}</a>' +
153 ' | <a href="#" class="checkinvert ui blue tertiary button">{{ _T("Invert selection")|e('js') }}</a> | ';
154 {% if _legend_block is not empty %}
155 var _legendlink = '<div class="ui basic right aligned fitted segment"><a href="#" class="show_legend ui blue tertiary button">{{ _T("Show legend")|e('js') }}</a></div></div>';
156 {% endif %}
157 $('.batch-select-action').before(_checklinks);
158 $('.batch-select-action').dropdown({
159 action: function(text, value, element) {
160 if (!_checkselection()) {
161 return false;
162 }
163 // Hide dropdown
164 var element = element.parentElement !== undefined ? element : element[0];
165 var dropdown = element.parentElement.parentElement;
166 $(dropdown).dropdown('hide');
167 // Handle direct download actions.
168 if (value.endsWith('__directdownload')) {
169 const _value = value.split('__');
170 var value = _value[0];
171 var _form = $('#listform');
172 _form.append($('<input id="directdownload" type="hidden" name="' + value + '" value="true"/>'));
173 _form.submit();
174 $('#directdownload').remove();
175 {% if login.isAdmin() or login.isStaff() %}
176 // Handle delete.
177 } else if (value == 'delete') {
178 {% include "elements/js/removal.js.twig" with {
179 selector: ".batch-delete",
180 deleteurl: url_for(batch.route.name, batch.route.args|default([])),
181 extra_data: "delete: true, entries_sel: $('#listform input[type=\"checkbox\"]:checked').map(function(){ return $(this).val(); }).get()",
182 method: "POST",
183 loader: "button",
184 loader_parent: ".batch-select-action"
185 } %}
186 {% endif %}
187 }
188 // Handle other custom list actions.
189 {% if batch_selection is defined %}
190 {% block batch_selection %}{% endblock %}
191 {% endif %}
192 }
193 });
194 {% if _legend_block is not empty %}
195 $('.batch-selection').after(_legendlink);
196 {% endif %}
197 _bind_check('entries_sel');
198 {% endif %}
199 }
200 _init_page();
201 {% endif %}
202 {% if _legend_block is not empty %}
203 _bind_legend();
204 {% endif %}
205 {% include "elements/js/removal.js.twig" with {
206 single_action: "true"
207 } %}
208 });
209 </script>
210 {% endblock %}