0001-wcs-add-pagination-for-current-forms-drafts-cells-10.patch
combo/apps/wcs/templates/combo/wcs/current_drafts.html | ||
---|---|---|
17 | 17 |
{% endif %} |
18 | 18 |
</div> |
19 | 19 |
{% endfor %} |
20 |
{% include "combo/pagination.html" %} |
|
20 | 21 |
{% endblock %} |
combo/apps/wcs/templates/combo/wcs/current_forms.html | ||
---|---|---|
6 | 6 |
{% include "combo/wcs/list_of_forms.html" with forms=forms %} |
7 | 7 |
</div> |
8 | 8 |
{% endfor %} |
9 |
{% include "combo/pagination.html" %} |
|
9 | 10 |
{% endblock %} |
combo/apps/wcs/templates/combo/wcs/user_all_forms.html | ||
---|---|---|
6 | 6 |
{% include "combo/wcs/list_of_forms.html" with forms=forms %} |
7 | 7 |
</div> |
8 | 8 |
{% endfor %} |
9 |
{% include "combo/pagination.html" %} |
|
9 | 10 |
{% endblock %} |
combo/apps/wcs/templates/combo/wcs/user_done_forms.html | ||
---|---|---|
6 | 6 |
{% include "combo/wcs/list_of_forms.html" with forms=forms %} |
7 | 7 |
</div> |
8 | 8 |
{% endfor %} |
9 |
{% include "combo/pagination.html" %} |
|
9 | 10 |
{% endblock %} |
combo/public/static/js/combo.public.js | ||
---|---|---|
275 | 275 |
return false; |
276 | 276 |
}); |
277 | 277 | |
278 |
// pagination in cells with list of items |
|
279 |
$(document).on('combo:cell-loaded', function(ev, cell) { |
|
280 |
var $pagination = $(cell).find('.cell-items-pagination'); |
|
281 |
if ($pagination.length == 0) return; |
|
282 |
var page_index = 0; |
|
283 |
var paginate_by = parseInt($pagination.data('paginate-by')); |
|
284 |
// Get all <li> inside the same div as us, ignoring whether they are part of |
|
285 |
// different <ul> |
|
286 |
var items = $pagination.parent().find('li'); |
|
287 |
var max_page_index = Math.ceil(items.length / paginate_by); |
|
288 |
if (items.length < paginate_by) { |
|
289 |
return; |
|
290 |
} |
|
291 | ||
292 |
function update_page(step) { |
|
293 |
page_index = page_index + step; |
|
294 |
if (page_index == 0) { |
|
295 |
$pagination.find('.cell-items-pagination-prev').prop('disabled', true); |
|
296 |
} else { |
|
297 |
$pagination.find('.cell-items-pagination-prev').prop('disabled', null); |
|
298 |
} |
|
299 |
if (page_index == max_page_index - 1) { |
|
300 |
$pagination.find('.cell-items-pagination-next').prop('disabled', true); |
|
301 |
} else { |
|
302 |
$pagination.find('.cell-items-pagination-next').prop('disabled', null); |
|
303 |
} |
|
304 |
start_item = paginate_by * page_index; |
|
305 |
items.hide(); |
|
306 |
items.slice(start_item, start_item + paginate_by).show(); |
|
307 |
}; |
|
308 | ||
309 |
$pagination.find('.cell-items-pagination-prev').click(function() { update_page(-1); }); |
|
310 |
$pagination.find('.cell-items-pagination-next').click(function() { update_page(1); }); |
|
311 |
update_page(0); |
|
312 |
$pagination.show(); |
|
313 |
}); |
|
314 |
$('.cell-items-pagination').each(function(idx, elem) { |
|
315 |
$(document).trigger('combo:cell-loaded', $(elem).parents('.cell').first()); |
|
316 |
}); |
|
278 | 317 |
}); |
combo/public/templates/combo/pagination.html | ||
---|---|---|
1 |
{% load static %} |
|
2 |
<div class="cell-items-pagination" data-paginate-by="10" hidden> |
|
3 |
<button class="cell-items-pagination-prev" disabled>←</a> |
|
4 |
<button class="cell-items-pagination-next" disabled>→</a> |
|
5 |
</div> |
|
0 |
- |