diff --git a/src/main/resources/templates/activities/list.html b/src/main/resources/templates/activities/list.html index 3916428..fd22b60 100644 --- a/src/main/resources/templates/activities/list.html +++ b/src/main/resources/templates/activities/list.html @@ -97,7 +97,9 @@ const emptyState = document.getElementById('emptyState'); const pagination = document.getElementById('pagination'); - let currentPage = 0; + const pageFromUrl = new URLSearchParams(window.location.search).get('page') || 1; + // Page in URL query parameter is 1-based + let currentPage = pageFromUrl - 1; let totalPages = 0; let activityToDelete = null; @@ -212,10 +214,10 @@ const paginationList = document.getElementById('paginationList'); let html = ''; - // Previous button + // Previous button (data.number + 1 - 1, data.number is 0-based) html += `
  • - +
  • @@ -232,7 +234,7 @@ for (let i = startPage; i <= endPage; i++) { html += `
  • - ${i + 1} + ${i + 1}
  • `; } @@ -241,10 +243,10 @@ html += `
  • ...
  • `; } - // Next button + // Next button (data.number + 1 + 1, data.number is 0-based) html += `
  • - +
  • @@ -254,11 +256,6 @@ } // Global functions for pagination and delete - window.changePage = function(page) { - loadActivities(page); - window.scrollTo({ top: 0, behavior: 'smooth' }); - }; - window.confirmDelete = function(activityId) { activityToDelete = activityId; const modal = new bootstrap.Modal(document.getElementById('deleteModal'));