From 9a962340b8cd272e8a336b4001d41c581f0a49c3 Mon Sep 17 00:00:00 2001 From: Pinga <121483313+getpinga@users.noreply.github.com> Date: Wed, 19 Feb 2025 10:21:33 +0200 Subject: [PATCH] CP UI pagination fix --- cp/resources/views/partials/js-applications.twig | 9 +++++---- cp/resources/views/partials/js-contacts.twig | 7 ++++--- cp/resources/views/partials/js-domains.twig | 9 +++++---- cp/resources/views/partials/js-hosts.twig | 7 ++++--- cp/resources/views/partials/js-logs.twig | 7 ++++--- cp/resources/views/partials/js-overview.twig | 9 +++++---- cp/resources/views/partials/js-registrars.twig | 7 ++++--- cp/resources/views/partials/js-transactions.twig | 9 +++++---- cp/resources/views/partials/js-users.twig | 7 ++++--- 9 files changed, 40 insertions(+), 31 deletions(-) diff --git a/cp/resources/views/partials/js-applications.twig b/cp/resources/views/partials/js-applications.twig index 63c2dc7..927d824 100644 --- a/cp/resources/views/partials/js-applications.twig +++ b/cp/resources/views/partials/js-applications.twig @@ -132,11 +132,12 @@ }, ajaxResponse: function(url, params, response) { if (response && Array.isArray(response.records) && typeof response.results === 'number') { - var lastPage = Math.ceil(response.results / this.options.paginationSize); + var pageSize = params.size || this.options.paginationSize; + var lastPage = Math.ceil(response.results / pageSize); return { - last_page: lastPage, // Calculated total number of pages - last_row: response.results, // Total number of rows - data: response.records, // Data for the current page + last_page: lastPage, + last_row: response.results, + data: response.records, }; } else { console.error('Unexpected response format', response); diff --git a/cp/resources/views/partials/js-contacts.twig b/cp/resources/views/partials/js-contacts.twig index 7a327e4..a476b82 100644 --- a/cp/resources/views/partials/js-contacts.twig +++ b/cp/resources/views/partials/js-contacts.twig @@ -68,10 +68,11 @@ }, ajaxResponse: function(url, params, response) { if (response && Array.isArray(response.records) && typeof response.results === 'number') { - var lastPage = Math.ceil(response.results / this.options.paginationSize); + var pageSize = params.size || this.options.paginationSize; + var lastPage = Math.ceil(response.results / pageSize); return { - last_page: lastPage, // Calculated total number of pages - data: response.records, // Data for the current page + last_page: lastPage, + data: response.records, }; } else { console.error('Unexpected response format', response); diff --git a/cp/resources/views/partials/js-domains.twig b/cp/resources/views/partials/js-domains.twig index a3f70d7..e82084c 100644 --- a/cp/resources/views/partials/js-domains.twig +++ b/cp/resources/views/partials/js-domains.twig @@ -108,11 +108,12 @@ }, ajaxResponse: function(url, params, response) { if (response && Array.isArray(response.records) && typeof response.results === 'number') { - var lastPage = Math.ceil(response.results / this.options.paginationSize); + var pageSize = params.size || this.options.paginationSize; + var lastPage = Math.ceil(response.results / pageSize); return { - last_page: lastPage, // Calculated total number of pages - last_row: response.results, // Total number of rows - data: response.records, // Data for the current page + last_page: lastPage, + last_row: response.results, + data: response.records, }; } else { console.error('Unexpected response format', response); diff --git a/cp/resources/views/partials/js-hosts.twig b/cp/resources/views/partials/js-hosts.twig index daf0cd5..e086d3c 100644 --- a/cp/resources/views/partials/js-hosts.twig +++ b/cp/resources/views/partials/js-hosts.twig @@ -67,10 +67,11 @@ }, ajaxResponse: function(url, params, response) { if (response && Array.isArray(response.records) && typeof response.results === 'number') { - var lastPage = Math.ceil(response.results / this.options.paginationSize); + var pageSize = params.size || this.options.paginationSize; + var lastPage = Math.ceil(response.results / pageSize); return { - last_page: lastPage, // Calculated total number of pages - data: response.records, // Data for the current page + last_page: lastPage, + data: response.records, }; } else { console.error('Unexpected response format', response); diff --git a/cp/resources/views/partials/js-logs.twig b/cp/resources/views/partials/js-logs.twig index 499c65f..47ab9fe 100644 --- a/cp/resources/views/partials/js-logs.twig +++ b/cp/resources/views/partials/js-logs.twig @@ -87,10 +87,11 @@ }, ajaxResponse: function(url, params, response) { if (response && Array.isArray(response.records) && typeof response.results === 'number') { - var lastPage = Math.ceil(response.results / this.options.paginationSize); + var pageSize = params.size || this.options.paginationSize; + var lastPage = Math.ceil(response.results / pageSize); return { - last_page: lastPage, // Calculated total number of pages - data: response.records, // Data for the current page + last_page: lastPage, + data: response.records, }; } else { console.error('Unexpected response format', response); diff --git a/cp/resources/views/partials/js-overview.twig b/cp/resources/views/partials/js-overview.twig index 3bc205f..6c859fa 100644 --- a/cp/resources/views/partials/js-overview.twig +++ b/cp/resources/views/partials/js-overview.twig @@ -57,11 +57,12 @@ }, ajaxResponse: function(url, params, response) { if (response && Array.isArray(response.records) && typeof response.results === 'number') { - var lastPage = Math.ceil(response.results / this.options.paginationSize); + var pageSize = params.size || this.options.paginationSize; + var lastPage = Math.ceil(response.results / pageSize); return { - last_page: lastPage, // Calculated total number of pages - last_row: response.results, // Total number of rows - data: response.records, // Data for the current page + last_page: lastPage, + last_row: response.results, + data: response.records, }; } else { console.error('Unexpected response format', response); diff --git a/cp/resources/views/partials/js-registrars.twig b/cp/resources/views/partials/js-registrars.twig index 3a17fbf..c409e1b 100644 --- a/cp/resources/views/partials/js-registrars.twig +++ b/cp/resources/views/partials/js-registrars.twig @@ -74,10 +74,11 @@ }, ajaxResponse: function(url, params, response) { if (response && Array.isArray(response.records) && typeof response.results === 'number') { - var lastPage = Math.ceil(response.results / this.options.paginationSize); + var pageSize = params.size || this.options.paginationSize; + var lastPage = Math.ceil(response.results / pageSize); return { - last_page: lastPage, // Calculated total number of pages - data: response.records, // Data for the current page + last_page: lastPage, + data: response.records, }; } else { console.error('Unexpected response format', response); diff --git a/cp/resources/views/partials/js-transactions.twig b/cp/resources/views/partials/js-transactions.twig index 54d32e4..99d2305 100644 --- a/cp/resources/views/partials/js-transactions.twig +++ b/cp/resources/views/partials/js-transactions.twig @@ -61,11 +61,12 @@ }, ajaxResponse: function(url, params, response) { if (response && Array.isArray(response.records) && typeof response.results === 'number') { - var lastPage = Math.ceil(response.results / this.options.paginationSize); + var pageSize = params.size || this.options.paginationSize; + var lastPage = Math.ceil(response.results / pageSize); return { - last_page: lastPage, // Calculated total number of pages - last_row: response.results, // Total number of rows - data: response.records, // Data for the current page + last_page: lastPage, + last_row: response.results, + data: response.records, }; } else { console.error('Unexpected response format', response); diff --git a/cp/resources/views/partials/js-users.twig b/cp/resources/views/partials/js-users.twig index 4c9cc93..410a0f1 100644 --- a/cp/resources/views/partials/js-users.twig +++ b/cp/resources/views/partials/js-users.twig @@ -149,10 +149,11 @@ }, ajaxResponse: function(url, params, response) { if (response && Array.isArray(response.records) && typeof response.results === 'number') { - var lastPage = Math.ceil(response.results / this.options.paginationSize); + var pageSize = params.size || this.options.paginationSize; + var lastPage = Math.ceil(response.results / pageSize); return { - last_page: lastPage, // Calculated total number of pages - data: response.records, // Data for the current page + last_page: lastPage, + data: response.records, }; } else { console.error('Unexpected response format', response);