From efca00de0f7fd2f84df9da2aa18206ad6da38344 Mon Sep 17 00:00:00 2001
From: Benjamin Renard <benjamin.renard@akka.eu>
Date: Thu, 9 May 2019 11:13:02 +0200
Subject: [PATCH] Update tab name in current plot request if need

---
 js/app/models/PlotTabNode.js | 13 ++++++++++++-
 js/app/views/PlotUI.js       | 10 ++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/js/app/models/PlotTabNode.js b/js/app/models/PlotTabNode.js
index b2a5ea7..d81703c 100644
--- a/js/app/models/PlotTabNode.js
+++ b/js/app/models/PlotTabNode.js
@@ -147,7 +147,18 @@ Ext.define('amdaModel.PlotTabNode', {
     },
 
     rename: function(value,callBackFn) {
+		var me = this;
                 var dataToSend = {id : this.get('tabid'), old_name: this.modified.text, name: value,  parent : this.data.parentId, leaf: this.isLeaf(), nodeType: this.get('nodeType')};
-		AmdaAction.renameObject(dataToSend, callBackFn);
+		AmdaAction.renameObject(dataToSend, function (result) {
+			callBackFn(result);
+			myDesktopApp.getLoadedModule(me.get('moduleId'), true, function (module) {
+				var uiContent = module.getUiContent();
+				if (uiContent != null) {
+					if ((module.linkedNode != null) && (module.linkedNode.get('id') == dataToSend.parent)) {
+						uiContent.updatePlotTabName(dataToSend.id, dataToSend.name);
+					}
+				}
+			});
+		});
         },
 });
diff --git a/js/app/views/PlotUI.js b/js/app/views/PlotUI.js
index 398fd1b..38887d9 100644
--- a/js/app/views/PlotUI.js
+++ b/js/app/views/PlotUI.js
@@ -186,6 +186,16 @@ Ext.define('amdaUI.PlotUI', {
 		}
 	},
 
+	updatePlotTabName: function(tabId, name) {
+		var me = this;
+		this.object.tabs().each(function (tabObject) {
+			if (tabId == tabObject.getId()) {
+				tabObject.set('tab-name', name);
+				me.plotTabs.updatePlotTabs();
+			}
+		});
+	},
+
 	insertPlotTab : function(tabData) {
 		var newTab = this.object.createNewTab(tabData);
 		this.plotTabs.addPlotTab(newTab,true);
--
libgit2 0.21.2