feat: aggiunti: loggica random, tema scuro, correzioni mail, miglioramenti generali, cache;
This commit is contained in:
@@ -59,7 +59,7 @@ function renderOffices() {
|
||||
const tbody = document.getElementById('officesBody');
|
||||
|
||||
if (offices.length === 0) {
|
||||
tbody.innerHTML = '<tr><td colspan="5" class="text-center">Nessun ufficio trovato</td></tr>';
|
||||
tbody.innerHTML = '<tr><td colspan="5" class="text-center">Nessun gruppo trovato</td></tr>';
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ function renderOffices() {
|
||||
<td>${office.user_count || 0} utenti</td>
|
||||
<td>
|
||||
<button class="btn btn-sm btn-secondary" onclick="editOffice('${office.id}')">Modifica</button>
|
||||
<button class="btn btn-sm btn-danger" onclick="deleteOffice('${office.id}')" ${office.user_count > 0 ? 'title="Impossibile eliminare uffici con utenti" disabled' : ''}>Elimina</button>
|
||||
<button class="btn btn-sm btn-danger" onclick="deleteOffice('${office.id}')" ${office.user_count > 0 ? 'title="Impossibile eliminare gruppi con utenti" disabled' : ''}>Elimina</button>
|
||||
</td>
|
||||
</tr>
|
||||
`;
|
||||
@@ -103,30 +103,30 @@ async function editOffice(officeId) {
|
||||
document.getElementById('officeCutoffHour').value = office.booking_window_end_hour != null ? office.booking_window_end_hour : 18;
|
||||
document.getElementById('officeCutoffMinute').value = office.booking_window_end_minute != null ? office.booking_window_end_minute : 0;
|
||||
|
||||
openModal('Modifica Ufficio');
|
||||
openModal('Modifica Gruppo');
|
||||
}
|
||||
|
||||
async function deleteOffice(officeId) {
|
||||
const office = offices.find(o => o.id === officeId);
|
||||
if (!office) return;
|
||||
|
||||
if (!confirm(`Eliminare l'ufficio "${office.name}"?`)) return;
|
||||
if (!confirm(`Eliminare il gruppo "${office.name}"?`)) return;
|
||||
|
||||
const response = await api.delete(`/api/offices/${officeId}`);
|
||||
if (response && response.ok) {
|
||||
utils.showMessage('Ufficio eliminato', 'success');
|
||||
utils.showMessage('Gruppo eliminato', 'success');
|
||||
api.invalidateCache('/api/offices'); // Clear cache
|
||||
await loadOffices();
|
||||
} else {
|
||||
const error = await response.json();
|
||||
utils.showMessage(error.detail || 'Impossibile eliminare l\'ufficio', 'error');
|
||||
utils.showMessage(error.detail || 'Impossibile eliminare il gruppo', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
function setupEventListeners() {
|
||||
// Add button
|
||||
document.getElementById('addOfficeBtn').addEventListener('click', () => {
|
||||
openModal('Nuovo Ufficio');
|
||||
openModal('Nuovo Gruppo');
|
||||
});
|
||||
|
||||
// Modal close
|
||||
@@ -177,7 +177,7 @@ async function handleOfficeSubmit(e) {
|
||||
|
||||
if (response && response.ok) {
|
||||
closeModal();
|
||||
utils.showMessage(officeId ? 'Ufficio aggiornato' : 'Ufficio creato', 'success');
|
||||
utils.showMessage(officeId ? 'Gruppo aggiornato' : 'Gruppo creato', 'success');
|
||||
api.invalidateCache('/api/offices'); // Clear cache
|
||||
await loadOffices();
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user