From b8c555a312aad8dda8c2b76a9795548bf598c039 Mon Sep 17 00:00:00 2001
From: Aaron Ponti <aaron.ponti@bsse.ethz.ch>
Date: Fri, 17 May 2019 17:00:52 +0200
Subject: [PATCH] Display series name instead of dataset codes in the
 ImageViewerWidget pull-down menu.

---
 .../html/js/plugins/MicroscopyTechnology.js   | 44 +++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/plugins/MicroscopyTechnology.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/plugins/MicroscopyTechnology.js
index 6d3ba47ce6d..5ee6177db2a 100644
--- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/plugins/MicroscopyTechnology.js
+++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/plugins/MicroscopyTechnology.js
@@ -71,6 +71,29 @@ $.extend(MicroscopyTechnology.prototype, ELNLIMSPlugin.prototype, {
                     // Create the image viewer component for the specific data sets
                     var widget = new ImageViewerWidget(screningFacade, imageViewerDataSets);
 
+                    // Customize the widget
+                    widget.addLoadListener(function () {
+
+                        widget.getDataSetChooserWidget().then(function (chooser) {
+
+                            var view = chooser.getView();
+
+                            // Show the series name instead of the dataset code
+                            view.getDataSetText = function (dataSetCode) {
+                                // Return the series name
+                                for (var i = 0; i < model.datasets.length; i++) {
+                                    if (model.datasets[i].code === dataSetCode) {
+                                        return model.datasets[i].properties.MICROSCOPY_IMG_CONTAINER_NAME;
+                                    }
+                                }
+
+                                // If not found, return the dataset code
+                                return dataSetCode;
+                            };
+
+                        });
+                    });
+
                     // Render the component and add it to the page
                     $container.append($('<legend>').text('Microscopy Viewer'));
                     var $imageWidgetContainer = new $('<div>');
@@ -93,6 +116,27 @@ $.extend(MicroscopyTechnology.prototype, ELNLIMSPlugin.prototype, {
                 // Create the image viewer component for the specific data sets
                 var widget = new ImageViewerWidget(screningFacade, [model.dataSetV3.permId.permId]);
 
+                    // Customize the widget
+                    widget.addLoadListener(function () {
+
+                        widget.getDataSetChooserWidget().then(function (chooser) {
+
+                            var view = chooser.getView();
+
+                            // Show the series name instead of the dataset code
+                            view.getDataSetText = function (dataSetCode) {
+                                // Return the series name
+                                if (model.dataSet.code === dataSetCode) {
+                                    return model.dataSet.properties.MICROSCOPY_IMG_CONTAINER_NAME;
+                                } else {
+                                    // Fall-back (that should not happen)
+                                    return dataSetCode;
+                                }
+                            };
+
+                        });
+                    });
+
                 // Render the component and add it to the page
                 $container.append($('<legend>').text('Microscopy Viewer'));
                 var $imageWidgetContainer = new $('<div>');
-- 
GitLab