diff --git a/app/templates/admin/code-quality-violations.html b/app/templates/admin/code-quality-violations.html index 24643a97..c9f48707 100644 --- a/app/templates/admin/code-quality-violations.html +++ b/app/templates/admin/code-quality-violations.html @@ -194,34 +194,64 @@ - -
-
-
- - Showing - - of - - results - -
-
- - - Page of - - -
-
+ +
+ + + Showing - of + + + + + + +
{% endblock %} diff --git a/static/admin/js/code-quality-violations.js b/static/admin/js/code-quality-violations.js index fa190bec..438a41a8 100644 --- a/static/admin/js/code-quality-violations.js +++ b/static/admin/js/code-quality-violations.js @@ -96,6 +96,61 @@ function codeQualityViolations() { } }, + // Computed: Total number of pages + get totalPages() { + return this.pagination.total_pages; + }, + + // Computed: Start index for pagination display + get startIndex() { + if (this.pagination.total === 0) return 0; + return (this.pagination.page - 1) * this.pagination.page_size + 1; + }, + + // Computed: End index for pagination display + get endIndex() { + const end = this.pagination.page * this.pagination.page_size; + return end > this.pagination.total ? this.pagination.total : end; + }, + + // Computed: Generate page numbers array with ellipsis + get pageNumbers() { + const pages = []; + const totalPages = this.totalPages; + const current = this.pagination.page; + + if (totalPages <= 7) { + // Show all pages if 7 or fewer + for (let i = 1; i <= totalPages; i++) { + pages.push(i); + } + } else { + // Always show first page + pages.push(1); + + if (current > 3) { + pages.push('...'); + } + + // Show pages around current page + const start = Math.max(2, current - 1); + const end = Math.min(totalPages - 1, current + 1); + + for (let i = start; i <= end; i++) { + pages.push(i); + } + + if (current < totalPages - 2) { + pages.push('...'); + } + + // Always show last page + pages.push(totalPages); + } + + return pages; + }, + async previousPage() { if (this.pagination.page > 1) { this.pagination.page--; @@ -103,6 +158,13 @@ function codeQualityViolations() { } }, + goToPage(pageNum) { + if (pageNum !== '...' && pageNum >= 1 && pageNum <= this.totalPages) { + this.pagination.page = pageNum; + this.loadViolations(); + } + }, + updateURL() { const params = new URLSearchParams();