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">
|
<data name="Login" xml:space="preserve">
|
||||||
<value>Anmelden</value>
|
<value>Anmelden</value>
|
||||||
</data>
|
</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>
|
</root>
|
||||||
|
|||||||
@@ -171,7 +171,9 @@
|
|||||||
|
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<label class="form-label">@T["Location"]</label>
|
<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>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<label class="form-label">@T["Owner"]</label>
|
<label class="form-label">@T["Owner"]</label>
|
||||||
@@ -373,7 +375,6 @@
|
|||||||
<form id="updateAssetForm">
|
<form id="updateAssetForm">
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<div class="row g-3">
|
<div class="row g-3">
|
||||||
<!-- Same fields as in Create -->
|
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<label class="form-label">@T["Name"]</label>
|
<label class="form-label">@T["Name"]</label>
|
||||||
<input type="text" class="form-control" name="Name" />
|
<input type="text" class="form-control" name="Name" />
|
||||||
@@ -381,7 +382,9 @@
|
|||||||
|
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<label class="form-label">@T["Location"]</label>
|
<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>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<label class="form-label">@T["Owner"]</label>
|
<label class="form-label">@T["Owner"]</label>
|
||||||
@@ -482,7 +485,8 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
|
|
||||||
updateAttributesContainer.innerHTML = '';
|
updateAttributesContainer.innerHTML = '';
|
||||||
updateForm.reset();
|
updateForm.reset();
|
||||||
|
const locationSelect = updateForm.querySelector('#updateLocationSelect');
|
||||||
|
await loadLocationsIntoSelect(locationSelect);
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`/Assets/Get?cn=${assetId}`);
|
const response = await fetch(`/Assets/Get?cn=${assetId}`);
|
||||||
const responseJson = await response.json();
|
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>
|
</script>
|
||||||
|
|
||||||
<partial name="_Batch"/>
|
<partial name="_Batch"/>
|
||||||
@@ -17,6 +17,12 @@
|
|||||||
<link rel="preload" href="~/css/site.css" as="style" onload="this.onload=null;this.rel='stylesheet'">
|
<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>
|
<noscript><link rel="stylesheet" href="~/css/site.css"></noscript>
|
||||||
<link rel="stylesheet" href="~/Berufsschule_HAM.styles.css" asp-append-version="true" />
|
<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>
|
</head>
|
||||||
<body data-bs-theme="dark">
|
<body data-bs-theme="dark">
|
||||||
<script>
|
<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