feat(backoffice): DataTables cliente-only nas 11 listagens com CSV
Fecha o item 6.9 da auditoria (sem server-side/AJAX — todas as tabelas estão bem abaixo de 60 linhas): ordenação, pesquisa, paginação, pt-PT e Responsive (colapso em ecrãs estreitos), reaproveitando o botão "Exportar CSV" já existente. DataTables 2.3.4 + Responsive 3.0.6 vendorizados em assets/vendor/datatables-2.3.4/ (mesma versão/decisão do hub.andmore.pt), nunca de CDN. Tradução pt-PT oficial inline em assets/js/datatables-init.js, que expõe initDataTable(selector, opts) — cada página dá um id estável à tabela e marca a coluna de Ações como orderable:false/searchable:false. Os vendor scripts só carregam nas 10 páginas que os usam (injeção dinâmica depois do DOMContentLoaded, como o loader do Summernote), não no header/footer partilhado. views/admin/trials/index.php ficou de fora de propósito: cada linha tem um <select> de estado e um <textarea> de notas editados in-line antes de "Guardar" — um redraw da DataTable a meio dessa edição (ordenar, paginar) arrisca perder ou baralhar o que ainda não foi submetido. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4222b8f2e0
commit
b1e88781b8
18 files changed
+342
-12
No files matched your search
@@ -31,6 +31,8 @@ $new_leads = db_membership_leads_count_new($pdo);
|
||||
$page_title = 'Mensalidades';
|
||||
include __DIR__ . '/../../../includes/header.php';
|
||||
?>
|
||||
<?= link_tag('assets/vendor/datatables-2.3.4/dataTables.bootstrap5.min.css') ?>
|
||||
<?= link_tag('assets/vendor/datatables-2.3.4/responsive.bootstrap5.min.css') ?>
|
||||
<div class="container">
|
||||
<div class="d-flex justify-content-between align-items-center flex-wrap gap-2 mb-4">
|
||||
<h1 class="h3 mb-0">Mensalidades</h1>
|
||||
@@ -46,7 +48,7 @@ include __DIR__ . '/../../../includes/header.php';
|
||||
<div class="card shadow-sm"><div class="card-body p-0">
|
||||
<form method="POST" class="mb-0"><?= csrf_field() ?>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover align-middle mb-0">
|
||||
<table class="table table-hover align-middle mb-0" id="membershipsTable">
|
||||
<thead class="table-light"><tr>
|
||||
<th>Nome</th><th>Preço</th><th>Estado</th><th>Ordem</th><th style="width:120px">Ações</th>
|
||||
</tr></thead>
|
||||
@@ -79,4 +81,24 @@ include __DIR__ . '/../../../includes/header.php';
|
||||
</form>
|
||||
</div></div>
|
||||
</div>
|
||||
<script>
|
||||
window.DT_SRC = [
|
||||
<?= json_encode(_asset_versioned('assets/vendor/datatables-2.3.4/dataTables.min.js')) ?>,
|
||||
<?= json_encode(_asset_versioned('assets/vendor/datatables-2.3.4/dataTables.bootstrap5.min.js')) ?>,
|
||||
<?= json_encode(_asset_versioned('assets/vendor/datatables-2.3.4/dataTables.responsive.min.js')) ?>,
|
||||
<?= json_encode(_asset_versioned('assets/vendor/datatables-2.3.4/responsive.bootstrap5.min.js')) ?>,
|
||||
<?= json_encode(_asset_versioned('assets/js/datatables-init.js')) ?>
|
||||
];
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
(function next(i) {
|
||||
if (i >= window.DT_SRC.length) {
|
||||
return initDataTable('#membershipsTable', { columnDefs: [{ targets: 4, orderable: false, searchable: false }] });
|
||||
}
|
||||
var s = document.createElement('script');
|
||||
s.src = window.DT_SRC[i];
|
||||
s.onload = function () { next(i + 1); };
|
||||
document.body.appendChild(s);
|
||||
})(0);
|
||||
});
|
||||
</script>
|
||||
<?php include __DIR__ . '/../../../includes/footer.php';
|
||||
Reference in new issue
Block a user