fix(prospecting): add missing pagination computed properties to JS components
Some checks failed
Some checks failed
The pagination() macro expects startIndex, endIndex, pageNumbers, totalPages, nextPage(), and previousPage() to be defined in the Alpine.js component. Added these to scan-jobs.js, prospects.js, and leads.js. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -81,11 +81,47 @@ function leadsList() {
|
|||||||
window.location.href = '/admin/prospecting/prospects/' + lead.id + '#campaigns';
|
window.location.href = '/admin/prospecting/prospects/' + lead.id + '#campaigns';
|
||||||
},
|
},
|
||||||
|
|
||||||
|
get startIndex() {
|
||||||
|
if (this.pagination.total === 0) return 0;
|
||||||
|
return (this.pagination.page - 1) * this.pagination.per_page + 1;
|
||||||
|
},
|
||||||
|
|
||||||
|
get endIndex() {
|
||||||
|
const end = this.pagination.page * this.pagination.per_page;
|
||||||
|
return end > this.pagination.total ? this.pagination.total : end;
|
||||||
|
},
|
||||||
|
|
||||||
|
get totalPages() {
|
||||||
|
return this.pagination.pages;
|
||||||
|
},
|
||||||
|
|
||||||
|
get pageNumbers() {
|
||||||
|
const pages = [];
|
||||||
|
const total = this.totalPages;
|
||||||
|
const current = this.pagination.page;
|
||||||
|
if (total <= 7) { for (let i = 1; i <= total; i++) pages.push(i); return pages; }
|
||||||
|
pages.push(1);
|
||||||
|
if (current > 3) pages.push('...');
|
||||||
|
for (let i = Math.max(2, current - 1); i <= Math.min(total - 1, current + 1); i++) pages.push(i);
|
||||||
|
if (current < total - 2) pages.push('...');
|
||||||
|
pages.push(total);
|
||||||
|
return pages;
|
||||||
|
},
|
||||||
|
|
||||||
goToPage(page) {
|
goToPage(page) {
|
||||||
|
if (page === '...' || page < 1 || page > this.totalPages) return;
|
||||||
this.pagination.page = page;
|
this.pagination.page = page;
|
||||||
this.loadLeads();
|
this.loadLeads();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
nextPage() {
|
||||||
|
if (this.pagination.page < this.totalPages) { this.pagination.page++; this.loadLeads(); }
|
||||||
|
},
|
||||||
|
|
||||||
|
previousPage() {
|
||||||
|
if (this.pagination.page > 1) { this.pagination.page--; this.loadLeads(); }
|
||||||
|
},
|
||||||
|
|
||||||
tierBadgeClass(tier) {
|
tierBadgeClass(tier) {
|
||||||
const classes = {
|
const classes = {
|
||||||
top_priority: 'text-red-700 bg-red-100 dark:text-red-100 dark:bg-red-700',
|
top_priority: 'text-red-700 bg-red-100 dark:text-red-100 dark:bg-red-700',
|
||||||
|
|||||||
@@ -111,11 +111,47 @@ function prospectsList() {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
get startIndex() {
|
||||||
|
if (this.pagination.total === 0) return 0;
|
||||||
|
return (this.pagination.page - 1) * this.pagination.per_page + 1;
|
||||||
|
},
|
||||||
|
|
||||||
|
get endIndex() {
|
||||||
|
const end = this.pagination.page * this.pagination.per_page;
|
||||||
|
return end > this.pagination.total ? this.pagination.total : end;
|
||||||
|
},
|
||||||
|
|
||||||
|
get totalPages() {
|
||||||
|
return this.pagination.pages;
|
||||||
|
},
|
||||||
|
|
||||||
|
get pageNumbers() {
|
||||||
|
const pages = [];
|
||||||
|
const total = this.totalPages;
|
||||||
|
const current = this.pagination.page;
|
||||||
|
if (total <= 7) { for (let i = 1; i <= total; i++) pages.push(i); return pages; }
|
||||||
|
pages.push(1);
|
||||||
|
if (current > 3) pages.push('...');
|
||||||
|
for (let i = Math.max(2, current - 1); i <= Math.min(total - 1, current + 1); i++) pages.push(i);
|
||||||
|
if (current < total - 2) pages.push('...');
|
||||||
|
pages.push(total);
|
||||||
|
return pages;
|
||||||
|
},
|
||||||
|
|
||||||
goToPage(page) {
|
goToPage(page) {
|
||||||
|
if (page === '...' || page < 1 || page > this.totalPages) return;
|
||||||
this.pagination.page = page;
|
this.pagination.page = page;
|
||||||
this.loadProspects();
|
this.loadProspects();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
nextPage() {
|
||||||
|
if (this.pagination.page < this.totalPages) { this.pagination.page++; this.loadProspects(); }
|
||||||
|
},
|
||||||
|
|
||||||
|
previousPage() {
|
||||||
|
if (this.pagination.page > 1) { this.pagination.page--; this.loadProspects(); }
|
||||||
|
},
|
||||||
|
|
||||||
statusBadgeClass(status) {
|
statusBadgeClass(status) {
|
||||||
const classes = {
|
const classes = {
|
||||||
pending: 'text-yellow-700 bg-yellow-100 dark:text-yellow-100 dark:bg-yellow-700',
|
pending: 'text-yellow-700 bg-yellow-100 dark:text-yellow-100 dark:bg-yellow-700',
|
||||||
|
|||||||
@@ -57,11 +57,47 @@ function scanJobs() {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
get startIndex() {
|
||||||
|
if (this.pagination.total === 0) return 0;
|
||||||
|
return (this.pagination.page - 1) * this.pagination.per_page + 1;
|
||||||
|
},
|
||||||
|
|
||||||
|
get endIndex() {
|
||||||
|
const end = this.pagination.page * this.pagination.per_page;
|
||||||
|
return end > this.pagination.total ? this.pagination.total : end;
|
||||||
|
},
|
||||||
|
|
||||||
|
get totalPages() {
|
||||||
|
return this.pagination.pages;
|
||||||
|
},
|
||||||
|
|
||||||
|
get pageNumbers() {
|
||||||
|
const pages = [];
|
||||||
|
const total = this.totalPages;
|
||||||
|
const current = this.pagination.page;
|
||||||
|
if (total <= 7) { for (let i = 1; i <= total; i++) pages.push(i); return pages; }
|
||||||
|
pages.push(1);
|
||||||
|
if (current > 3) pages.push('...');
|
||||||
|
for (let i = Math.max(2, current - 1); i <= Math.min(total - 1, current + 1); i++) pages.push(i);
|
||||||
|
if (current < total - 2) pages.push('...');
|
||||||
|
pages.push(total);
|
||||||
|
return pages;
|
||||||
|
},
|
||||||
|
|
||||||
goToPage(page) {
|
goToPage(page) {
|
||||||
|
if (page === '...' || page < 1 || page > this.totalPages) return;
|
||||||
this.pagination.page = page;
|
this.pagination.page = page;
|
||||||
this.loadJobs();
|
this.loadJobs();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
nextPage() {
|
||||||
|
if (this.pagination.page < this.totalPages) { this.pagination.page++; this.loadJobs(); }
|
||||||
|
},
|
||||||
|
|
||||||
|
previousPage() {
|
||||||
|
if (this.pagination.page > 1) { this.pagination.page--; this.loadJobs(); }
|
||||||
|
},
|
||||||
|
|
||||||
jobStatusClass(status) {
|
jobStatusClass(status) {
|
||||||
const classes = {
|
const classes = {
|
||||||
pending: 'text-yellow-700 bg-yellow-100 dark:text-yellow-100 dark:bg-yellow-700',
|
pending: 'text-yellow-700 bg-yellow-100 dark:text-yellow-100 dark:bg-yellow-700',
|
||||||
|
|||||||
Reference in New Issue
Block a user