mirror of
https://github.com/LD-Reborn/Berufsschule_HAM.git
synced 2025-12-20 15:01:56 +00:00
Added location dropdown selection for Assets view
This commit is contained in:
@@ -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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user