feat: possibilità di ingrandire gli elenchi delle pagine dashbaord, ticket e ticket a mio carico
This commit is contained in:
@@ -19,6 +19,16 @@ const TicketListView = {
|
||||
// Fetch lookups for filter dropdowns
|
||||
await App.ensureLookups();
|
||||
|
||||
// Fetch agent settings for tickets_per_page
|
||||
try {
|
||||
const settings = await App.api('/api/dashboard/settings');
|
||||
if (settings && settings.tickets_per_page) {
|
||||
this.perPage = settings.tickets_per_page;
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn('Failed to load agent settings:', err);
|
||||
}
|
||||
|
||||
// Build query params
|
||||
const isMyTickets = window.location.hash.startsWith('#/tickets/my');
|
||||
Filters.currentMode = isMyTickets ? 'my' : 'general';
|
||||
@@ -168,6 +178,19 @@ const TicketListView = {
|
||||
|
||||
renderPagination(page, per_page, total, total_pages, isTop) {
|
||||
const marginStyle = isTop ? 'margin-bottom: var(--space-md); margin-top: 0;' : 'margin-top: var(--space-md); margin-bottom: 0;';
|
||||
const limitSelectHtml = `
|
||||
<div style="display:inline-flex; align-items:center; gap:var(--space-xs); font-size:0.8rem; color:var(--text-secondary); margin-right:var(--space-md);">
|
||||
<span>Righe:</span>
|
||||
<select class="form-select ticket-per-page-select" style="padding: 2px 24px 2px 6px; font-size: 0.75rem; height: 26px; min-width: 65px; margin: 0; background-position: right 6px center; border-color: var(--border-light);">
|
||||
<option value="10" ${per_page === 10 ? 'selected' : ''}>10</option>
|
||||
<option value="20" ${per_page === 20 ? 'selected' : ''}>20</option>
|
||||
<option value="50" ${per_page === 50 ? 'selected' : ''}>50</option>
|
||||
<option value="100" ${per_page === 100 ? 'selected' : ''}>100</option>
|
||||
<option value="200" ${per_page === 200 ? 'selected' : ''}>200</option>
|
||||
</select>
|
||||
</div>
|
||||
`;
|
||||
|
||||
if (total_pages > 1) {
|
||||
return `
|
||||
<div class="pagination" style="${marginStyle}">
|
||||
@@ -175,6 +198,7 @@ const TicketListView = {
|
||||
Mostrando ${((page - 1) * per_page) + 1}–${Math.min(page * per_page, total)} di ${total} ticket
|
||||
</div>
|
||||
<div class="pagination-controls">
|
||||
${limitSelectHtml}
|
||||
<button class="pagination-btn" data-page="1" ${page <= 1 ? 'disabled' : ''}>«</button>
|
||||
<button class="pagination-btn" data-page="${page - 1}" ${page <= 1 ? 'disabled' : ''}>‹</button>
|
||||
${this.renderPageButtons(page, total_pages)}
|
||||
@@ -187,7 +211,9 @@ const TicketListView = {
|
||||
return `
|
||||
<div class="pagination" style="${marginStyle}">
|
||||
<div class="pagination-info">${total} ticket totali</div>
|
||||
<div></div>
|
||||
<div class="pagination-controls">
|
||||
${limitSelectHtml}
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
@@ -400,6 +426,25 @@ const TicketListView = {
|
||||
this.render();
|
||||
});
|
||||
});
|
||||
|
||||
// Page size change
|
||||
document.querySelectorAll('.ticket-per-page-select').forEach(select => {
|
||||
select.addEventListener('change', async () => {
|
||||
const newLimit = parseInt(select.value, 10);
|
||||
try {
|
||||
await App.api('/api/dashboard/settings', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ tickets_per_page: newLimit }),
|
||||
});
|
||||
Toast.success(`Righe per pagina aggiornate a ${newLimit}!`);
|
||||
this.perPage = newLimit;
|
||||
this.currentPage = 1;
|
||||
this.render();
|
||||
} catch (err) {
|
||||
Toast.error('Errore durante il salvataggio dell\'impostazione: ' + err.message);
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
updateBatchBar() {
|
||||
|
||||
Reference in New Issue
Block a user