mirror of
https://github.com/LD-Reborn/Berufsschule_HAM.git
synced 2025-12-20 06:51:55 +00:00
Added location dropdown selection for Assets view
This commit is contained in:
@@ -37,4 +37,10 @@
|
||||
<data name="Login" xml:space="preserve">
|
||||
<value>Anmelden</value>
|
||||
</data>
|
||||
<data name="Select location" xml:space="preserve">
|
||||
<value>Ort auswählen</value>
|
||||
</data>
|
||||
<data name="Error loading locations" xml:space="preserve">
|
||||
<value>Fehler beim Laden der Orte</value>
|
||||
</data>
|
||||
</root>
|
||||
|
||||
@@ -171,7 +171,9 @@
|
||||
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">@T["Location"]</label>
|
||||
<input type="text" class="form-control" name="Location" />
|
||||
<select class="form-select" name="Location" id="createLocationSelect">
|
||||
<option value="">@T["Select location"]</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">@T["Owner"]</label>
|
||||
@@ -373,7 +375,6 @@
|
||||
<form id="updateAssetForm">
|
||||
<div class="modal-body">
|
||||
<div class="row g-3">
|
||||
<!-- Same fields as in Create -->
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">@T["Name"]</label>
|
||||
<input type="text" class="form-control" name="Name" />
|
||||
@@ -381,7 +382,9 @@
|
||||
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">@T["Location"]</label>
|
||||
<input type="text" class="form-control" name="Location" />
|
||||
<select class="form-select" name="Location" id="updateLocationSelect">
|
||||
<option value="">@T["Select location"]</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">@T["Owner"]</label>
|
||||
@@ -482,7 +485,8 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
|
||||
updateAttributesContainer.innerHTML = '';
|
||||
updateForm.reset();
|
||||
|
||||
const locationSelect = updateForm.querySelector('#updateLocationSelect');
|
||||
await loadLocationsIntoSelect(locationSelect);
|
||||
try {
|
||||
const response = await fetch(`/Assets/Get?cn=${assetId}`);
|
||||
const responseJson = await response.json();
|
||||
@@ -754,6 +758,15 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const createModal = document.getElementById('createAssetModal');
|
||||
createModal.addEventListener('show.bs.modal', async () => {
|
||||
const select = createModal.querySelector('#createLocationSelect');
|
||||
await loadLocationsIntoSelect(select);
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<partial name="_Batch"/>
|
||||
@@ -17,6 +17,12 @@
|
||||
<link rel="preload" href="~/css/site.css" as="style" onload="this.onload=null;this.rel='stylesheet'">
|
||||
<noscript><link rel="stylesheet" href="~/css/site.css"></noscript>
|
||||
<link rel="stylesheet" href="~/Berufsschule_HAM.styles.css" asp-append-version="true" />
|
||||
<script>
|
||||
window.appTranslations = {
|
||||
selectLocation: '@T["Select location"]',
|
||||
errorLoading: '@T["Error loading locations"]'
|
||||
};
|
||||
</script>
|
||||
</head>
|
||||
<body data-bs-theme="dark">
|
||||
<script>
|
||||
|
||||
@@ -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