From f0857375b9a18ba7a0d1820d1471f9bc0427efd3 Mon Sep 17 00:00:00 2001
From: felmer <franz-josef.elmer@id.ethz.ch>
Date: Wed, 19 Apr 2023 19:51:40 +0200
Subject: [PATCH] SSDM-13120: handle openBIS upgrade situation where previuous
 version doesn't have the feature of showing Semantic Annotations.

---
 .../html/js/config/SettingsManager.js         | 20 ++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/ui-eln-lims/src/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/config/SettingsManager.js b/ui-eln-lims/src/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/config/SettingsManager.js
index 0926b446573..d7a83e4430b 100644
--- a/ui-eln-lims/src/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/config/SettingsManager.js
+++ b/ui-eln-lims/src/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/config/SettingsManager.js
@@ -236,14 +236,20 @@ function SettingsManager(serverFacade) {
      	    }
 
              // Miscellaneous
-             var miscellaneousFields = ["hideSectionsByDefault", "showSemanticAnnotations", "showDatasetArchivingButton"]
+             var miscellaneousFields = [{name: "hideSectionsByDefault", defaultValue: true},
+                                        {name: "showSemanticAnnotations", defaultValue: true},
+                                        {name: "showDatasetArchivingButton", defaultValue: false}];
+             var defaultValues = [];
              for(var miscellaneousField of miscellaneousFields) {
-                if(isMergeGroup && targetProfile[miscellaneousField] != undefined) { // Merge found values
-                    targetProfile[miscellaneousField] = targetProfile[miscellaneousField] || settings[miscellaneousField];
-                } else if (settings[miscellaneousField] != undefined) { // Replaces or sets value
-     	            targetProfile[miscellaneousField] = settings[miscellaneousField];
-     	        }
-     	    }
+                 var name = miscellaneousField.name;
+                if(isMergeGroup && targetProfile[name] != undefined) { // Merge found values
+                    targetProfile[miscellaneousField] = targetProfile[name] || settings[name];
+                } else if (settings[name] != undefined) { // Replaces or sets value
+                    targetProfile[name] = settings[name];
+                } else {
+                    targetProfile[name] = miscellaneousField.defaultValue;
+                }
+            }
 
              // Forced Disable RTF
              if(isMergeGroup) { // Merge found values
-- 
GitLab