fix(admin): empty DataTables listings no longer error; their message becomes emptyTable

docs: JPEG XL optimizer plan and image-input rule
This commit is contained in:
andre committed 2026-10-26 10:13:29 +00:00
1 parent cc677af92d
commit 1eb2a61031
2 files changed
+16 -1

No files matched your search

+11 -1
View File
@@ -46,8 +46,18 @@ function initDataTable(selector, opts) {
if (!window.jQuery || !jQuery.fn || !jQuery.fn.DataTable) return null;
var $table = jQuery(selector);
if (!$table.length) return null;
// Listagem vazia: as páginas desenham uma única linha <td colspan> com a
// mensagem, que a DataTables rejeita (nº de colunas errado → erro). Tira-se
// a linha e a mensagem dela (com links) passa a ser o emptyTable.
var language = DATATABLES_PT_PT;
var $rows = $table.find('tbody > tr');
var $only = $rows.length === 1 ? $rows.children('td[colspan]') : jQuery();
if ($only.length === 1 && $rows.children().length === 1) {
language = jQuery.extend({}, DATATABLES_PT_PT, { emptyTable: $only.html() });
$rows.remove();
}
return $table.DataTable(jQuery.extend(true, {
language: DATATABLES_PT_PT,
language: language,
pageLength: 25,
lengthMenu: [[10, 25, 50, -1], [10, 25, 50, 'Todos']],
responsive: true,