From 08b9e66f156e85baa553f89d9ffaa4fbbb918c0c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timoth=C3=A9e?= <tpoussard@neogeo.fr>
Date: Wed, 8 Jun 2022 15:02:14 +0200
Subject: [PATCH] fix errors if no custom field was selected

---
 src/services/map-service.js | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/src/services/map-service.js b/src/services/map-service.js
index 44ed8290..87156fe6 100644
--- a/src/services/map-service.js
+++ b/src/services/map-service.js
@@ -335,13 +335,19 @@ const mapService = {
     if (colors_style && colors_style.custom_field_name && customfield_set) {
       const fieldType = customfield_set.find((el) => el.name === colors_style.custom_field_name).field_type;
       const currentValue = properties[colors_style.custom_field_name];
-      if (fieldType === 'list') {
-        color = colors_style.colors[currentValue];
-        opacity = colors_style.opacities[currentValue];
-      } else if (fieldType === 'char') { //* if the custom field is supposed to be a string
-        //* check if its current value is empty or not, to select a color | https://redmine.neogeo.fr/issues/14048
-        color = colors_style.value.colors[currentValue ? 'Non vide' : 'Vide'];
-        opacity = colors_style.value.opacities[currentValue ? 'Non vide' : 'Vide'];
+
+      if (currentValue) {
+        switch (fieldType) {
+        case 'list' :
+          color = colors_style.colors[currentValue];
+          opacity = colors_style.opacities[currentValue];
+          break;
+        case 'char': //* if the custom field is supposed to be a string
+          //* check if its current value is empty or not, to select a color | https://redmine.neogeo.fr/issues/14048
+          color = colors_style.value.colors[currentValue ? 'Non vide' : 'Vide'];
+          opacity = colors_style.value.opacities[currentValue ? 'Non vide' : 'Vide'];
+          break;
+        }
       }
     }
     return { color, opacity };
-- 
GitLab