From 6a6e641621410a1ead76352407df8dd66d703adb Mon Sep 17 00:00:00 2001 From: LD-Reborn Date: Sun, 26 Oct 2025 11:17:52 +0100 Subject: [PATCH] Implemented owner dropdown with Tomselect in Assets view --- src/Views/Home/Assets.cshtml | 88 ++++++++++++++++++++++----------- src/Views/Shared/_Layout.cshtml | 4 +- src/wwwroot/js/site.js | 27 +++++++++- 3 files changed, 87 insertions(+), 32 deletions(-) diff --git a/src/Views/Home/Assets.cshtml b/src/Views/Home/Assets.cshtml index 0b5cf94..4a20bd6 100644 --- a/src/Views/Home/Assets.cshtml +++ b/src/Views/Home/Assets.cshtml @@ -5,7 +5,7 @@ @{ ViewData["Title"] = T["Assets"]; } - + @@ -179,9 +179,10 @@
- +
-
@@ -390,9 +391,10 @@
- +
-
@@ -764,38 +766,66 @@ 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); + const selectLocations = createModal.querySelector('#createLocationSelect'); + await loadLocationsIntoSelect(selectLocations); + const selectUsers = createModal.querySelector('#createUsersSelect'); + await loadUsersIntoSelect(selectUsers); }); }); - + diff --git a/src/Views/Shared/_Layout.cshtml b/src/Views/Shared/_Layout.cshtml index 0611bc7..fd97d68 100644 --- a/src/Views/Shared/_Layout.cshtml +++ b/src/Views/Shared/_Layout.cshtml @@ -20,7 +20,9 @@ diff --git a/src/wwwroot/js/site.js b/src/wwwroot/js/site.js index 1d0fcb1..dfad9b8 100644 --- a/src/wwwroot/js/site.js +++ b/src/wwwroot/js/site.js @@ -137,6 +137,29 @@ async function loadLocationsIntoSelect(selectElement, selectedValue = null) { }); } catch (err) { console.error('Error loading locations:', err); - showToast(appTranslations.errorLoading, 'danger'); + showToast(appTranslations.errorLoadingLocations, 'danger'); } -} \ No newline at end of file +} + +async function loadUsersIntoSelect(selectElement, selectedValue = null) { + try { + const response = await fetch('/Users/Index?Cn=false&Sn=false&Title=false&Description=false&JpegPhoto=false&UserPassword=false'); + const users = await response.json(); + + selectElement.innerHTML = ``; + + users.forEach(usr => { + const text = usr.uid; + const option = document.createElement('option'); + option.value = usr.uid; + option.textContent = text; + if (selectedValue && selectedValue === usr.uid) { + option.selected = true; + } + selectElement.appendChild(option); + }); + } catch (err) { + console.error('Error loading users:', err); + showToast(appTranslations.errorLoadingUsers, 'danger'); + } +}