Added location dropdown selection for Assets view

This commit is contained in:
2025-10-26 09:06:59 +01:00
parent c47d7f2dae
commit 2e8aee2181
4 changed files with 53 additions and 4 deletions

View File

@@ -116,3 +116,27 @@ document.addEventListener('DOMContentLoaded', () => {
});
});
});
async function loadLocationsIntoSelect(selectElement, selectedValue = null) {
try {
const response = await fetch('/Locations/Index');
const locations = await response.json();
selectElement.innerHTML = `<option value="">${appTranslations.selectLocation}</option>`;
locations.forEach(loc => {
const text = `${loc.description.Location}, Room ${loc.description.RoomNumber}, Seat ${loc.description.Seat}`;
const option = document.createElement('option');
option.value = loc.location;
option.textContent = text;
if (selectedValue && selectedValue === loc.location) {
option.selected = true;
}
selectElement.appendChild(option);
});
} catch (err) {
console.error('Error loading locations:', err);
showToast(appTranslations.errorLoading, 'danger');
}
}