From a898da119e2a3992559c675d8ccb11ef7288dbc4 Mon Sep 17 00:00:00 2001 From: Jukka Lampikoski Date: Wed, 11 Mar 2026 12:32:55 +0200 Subject: [PATCH] =?UTF-8?q?Laitteiden=20Tyyppi=20ja=20Funktio=20kent=C3=A4?= =?UTF-8?q?t=20muutettu=20dropdown-valikoiksi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Vapaa tekstikenttä → select-dropdown valmiilla vaihtoehdoilla: - Tyyppi: Reititin, Kytkin, Palomuuri, Tukiasema, Palvelin, OLT, ONT, Mediamuunnin, Muu - Funktio: PE/EDGE/CPE Reititin, Core/Aggregaatio/Access-kytkin, WAN GW, WLAN Controller, Asiakaslaite, Muu - Tyyppi-sarake siirretty ennen Funktio-saraketta - setSelectValue helper: lisää puuttuvan option automaattisesti muokatessa vanhaa dataa Co-Authored-By: Claude Opus 4.6 --- index.html | 33 ++++++++++++++++++++++++++++----- script.js | 19 ++++++++++++++++--- 2 files changed, 44 insertions(+), 8 deletions(-) diff --git a/index.html b/index.html index c6a72e8..488a72c 100644 --- a/index.html +++ b/index.html @@ -218,8 +218,8 @@ Hallintaosoite Serial Sijainti - Funktio Tyyppi + Funktio Malli Ping Toiminnot @@ -1065,12 +1065,35 @@
- - + +
- - + +
diff --git a/script.js b/script.js index 90099b8..4679c20 100644 --- a/script.js +++ b/script.js @@ -2714,8 +2714,8 @@ function renderDevices() { ${esc(d.hallintaosoite || '-')} ${esc(d.serial || '-')} ${d.site_name ? esc(d.site_name) : '-'} - ${esc(d.funktio || '-')} ${esc(d.tyyppi || '-')} + ${esc(d.funktio || '-')} ${esc(d.malli || '-')} ${pingIcon} @@ -2728,6 +2728,19 @@ function renderDevices() { document.getElementById('device-count').textContent = filtered.length + ' laitetta' + (query ? ` (${devicesData.length} yhteensä)` : ''); } +function setSelectValue(selectId, val) { + const sel = document.getElementById(selectId); + if (!val) { sel.value = ''; return; } + const exists = Array.from(sel.options).some(o => o.value === val); + if (!exists) { + const opt = document.createElement('option'); + opt.value = val; + opt.textContent = val; + sel.appendChild(opt); + } + sel.value = val; +} + async function editDevice(id) { const d = devicesData.find(x => x.id === id); if (!d) return; @@ -2735,8 +2748,8 @@ async function editDevice(id) { document.getElementById('device-form-nimi').value = d.nimi || ''; document.getElementById('device-form-hallintaosoite').value = d.hallintaosoite || ''; document.getElementById('device-form-serial').value = d.serial || ''; - document.getElementById('device-form-funktio').value = d.funktio || ''; - document.getElementById('device-form-tyyppi').value = d.tyyppi || ''; + setSelectValue('device-form-tyyppi', d.tyyppi || ''); + setSelectValue('device-form-funktio', d.funktio || ''); document.getElementById('device-form-malli').value = d.malli || ''; document.getElementById('device-form-ping-check').checked = d.ping_check || false; document.getElementById('device-form-lisatiedot').value = d.lisatiedot || '';