From b1fab76f2f8b39b84814708efc8ff0451f32e7cf Mon Sep 17 00:00:00 2001
From: Benjamin Renard <benjamin.renard@akka.eu>
Date: Tue, 4 May 2021 15:23:42 +0200
Subject: [PATCH] Give the possibility to edit options of a predefined templated parameter (#9385)

---
 js/app/views/ParameterUI.js                  |  9 ++++++++-
 js/app/views/PlotComponents/PlotPanelForm.js |  2 +-
 js/app/views/SearchUI.js                     | 12 ++++++++++--
 js/app/views/StatisticsUI.js                 |  9 ++++++++-
 4 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/js/app/views/ParameterUI.js b/js/app/views/ParameterUI.js
index cc507a3..a82eb1b 100755
--- a/js/app/views/ParameterUI.js
+++ b/js/app/views/ParameterUI.js
@@ -391,7 +391,14 @@ Ext.define('amdaUI.ParameterUI',
 							}
 							var paramModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.param.id);
 							if (paramModule) {
-								paramModule.addParam(nameToSent, data.records[0].get('leaf'), data.records[0].get('needsArgs'), components);
+								if (data.records[0].get('predefinedArgs')) {
+									paramModule.parseTemplatedParam(nameToSent, function(param_info) {
+										paramModule.addParam(param_info.paramid, data.records[0].get('leaf'), true, components, param_info.template_args);
+									});
+								}
+								else {
+									paramModule.addParam(nameToSent, data.records[0].get('leaf'), data.records[0].get('needsArgs'), components);
+								}
 							}
 							return true;
 						}
diff --git a/js/app/views/PlotComponents/PlotPanelForm.js b/js/app/views/PlotComponents/PlotPanelForm.js
index 979fb3d..31907fb 100644
--- a/js/app/views/PlotComponents/PlotPanelForm.js
+++ b/js/app/views/PlotComponents/PlotPanelForm.js
@@ -132,7 +132,7 @@ Ext.define('amdaPlotComp.PlotPanelForm', {
 		        this.addStandardCheck('panel-scatter-isotropic', 'Orthonormal scale', function(name, value, oldValue) {
 		        	me.object.set('panel-scatter-isotropic', value);
 	        		me.crtTree.refresh();
-		        }, 'When this is option is selected, a unit on the X-axis appears with the same size as a unit on the Y-axis'), 
+		        }, 'When this option is selected, a unit on the X-axis appears with the same size as a unit on the Y-axis'), 
 		        this.addStandardText('panel-epoch-centertimeid', 'Epoch Center Time Id', function(name, value, oldValue) {
 		        	me.object.set('panel-epoch-centertimeid', value);
 	        		me.crtTree.refresh();
diff --git a/js/app/views/SearchUI.js b/js/app/views/SearchUI.js
index b88fa0f..ba4fd65 100755
--- a/js/app/views/SearchUI.js
+++ b/js/app/views/SearchUI.js
@@ -414,8 +414,16 @@ Ext.define('amdaUI.SearchUI',
 									}
 									var searchModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.search.id);
 									
-									if (searchModule)
-										searchModule.addParam(nameToSent, data.records[0].get('leaf'), data.records[0].get('needsArgs'), components);	
+									if (searchModule) {
+										if (data.records[0].get('predefinedArgs')) {
+											searchModule.parseTemplatedParam(nameToSent, function(param_info) {
+												searchModule.addParam(param_info.paramid, data.records[0].get('leaf'), true, components, param_info.template_args);
+											});
+										}
+										else {
+											searchModule.addParam(nameToSent, data.records[0].get('leaf'), data.records[0].get('needsArgs'), components);
+										}
+									}
 									return true;
 								}
 						});
diff --git a/js/app/views/StatisticsUI.js b/js/app/views/StatisticsUI.js
index 62a272e..582cef7 100644
--- a/js/app/views/StatisticsUI.js
+++ b/js/app/views/StatisticsUI.js
@@ -370,7 +370,14 @@ Ext.define('amdaUI.StatisticsUI',
                                                     var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.statistics.id);
                                                     if (module)
                                                     {
-                                                        module.addParam(nameToSent, data.records[0].get('leaf'), data.records[0].get('needsArgs'), components);
+							if (data.records[0].get('predefinedArgs')) {
+								module.parseTemplatedParam(nameToSent, function(param_info) {
+									module.addParam(param_info.paramid, data.records[0].get('leaf'), true, components, param_info.template_args);
+								});
+							}
+							else {
+                                                        	module.addParam(nameToSent, data.records[0].get('leaf'), data.records[0].get('needsArgs'), components);
+							}
                                                     }
                                                     return true;
                                                 }
--
libgit2 0.21.2