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
@@ -25,7 +25,10 @@ if (isset($_GET['csv'])) {
|
||||
|
||||
$page_title = 'Horário de Funcionamento';
|
||||
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') ?>
|
||||
<?php
|
||||
$dias = ['segunda'=>'Segunda','terça'=>'Terça','quarta'=>'Quarta','quinta'=>'Quinta','sexta'=>'Sexta','sabado'=>'Sábado','domingo'=>'Domingo','feriados'=>'Feriados'];
|
||||
?>
|
||||
<div class="container">
|
||||
@@ -39,7 +42,7 @@ $dias = ['segunda'=>'Segunda','terça'=>'Terça','quarta'=>'Quarta','quinta'=>'Q
|
||||
|
||||
<div class="card shadow-sm"><div class="card-body p-0">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover align-middle mb-0">
|
||||
<table class="table table-hover align-middle mb-0" id="workHoursTable">
|
||||
<thead class="table-light"><tr>
|
||||
<th>Dia</th><th>Abertura</th><th>Fecho</th><th style="width:120px">Ações</th>
|
||||
</tr></thead>
|
||||
@@ -63,4 +66,24 @@ $dias = ['segunda'=>'Segunda','terça'=>'Terça','quarta'=>'Quarta','quinta'=>'Q
|
||||
</div>
|
||||
</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('#workHoursTable', { columnDefs: [{ targets: 3, 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