From 58eab001a65336508dedef1c719f7e4da73f9a98 Mon Sep 17 00:00:00 2001 From: Nik Verweel Date: Wed, 18 Feb 2026 09:20:46 +0100 Subject: [PATCH] Fix client selection edge cases --- webapps/uid_generator/app.js | 17 ++++++++++++----- webapps/uid_generator/index.html | 4 ++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/webapps/uid_generator/app.js b/webapps/uid_generator/app.js index 78cab31..e0a3316 100644 --- a/webapps/uid_generator/app.js +++ b/webapps/uid_generator/app.js @@ -42,21 +42,28 @@ clearAllBtn.addEventListener('click', () => { function tryAutoSelectClient(filename) { if (!filename) return; - // Matches strings starting with alphanumerics followed by an underscore - // e.g. KQ001_2023-10-10.geojson -> match "KQ001" - const match = filename.match(/^([A-Z0-9]+)_/); + // 1. Always clear the current selection and detected code first + clientSelect.value = ""; + detectedClientCode = null; + + // Matches strings starting with alphanumerics followed by an underscore OR a dot + const match = filename.match(/^([A-Z0-9]+)[_.]/); if (match && match[1]) { const potentialCode = match[1]; console.log(`Detected potential client code from filename: ${potentialCode}`); + // Save this in case the client list is uploaded AFTER the GeoJSON detectedClientCode = potentialCode; - // Try to select it in the dropdown if options exist + // 2. Try to select it in the dropdown immediately if the list exists const option = Array.from(clientSelect.options).find(opt => opt.value === potentialCode); + if (option) { clientSelect.value = potentialCode; - // Visual feedback could be added here if desired + } else { + // Optional: Log that a code was found in the file, but not in the dropdown list yet + console.log("Client code found in filename but not in the current list."); } } } diff --git a/webapps/uid_generator/index.html b/webapps/uid_generator/index.html index 41b17ad..b307b45 100644 --- a/webapps/uid_generator/index.html +++ b/webapps/uid_generator/index.html @@ -166,11 +166,11 @@ - -->

🆔 Unique ID generator