Repository navigation
Expand file tree
/
Copy pathlist.html
More file actions
256 lines (252 loc) · 11.4 KB
/
Copy pathlist.html
File metadata and controls
256 lines (252 loc) · 11.4 KB
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
{% extends "layout.html" %}
{% block page_body %}
<div class="col-12">
<div class="card">
<div class="card-header">
<form
action="{{ request.app.admin_path }}/{{ resource }}/list"
method="get"
class="w-100"
>
<div class="d-flex">
<div class="text-muted">
{{ _('show') }}
<div class="mx-2 d-inline-block">
<input
type="text"
class="form-control"
value="{{ page_size }}"
size="2"
name="page_size"
aria-label="entries count"
/>
</div>
{{ _('entries') }}
</div>
<div class="d-flex ms-auto">
{% for filter in filters %}
<div class="mx-2">{{ filter|safe }}</div>
{% endfor %}
<div class="ms-2">
<button type="submit" class="btn btn-primary">
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-search"
width="24" height="24" viewBox="0 0 24 24" stroke-width="2"
stroke="currentColor" fill="none" stroke-linecap="round"
stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<circle cx="10" cy="10" r="7"></circle>
<line x1="21" y1="21" x2="15" y2="15"></line>
</svg>
{{ _('search') }}
</button>
</div>
</div>
</div>
</form>
</div>
<div class="card-body border-bottom py-3 d-flex">
<div id="bulk-actions">
{% if model_resource.bulk_actions %}
<span class="dropdown">
<button class="btn dropdown-toggle align-text-top" data-bs-boundary="viewport"
data-bs-toggle="dropdown">
{{ _('bulk_actions') }}
</button>
<div class="dropdown-menu dropdown-menu-end dropdown-menu-arrow">
{% for action in model_resource.bulk_actions %}
{% set url = request.app.admin_path + '/' + resource +'/bulk_actions/'+ action.name %}
<a
class="dropdown-item"
{% if action.ajax %}
href="#"
onclick="onBulkAction('{{ url }}','{{ action.method }}')"
{% else %}
href="{{ url }}"
{% endif %}
>
<i class="{{ action.icon }} me-2"></i>
{{ action.label }}
</a>
{% endfor %}
</div>
</span>
{% endif %}
</div>
{% if model_resource.can_create %}
<a class="ms-auto btn btn-dark" href="{{ request.app.admin_path }}/{{ resource }}/create">
<svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24" viewBox="0 0 24 24"
stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round"
stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<line x1="12" y1="5" x2="12" y2="19"></line>
<line x1="5" y1="12" x2="19" y2="12"></line>
</svg>
{{ _('create') }}
</a>
{% endif %}
</div>
<div class="table-responsive">
<table class="table card-table table-vcenter text-nowrap datatable">
<thead>
<tr>
{% if model_resource.bulk_actions %}
<th class="w-1">
<input
class="form-check-input m-0 align-middle"
type="checkbox"
id="checkbox-select-all"
/>
</th>
{% endif %}
{% for label in fields_label %}
<th>{{ label }}</th>
{% endfor %}
{% if model_resource.actions %}
<th></th>
{% endif %}
</tr>
</thead>
<tbody>
{% for value in rendered_values %}
<tr {% for k,v in row_attributes[loop.index0].items() %}{{ k }}="{{ v }}"{% endfor %}>
{% if model_resource.bulk_actions %}
<td>
<input
data-id="{{ value[0]|int }}"
class="form-check-input m-0 align-middle checkbox-select-item"
type="checkbox"
/>
</td>
{% endif %}
{% with outer_index = loop.index0 %}
{% for x in value %}
<td {% for k,v in cell_attributes[outer_index][loop.index0].items() %}
{{ k }}="{{ v }}"{% endfor %}>{{ x|safe }}</td>
{% endfor %}
{% endwith %}
{% if model_resource.actions %}
<td class="text-end">
<span class="dropdown">
<button
class="btn dropdown-toggle align-text-top"
data-bs-boundary="viewport"
data-bs-toggle="dropdown"
>
{{ _('actions') }}
</button>
<div
class="dropdown-menu dropdown-menu-end dropdown-menu-arrow"
>
{% for action in model_resource.actions %}
{% set url = request.app.admin_path + '/' + resource +'/'+ action.name +'/'+ value[0]|string %}
<a
class="dropdown-item"
{% if action.ajax %}
href="#"
onclick="onAction('{{ url }}','{{ action.method }}')"
{% else %}
href="{{ url }}"
{% endif %}
>
<i class="{{ action.icon }} me-2"></i>
{{ action.label }}
</a>
{% endfor %}
</div>
</span>
</td>
{% endif %}
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="card-footer d-flex align-items-center">
<p class="m-0 text-muted">
{{ _('Showing %(from)s to %(to)s of %(total)s entries')|format(from=from,to=to,total=total) }}
</p>
<ul class="pagination m-0 ms-auto">
<li class="page-item {% if page_num <= 1 %} disabled {% endif %}">
<a
class="page-link"
href="{{ {'page_num':page_num - 1}|current_page_with_params }}"
tabindex="-1"
aria-disabled="true"
>
<i class="ti ti-chevron-left"></i>
{{ _('prev_page') }}
</a>
</li>
{% with total_page = (total/page_size)|round(0,'ceil')|int,start_page =
(1 if page_num <=3 else page_num - 2 ) %} {% for i in
range(start_page,[start_page + 5,total_page + 1]|min) %}
<li class="page-item {% if i == (page_num or 1) %} active {% endif %}">
<a
class="page-link"
href="{{ {'page_num':i}|current_page_with_params }}"
>{{ i }}</a
>
</li>
{% endfor %}
<li
class="page-item {% if page_num >= total_page %} disabled {% endif %}"
>
<a
class="page-link"
href="{{ {'page_num':page_num + 1}|current_page_with_params }}"
>
{{ _('next_page') }}
<i class="ti ti-chevron-right"></i>
</a>
</li>
{% endwith %}
</ul>
</div>
</div>
</div>
<script>
function onAction(url, method) {
$.ajax({
url: url,
method: method,
success: function () {
location.reload();
},
});
}
function onBulkAction(url, method) {
let ids = $('.checkbox-select-item:checked').map(function () {
return $(this).attr('data-id')
}).get();
if (ids.length > 0) {
console.log(ids)
$.ajax({
url: url + '?ids=' + ids,
method: method,
success: function () {
location.reload();
},
});
}
}
let checkbox = $('#checkbox-select-all');
let bulk_actions = $('#bulk-actions').hide();
checkbox.change(function () {
let checked = checkbox.prop('checked');
$('.checkbox-select-item').prop("checked", checked);
if (checked) {
bulk_actions.show();
} else {
bulk_actions.hide();
}
});
$('.checkbox-select-item').change(function () {
let length = $('.checkbox-select-item:checked').length;
if (length === 0) {
bulk_actions.hide();
} else {
bulk_actions.show();
}
});
</script>
{% endblock %}