Fixed locations dropdown in Assets view

This commit is contained in:
2025-10-26 10:14:45 +01:00
parent 17cc9243b5
commit 1ea286cf9c
3 changed files with 55 additions and 2 deletions

View File

@@ -5,6 +5,8 @@
@{ @{
ViewData["Title"] = T["Assets"]; ViewData["Title"] = T["Assets"];
} }
<link href="https://cdn.jsdelivr.net/npm/tom-select/dist/css/tom-select.bootstrap5.min.css" rel="preload" as="style" />
<script src="https://cdn.jsdelivr.net/npm/tom-select/dist/js/tom-select.complete.min.js" defer></script>
<partial name="_BatchButton"/> <partial name="_BatchButton"/>
@@ -768,5 +770,33 @@ document.addEventListener('DOMContentLoaded', () => {
}); });
</script> </script>
<!-- TomSelect locations dropdowns -->
<script>
document.addEventListener('DOMContentLoaded', () => {
const createSelect = document.getElementById('createLocationSelect');
const updateSelect = document.getElementById('updateLocationSelect');
async function initLocationSelect(selectElement) {
if (!selectElement) return;
await loadLocationsIntoSelect(selectElement);
new TomSelect(selectElement, {
plugins: ['clear_button'],
create: false,
sortField: { field: 'text', direction: 'asc' },
placeholder: '@T["Select location"]',
maxOptions: 500, // avoid performance hit if there are many
render: {
no_results: function(data, escape) {
return `<div class="no-results">@T["No locations found"]</div>`;
}
}
});
}
initLocationSelect(createSelect);
initLocationSelect(updateSelect);
});
</script>
<partial name="_Batch"/> <partial name="_Batch"/>

View File

@@ -40,4 +40,27 @@ body {
width: 2rem; width: 2rem;
height: 2rem; height: 2rem;
float: right; float: right;
} }
/* Tomselect dark mode theme */
[data-bs-theme="dark"] .ts-control,
[data-bs-theme="dark"] .ts-dropdown {
color: #f8f9fa !important;
border-color: #444 !important;
}
[data-bs-theme="dark"] .ts-control input,
[data-bs-theme="dark"] .ts-dropdown .option,
[data-bs-theme="dark"] .ts-dropdown .item {
color: #f8f9fa !important;
}
[data-bs-theme="dark"] .ts-dropdown .option:hover,
[data-bs-theme="dark"] .ts-dropdown .active {
color: #ffffff !important;
}
[data-bs-theme="dark"] .ts-control .item {
color: #f8f9fa !important;
border-color: #666 !important;
}

View File

@@ -126,7 +126,7 @@ async function loadLocationsIntoSelect(selectElement, selectedValue = null) {
selectElement.innerHTML = `<option value="">${appTranslations.selectLocation}</option>`; selectElement.innerHTML = `<option value="">${appTranslations.selectLocation}</option>`;
locations.forEach(loc => { locations.forEach(loc => {
const text = `${loc.description.Location}, Room ${loc.description.RoomNumber}, Seat ${loc.description.Seat}`; const text = `${loc.location}`;
const option = document.createElement('option'); const option = document.createElement('option');
option.value = loc.location; option.value = loc.location;
option.textContent = text; option.textContent = text;