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"];
}
<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"/>
@@ -768,5 +770,33 @@ document.addEventListener('DOMContentLoaded', () => {
});
</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"/>