adding developer tools in admin panel, adding vendor management
This commit is contained in:
@@ -18,8 +18,10 @@ function adminVendors() {
|
||||
// Inherit base layout functionality from init-alpine.js
|
||||
...data(),
|
||||
|
||||
// Vendors page specific state
|
||||
// ✅ CRITICAL: Page identifier for sidebar active state
|
||||
currentPage: 'vendors',
|
||||
|
||||
// Vendors page specific state
|
||||
vendors: [],
|
||||
stats: {
|
||||
total: 0,
|
||||
@@ -30,8 +32,8 @@ function adminVendors() {
|
||||
loading: false,
|
||||
error: null,
|
||||
|
||||
// Pagination state
|
||||
currentPage: 1,
|
||||
// Pagination state (renamed from currentPage to avoid conflict)
|
||||
page: 1, // ✅ FIXED: Was 'currentPage' which conflicted with sidebar
|
||||
itemsPerPage: 10,
|
||||
|
||||
// Initialize
|
||||
@@ -53,7 +55,7 @@ function adminVendors() {
|
||||
|
||||
// Computed: Get paginated vendors for current page
|
||||
get paginatedVendors() {
|
||||
const start = (this.currentPage - 1) * this.itemsPerPage;
|
||||
const start = (this.page - 1) * this.itemsPerPage;
|
||||
const end = start + this.itemsPerPage;
|
||||
return this.vendors.slice(start, end);
|
||||
},
|
||||
@@ -66,12 +68,12 @@ function adminVendors() {
|
||||
// Computed: Start index for pagination display
|
||||
get startIndex() {
|
||||
if (this.vendors.length === 0) return 0;
|
||||
return (this.currentPage - 1) * this.itemsPerPage + 1;
|
||||
return (this.page - 1) * this.itemsPerPage + 1;
|
||||
},
|
||||
|
||||
// Computed: End index for pagination display
|
||||
get endIndex() {
|
||||
const end = this.currentPage * this.itemsPerPage;
|
||||
const end = this.page * this.itemsPerPage;
|
||||
return end > this.vendors.length ? this.vendors.length : end;
|
||||
},
|
||||
|
||||
@@ -79,7 +81,7 @@ function adminVendors() {
|
||||
get pageNumbers() {
|
||||
const pages = [];
|
||||
const totalPages = this.totalPages;
|
||||
const current = this.currentPage;
|
||||
const current = this.page;
|
||||
|
||||
if (totalPages <= 7) {
|
||||
// Show all pages if 7 or fewer
|
||||
@@ -137,7 +139,7 @@ function adminVendors() {
|
||||
}
|
||||
|
||||
// Reset to first page when data is loaded
|
||||
this.currentPage = 1;
|
||||
this.page = 1;
|
||||
|
||||
} catch (error) {
|
||||
vendorsLog.error('Failed to load vendors:', error);
|
||||
@@ -167,27 +169,27 @@ function adminVendors() {
|
||||
},
|
||||
|
||||
// Pagination: Go to specific page
|
||||
goToPage(page) {
|
||||
if (page === '...' || page < 1 || page > this.totalPages) {
|
||||
goToPage(pageNum) {
|
||||
if (pageNum === '...' || pageNum < 1 || pageNum > this.totalPages) {
|
||||
return;
|
||||
}
|
||||
vendorsLog.info('Going to page:', page);
|
||||
this.currentPage = page;
|
||||
vendorsLog.info('Going to page:', pageNum);
|
||||
this.page = pageNum;
|
||||
},
|
||||
|
||||
// Pagination: Go to next page
|
||||
nextPage() {
|
||||
if (this.currentPage < this.totalPages) {
|
||||
if (this.page < this.totalPages) {
|
||||
vendorsLog.info('Going to next page');
|
||||
this.currentPage++;
|
||||
this.page++;
|
||||
}
|
||||
},
|
||||
|
||||
// Pagination: Go to previous page
|
||||
previousPage() {
|
||||
if (this.currentPage > 1) {
|
||||
if (this.page > 1) {
|
||||
vendorsLog.info('Going to previous page');
|
||||
this.currentPage--;
|
||||
this.page--;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user