3 * Copyright © 2003-2024 The Galette Team
5 * This file is part of Galette (https://galette.eu).
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.
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.
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/>.
21 {% set mode = mode|default('') %}
22 {% set is_paginated = is_paginated ?? (nb > 0) %}
23 {% set is_public = is_public ?? false %}
25 {% extends (mode == 'ajax') ? "ajax.html.twig" : is_public ? "public_page.html.twig" : "page.html.twig" %}
26 {% import "macros.twig" as macros %}
29 {% if mode == 'ajax' %}
30 <div id="main-container">
32 {% block search %}{% endblock %}
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 %}
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>
50 {% for key, value in nbshow_options %}
51 <div class="item{% if key == numrows %} active selected {% endif %}" data-value="{{ key }}">{{ value }}</div>
60 {% if mode != 'ajax' %}
61 {% include "components/forms/csrf.html.twig" %}
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">
69 {% if mode != 'ajax' and batch_actions is defined and batch_actions|length > 0 %}
70 {{ macros.drawBatchActionsList(batch_actions) }}
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 %}">
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">
82 {% for column in columns %}
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})) }}">
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>
91 <i class="ui angle up icon tooltip" aria-hidden="true"></i>
100 {% if mode != 'ajax' and (no_action is not defined or no_action == false) %}
101 <th class="actions_row">{{ _T('Actions') }}</th>
108 {% block body %}{% endblock %}
109 {% if list_type is not defined %}
112 {% block footer %}{% endblock %}
119 {% if form is defined and mode != 'ajax' and batch_actions is defined and batch_actions|length > 0 %}
120 {{ macros.drawBatchActionsList(batch_actions) }}
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">
134 {% if form is defined %}
135 {% block extra_form %}{% endblock %}
136 {% include "components/forms/csrf.html.twig" %}
139 {% block legend %}{% endblock %}
140 {% if mode == 'ajax' %}
145 {% set _legend_block = block('legend') %}
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"),
157 modal_deny_only: true,
158 modal_cancel_text: _T("Close")|e("js"),
159 modal_classname: "redalert",
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>';
177 $('.batch-select-action').before(_checklinks);
178 $('.batch-select-action').dropdown({
179 action: function(text, value, element) {
180 if (!_checkselection()) {
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"/>'));
194 $('#directdownload').remove();
195 {% if login.isAdmin() or login.isStaff() %}
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,
206 loader_parent: ".batch-select-action"
210 // Handle other custom list actions.
211 {% if batch_selection is defined %}
212 {% block batch_selection %}{% endblock %}
216 {% if _legend_block is not empty %}
217 $('.batch-selection').after(_legendlink);
219 _bind_check('entries_sel');
224 {% if _legend_block is not empty %}
227 {% include "elements/js/removal.js.twig" with {
228 single_action: "true"