From ae185f403e6c51c8cf4a4e2f494da047269d677f Mon Sep 17 00:00:00 2001
From: Benjamin Renard <benjamin.renard@akka.eu>
Date: Wed, 16 Dec 2020 09:32:44 +0100
Subject: [PATCH] Fix multiplot (#8314)

---
 js/app/views/MultiPlotUI.js                 |  2 ++
 js/app/views/PlotComponents/PlotTabPanel.js | 19 ++++++++++++++++++-
 js/app/views/PlotUI.js                      |  4 +++-
 3 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/js/app/views/MultiPlotUI.js b/js/app/views/MultiPlotUI.js
index 51f28cb..ea3ded2 100644
--- a/js/app/views/MultiPlotUI.js
+++ b/js/app/views/MultiPlotUI.js
@@ -33,10 +33,12 @@ Ext.define('amdaUI.MultiPlotUI', {
                     listeners: {
                         change: function(field, newValue, oldValue, eOpts) {
                             tabInfo.object.set('multi-selected', newValue);
+                            tabInfo.tabContent.enableTimeSelection(!newValue);
                         }
                     }
                 }
             );
+            tabInfo.tabContent.enableTimeSelection(!tabInfo.object.get('multi-selected'));
         });
     },
 
diff --git a/js/app/views/PlotComponents/PlotTabPanel.js b/js/app/views/PlotComponents/PlotTabPanel.js
index 9e18949..0613f6a 100644
--- a/js/app/views/PlotComponents/PlotTabPanel.js
+++ b/js/app/views/PlotComponents/PlotTabPanel.js
@@ -203,7 +203,8 @@ Ext.define('amdaPlotComp.PlotTabPanel', {
             tabsInfo.push({
                 name: plotNode.get('object').get('tab-title'),
                 object: plotNode.get('object'),
-                selected: (tabItem == this.getActiveTab())
+                selected: (tabItem == this.getActiveTab()),
+                tabContent: tabContent
             });
         }
         return tabsInfo;
@@ -250,6 +251,22 @@ Ext.define('amdaPlotComp.PlotTabPanel', {
                         me.tabbar_destroy = true;
                     }
                 }
+            },
+            listeners: {
+                tabchange: function(tabPanel, newCard, oldCard, eOpts) {
+			if (newCard) {
+				var newTree = this.getTreeFromPlotTab(newCard);
+				if (newTree) {
+					if (newTree.plotElementPanel != null) {
+						var selectedNode = newTree.getSelectedNode();
+						if (selectedNode != null) {
+							newTree.plotElementPanel.setElement(selectedNode.type, selectedNode.object, newTree);
+						}
+					}
+				}
+			}
+                },
+                scope: this
             }
         };
 
diff --git a/js/app/views/PlotUI.js b/js/app/views/PlotUI.js
index a821666..a6fd7ef 100644
--- a/js/app/views/PlotUI.js
+++ b/js/app/views/PlotUI.js
@@ -152,7 +152,9 @@ Ext.define('amdaUI.PlotUI', {
         var plotButton = this.queryById('single-plot-button');
         plotButton.setDisabled(!enable);
         plotButton.setTooltip(enable ? 'Plot request' : 'Multiplot is enabled');
-        this.plotTabs.enableTimeSelection(enable);
+        if (enable) {
+            this.plotTabs.enableTimeSelection(true);
+        }
     },
     
     init : function(config) {
--
libgit2 0.21.2