From 8ac805adbf76f9282508f87bb8e805a26554002d Mon Sep 17 00:00:00 2001 From: Tom O'Dwyer Date: Thu, 12 Sep 2024 12:49:46 +0100 Subject: [PATCH] Only paginate datatable if per_page is supplied --- airlock/templates/_components/datatable.html | 4 ++-- airlock/templates/activity.html | 2 +- assets/src/scripts/datatable.js | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/airlock/templates/_components/datatable.html b/airlock/templates/_components/datatable.html index 4f1fe401..2acc5d9b 100644 --- a/airlock/templates/_components/datatable.html +++ b/airlock/templates/_components/datatable.html @@ -3,10 +3,10 @@ {{ children }} diff --git a/airlock/templates/activity.html b/airlock/templates/activity.html index a49859fa..313e3f1c 100644 --- a/airlock/templates/activity.html +++ b/airlock/templates/activity.html @@ -3,7 +3,7 @@ {% #card title="Recent activity" class="mt-5" %} {% if activity %} - {% #datatable paging per_page="10" column_filter searchable sortable %} + {% #datatable per_page="10" column_filter searchable sortable %} diff --git a/assets/src/scripts/datatable.js b/assets/src/scripts/datatable.js index 856ad3bc..35204ea3 100644 --- a/assets/src/scripts/datatable.js +++ b/assets/src/scripts/datatable.js @@ -14,14 +14,15 @@ function buildTables() { datatableEls?.forEach((table) => { const columnFilter = table.hasAttribute("data-column-filter"); - const paging = table.hasAttribute("data-paging"); const searchable = table.hasAttribute("data-searchable"); const sortable = table.hasAttribute("data-sortable"); + let paging = false; let perPage = undefined; if (table.hasAttribute("data-per-page")) { const dataPerPage = table.getAttribute("data-per-page"); if (dataPerPage !== null && hasOnlyDigits(dataPerPage)) { + paging = true; perPage = parseInt(dataPerPage); } }