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