Commit 63ac7745b97f49bd66e2a6151a63bfd0132068e6

Authored by Benjamin Renard
1 parent 509bf9fa

Support components for parameters drag&drop

js/app/controllers/InteractiveModule.js
... ... @@ -243,9 +243,9 @@ Ext.define('amdaDesktop.InteractiveModule', {
243 243 * @param {String} objectName The name of sent object
244 244 * @param {String} isLeaf boolean true if it's a leaf parameter
245 245 */
246   - addParam : function(objectName, isLeaf, isScatter, needsArgs) {
  246 + addParam : function(objectName, isLeaf, needsArgs, components) {
247 247 var uiContent = this.getUiContent();
248   - uiContent.addParam(objectName, isLeaf, isScatter, needsArgs);
  248 + uiContent.addParam(objectName, isLeaf, needsArgs, components);
249 249 },
250 250  
251 251 saveState : Ext.emptyFn,
... ...
js/app/models/AliasNode.js
... ... @@ -18,11 +18,7 @@ Ext.define('amdaModel.AliasNode', {
18 18 deletedAliases : null
19 19 },
20 20  
21   - fields: [
22   - {name: 'isScatter', type: 'boolean', defaultValue: true}
23   - ],
24   -
25   - constructor : function(config)
  21 + constructor : function(config)
26 22 {
27 23 this.callParent(arguments);
28 24 if (this.get('leaf')) this.set('iconCls', 'icon-scalar');
... ...
js/app/models/DerivedParamNode.js
... ... @@ -17,11 +17,7 @@ Ext.define('amdaModel.DerivedParamNode', {
17 17 objectName: 'Parameter'
18 18 },
19 19  
20   - fields:[
21   - {name: 'isScatter', type: 'boolean', defaultValue: true}
22   - ],
23   -
24   - constructor : function(config){
  20 + constructor : function(config){
25 21 this.callParent(arguments);
26 22 this.set('moduleId',myDesktopApp.dynamicModules.param.id);
27 23 this.set('objectDataModel',amdaModel.Parameter.$className);
... ...
js/app/models/InteractiveNode.js
... ... @@ -534,7 +534,8 @@ Ext.define('amdaModel.InteractiveNode', {
534 534 module.getUiContent().fireEvent('openParamEditor',node.get('id'));
535 535 }
536 536 else {
537   - var paramName;
  537 + var paramName;
  538 + var components = null;
538 539 switch (node.$className) {
539 540 case 'amdaModel.AliasNode' :
540 541 paramName = "#"+node.get('text');
... ... @@ -549,10 +550,21 @@ Ext.define('amdaModel.InteractiveNode', {
549 550 if (node.get('alias')!= "" )
550 551 paramName = "#"+node.get('alias');
551 552 else
552   - paramName = node.get('id');
  553 + paramName = node.get('id');
  554 + }
  555 +
  556 + var component_info = node.get('component_info');
  557 + if (component_info && component_info.parentId) {
  558 + //It's a component
  559 + paramName = component_info.parentId;
  560 + components = [];
  561 + if (component_info.index1)
  562 + components['index1'] = component_info.index1;
  563 + if (component_info.index2)
  564 + components['index2'] = component_info.index2;
553 565 }
554 566  
555   - module.addParam(paramName,true);
  567 + module.addParam(paramName,true,node.get('needsArgs'),components);
556 568 }
557 569 });
558 570  
... ...
js/app/models/LocalParamNode.js
... ... @@ -23,7 +23,6 @@ Ext.define('amdaModel.LocalParamNode',
23 23 {name: 'isParameter', type: 'boolean', persist: false},
24 24 {name: 'notyet', type: 'boolean', defaultValue: false, persist: false},
25 25 {name: 'needsArgs', type: 'boolean', persist: false},
26   - {name: 'isScatter', type: 'boolean', defaultValue: true, persist: false},
27 26 {name: 'isSpectra', type: 'boolean', defaultValue: false, persist: false},
28 27 {name: 'isStack', type: 'boolean', defaultValue: true, persist: false},
29 28 {name: 'globalStart', type: 'string', persist: false},
... ... @@ -174,22 +173,27 @@ Ext.define('amdaModel.LocalParamNode',
174 173 // edit newNode into Parameter Module with node as contextNode
175 174 newNode.editInModule();
176 175  
177   - var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.param.id);
  176 + var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.param.id, true, function(module) {
  177 + var paramName;
  178 + var components = null;
  179 + if (node.get('alias')!= "" )
  180 + paramName = "#"+node.get('alias');
  181 + else
  182 + paramName = node.get('id');
  183 + var component_info = node.get('component_info');
  184 + if (component_info && component_info.parentId) {
  185 + //It's a component
  186 + paramName = component_info.parentId;
  187 + components = [];
  188 + if (component_info.index1)
  189 + components['index1'] = component_info.index1;
  190 + if (component_info.index2)
  191 + components['index2'] = component_info.index2;
  192 + }
  193 +
  194 + module.addParam(paramName,true,node.get('needsArgs'),components);
  195 + });
178 196  
179   - if (node.get('needsArgs')) {
180   - module.getUiContent().fireEvent('openParamEditor',node.get('id'));
181   - }
182   - else {
183   - var paramName;
184   - if (node.get('alias')!= "" )
185   - paramName = "#"+node.get('alias');
186   - else
187   - paramName = node.get('id');
188   -
189   -
190   - module.addParam(paramName,true);
191   - }
192   -
193 197 },
194 198  
195 199 createAlias: function(node)
... ...
js/app/models/PlotObjects/PlotPanelObject.js
... ... @@ -270,8 +270,7 @@ Ext.define('amdaPlotObj.PlotPanelObject', {
270 270 }
271 271 },
272 272  
273   - createNewParam: function(paramId, onAfterCreate) {
274   -
  273 + createNewParam: function(paramId, paramComponents, onAfterCreate) {
275 274 this.set('last-param-id', this.get('last-param-id') + 1);
276 275  
277 276 var emptyPanel = (this.params().getCount() == 0);
... ... @@ -279,6 +278,13 @@ Ext.define('amdaPlotObj.PlotPanelObject', {
279 278 var recs = this.params().add({id : this.get('last-param-id')});
280 279 recs[0].set('paramid', paramId);
281 280  
  281 + if (paramComponents) {
  282 + if (paramComponents['index1'])
  283 + recs[0].set('dim1', paramComponents['index1']);
  284 + if (paramComponents['index2'])
  285 + recs[0].set('dim2', paramComponents['index2']);
  286 + }
  287 +
282 288 var me = this;
283 289 amdaPlotObj.PlotObjectConfig.getParamConfig(paramId, function (success, data) {
284 290 var availableDrawingObjects = null;
... ...
js/app/views/DownloadUI.js
... ... @@ -84,14 +84,31 @@ Ext.define('amdaUI.DownloadUI', {
84 84 this.timeSelector.intervalSel.updateDuration();
85 85 },
86 86  
87   - addParam : function(paramId,isArgsToDefined)
  87 + addParam : function(paramId, isLeaf, needArgs, components)
88 88 {
89 89 // adding the parameter to the paramGrid
90   - var r = Ext.create('amdaModel.DownloadParam', {paramid: paramId, type: 0, dim1: '', dim2: '', template_args: {} });
  90 +
  91 + var type = 0;
  92 + var dim1 = '';
  93 + var dim2 = '';
  94 +
  95 + if (components) {
  96 + if (components['index1']) {
  97 + dim1 = components['index1'];
  98 + ++type;
  99 + }
  100 +
  101 + if (components['index2']) {
  102 + dim2 = components['index2'];
  103 + ++type;
  104 + }
  105 + }
  106 +
  107 + var r = Ext.create('amdaModel.DownloadParam', {paramid: paramId, type: type, dim1: dim1, dim2: dim2, template_args: {} });
91 108 var pos = paramId.indexOf('ws_',0) == -1 ? 0 :this.paramGrid.store.getCount();
92 109 this.paramGrid.store.insert(pos,r);
93 110 this.paramGrid.getView().refresh();
94   - if (isArgsToDefined)
  111 + if (!isLeaf || needArgs)
95 112 this.editParameterArgs(r);
96 113 },
97 114  
... ... @@ -376,6 +393,7 @@ Ext.define('amdaUI.DownloadUI', {
376 393 if (!this.valid)
377 394 return false;
378 395 var idToSent;
  396 + var components = null;
379 397 switch (data.records[0].data.nodeType)
380 398 {
381 399 case 'localParam' :
... ... @@ -383,7 +401,17 @@ Ext.define('amdaUI.DownloadUI', {
383 401 case 'remoteSimuParam':
384 402 idToSent = data.records[0].get('id');
385 403 if (data.records[0].get('alias')!= "" )
386   - var idToSent = "#"+data.records[0].get('alias');
  404 + idToSent = "#"+data.records[0].get('alias');
  405 + var component_info = data.records[0].get('component_info');
  406 + if (component_info && component_info.parentId) {
  407 + //It's a component
  408 + idToSent = component_info.parentId;
  409 + components = [];
  410 + if (component_info.index1)
  411 + components['index1'] = component_info.index1;
  412 + if (component_info.index2)
  413 + components['index2'] = component_info.index2;
  414 + }
387 415 break;
388 416 case 'alias' :
389 417 idToSent = "#"+data.records[0].get('text');
... ... @@ -399,7 +427,7 @@ Ext.define('amdaUI.DownloadUI', {
399 427 }
400 428 var downModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.download.id);
401 429 if (downModule)
402   - downModule.addParam(idToSent,!data.records[0].get('leaf') || data.records[0].get('needsArgs'));
  430 + downModule.addParam(idToSent,data.records[0].get('leaf'), data.records[0].get('needsArgs'), components);
403 431 return true;
404 432 }
405 433 });
... ...
js/app/views/ParamArgumentsPlug.js
... ... @@ -134,7 +134,7 @@ Ext.define('amdaUI.ParamArgumentsPlug', {
134 134 handler: function(bt,event) {
135 135 //Set modification
136 136 if (me.paramObject)
137   - me.paramObject = me.paramArgs.paramRequestObject;
  137 + me.paramObject.data = me.paramArgs.paramRequestObject.data;
138 138 if (me.onApply)
139 139 me.onApply(me.hostCmp, me.paramArgs.paramRequestObject);
140 140 me.close();
... ...
js/app/views/ParameterUI.js
... ... @@ -46,17 +46,33 @@ Ext.define('amdaUI.ParameterUI', {
46 46 uiScope.addParamInEditor(fullParam);
47 47 },
48 48  
49   - addParam : function(newParamName, isArgsToDefined) {
50   - if (isArgsToDefined)
51   - this.editParameterArgs(newParamName);
  49 + addParam : function(newParamName, isLeaf, needArgs, components) {
  50 + if (!isLeaf || needArgs || components)
  51 + this.editParameterArgs(newParamName, components);
52 52 else
53 53 this.addParamInEditor(newParamName);
54 54 },
55 55  
56   - editParameterArgs: function(name) {
  56 + editParameterArgs: function(name, components) {
  57 + var type = 0;
  58 + var dim1 = '';
  59 + var dim2 = '';
  60 +
  61 + if (components) {
  62 + if (components['index1']) {
  63 + dim1 = components['index1'];
  64 + ++type;
  65 + }
  66 +
  67 + if (components['index2']) {
  68 + dim2 = components['index2'];
  69 + ++type;
  70 + }
  71 + }
  72 +
57 73 var paramArgsPlug = this.getPlugin('derived-param-arguments-plugin');
58 74 if (paramArgsPlug) {
59   - var workinRequestParamObject = Ext.create('amdaModel.RequestParamObject', {paramid: name, type: 0, dim1: '', dim2: '', template_args: {} });
  75 + var workinRequestParamObject = Ext.create('amdaModel.RequestParamObject', {paramid: name, type: type, dim1: dim1, dim2: dim2, template_args: {} });
60 76 paramArgsPlug.show('derived-param-arguments-plugin', workinRequestParamObject);
61 77 }
62 78 },
... ... @@ -279,6 +295,7 @@ Ext.define('amdaUI.ParameterUI', {
279 295 if (!this.valid)
280 296 return false;
281 297 var nameToSent;
  298 + var components = null;
282 299 switch (data.records[0].data.nodeType)
283 300 {
284 301 case 'localParam' :
... ... @@ -287,6 +304,16 @@ Ext.define('amdaUI.ParameterUI', {
287 304 nameToSent = data.records[0].get('id');
288 305 if (data.records[0].get('alias')!= "" )
289 306 var nameToSent = "#"+data.records[0].get('alias');
  307 + var component_info = data.records[0].get('component_info');
  308 + if (component_info && component_info.parentId) {
  309 + //It's a component
  310 + nameToSent = component_info.parentId;
  311 + components = [];
  312 + if (component_info.index1)
  313 + components['index1'] = component_info.index1;
  314 + if (component_info.index2)
  315 + components['index2'] = component_info.index2;
  316 + }
290 317 break;
291 318 case 'alias' :
292 319 nameToSent = "#"+data.records[0].get('text');
... ... @@ -309,7 +336,7 @@ Ext.define('amdaUI.ParameterUI', {
309 336 }
310 337 var paramModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.param.id);
311 338 if (paramModule) {
312   - paramModule.addParam(nameToSent, !data.records[0].get('leaf') || data.records[0].get('needsArgs'));
  339 + paramModule.addParam(nameToSent, data.records[0].get('leaf'), data.records[0].get('needsArgs'), components);
313 340 }
314 341 return true;
315 342 }
... ...
js/app/views/PlotComponents/PlotTree.js
... ... @@ -594,7 +594,7 @@ Ext.define('amdaPlotComp.PlotTree', {
594 594 return false;
595 595 },
596 596  
597   - dropParamToCreate : function(targetNode, position, paramId, needsArgs, plotOnly)
  597 + dropParamToCreate : function(targetNode, position, paramId, paramComponents)
598 598 {
599 599 var panelObject = null;
600 600 if (targetNode == null)
... ... @@ -628,7 +628,7 @@ Ext.define('amdaPlotComp.PlotTree', {
628 628  
629 629 //Create param object
630 630 var me = this;
631   - panelObject.createNewParam(paramId, function (newParamObject) {
  631 + panelObject.createNewParam(paramId, paramComponents, function (newParamObject) {
632 632 //Rebuild params node
633 633 me.buildPanelsNode(newParamObject.getId());
634 634 //BRE newParamObject
... ... @@ -653,19 +653,23 @@ Ext.define('amdaPlotComp.PlotTree', {
653 653 if (!record.get('isParameter') || record.get('disable'))
654 654 return false;
655 655  
656   - var needsArgs = false;
657   -
658   - if (record.$className == 'amdaModel.RemoteSimuParamNode') {
659   - needsArgs = record.get('needsArgs');
660   - }
661   - else if (record.$className == 'amdaModel.LocalParamNode') {
662   - needsArgs = record.get('needsArgs') && !record.get('isSpectra');
  656 + if (record.get('alias') != "" )
  657 + this.dropParamToCreate(targetNode, position, "#"+record.get('alias'));
  658 + else {
  659 + var component_info = record.get('component_info');
  660 + var param_id = record.get('id');
  661 + var components = null;
  662 + if (component_info && component_info.parentId) {
  663 + //It's a component
  664 + param_id = component_info.parentId;
  665 + components = [];
  666 + if (component_info.index1)
  667 + components['index1'] = component_info.index1;
  668 + if (component_info.index2)
  669 + components['index2'] = component_info.index2;
  670 + }
  671 + this.dropParamToCreate(targetNode, position, param_id, components);
663 672 }
664   -
665   - if (record.get('alias') != "" )
666   - this.dropParamToCreate(targetNode, position, "#"+record.get('alias'), needsArgs);
667   - else
668   - this.dropParamToCreate(targetNode, position, record.get('id'), needsArgs, record.get('notyet'));
669 673 return true;
670 674 case 'amdaModel.AliasNode' :
671 675 if (!record.isLeaf())
... ...
js/app/views/SearchUI.js
... ... @@ -39,10 +39,9 @@ Ext.define('amdaUI.SearchUI', {
39 39 // set TTTab
40 40 this.timeSelector.setTTTab(TTarray);
41 41 },
42   -
43   - addParam : function(newParamName, isArgsToDefined) {
44   - if (isArgsToDefined)
45   - this.editParameterArgs(newParamName);
  42 + addParam : function(newParamName, isLeaf, needArgs, components) {
  43 + if (!isLeaf || needArgs || components)
  44 + this.editParameterArgs(newParamName, components);
46 45 else
47 46 this.addParamInEditor(newParamName);
48 47 },
... ... @@ -59,10 +58,26 @@ Ext.define('amdaUI.SearchUI', {
59 58 uiScope.addParamInEditor(fullParam);
60 59 },
61 60  
62   - editParameterArgs: function(name) {
  61 + editParameterArgs: function(name, components) {
  62 + var type = 0;
  63 + var dim1 = '';
  64 + var dim2 = '';
  65 +
  66 + if (components) {
  67 + if (components['index1']) {
  68 + dim1 = components['index1'];
  69 + ++type;
  70 + }
  71 +
  72 + if (components['index2']) {
  73 + dim2 = components['index2'];
  74 + ++type;
  75 + }
  76 + }
  77 +
63 78 var paramArgsPlug = this.getPlugin('search-param-components-plugin');
64 79 if (paramArgsPlug) {
65   - var workinRequestParamObject = Ext.create('amdaModel.RequestParamObject', {paramid: name, type: 0, dim1: '', dim2: '', template_args: {} });
  80 + var workinRequestParamObject = Ext.create('amdaModel.RequestParamObject', {paramid: name, type: type, dim1: dim1, dim2: dim2, template_args: {} });
66 81 paramArgsPlug.show('search-param-components-plugin', workinRequestParamObject);
67 82 }
68 83 },
... ... @@ -322,6 +337,7 @@ Ext.define('amdaUI.SearchUI', {
322 337 if (!this.valid) return false;
323 338  
324 339 var nameToSent;
  340 + var components = null;
325 341 switch (data.records[0].get('nodeType'))
326 342 {
327 343 case 'localParam' :
... ... @@ -329,7 +345,17 @@ Ext.define('amdaUI.SearchUI', {
329 345 case 'remoteSimuParam' :
330 346 nameToSent = data.records[0].get('id');
331 347 if (data.records[0].get('alias')!= "" )
332   - var nameToSent = "#"+data.records[0].get('alias');
  348 + nameToSent = "#"+data.records[0].get('alias');
  349 + var component_info = data.records[0].get('component_info');
  350 + if (component_info && component_info.parentId) {
  351 + //It's a component
  352 + nameToSent = component_info.parentId;
  353 + components = [];
  354 + if (component_info.index1)
  355 + components['index1'] = component_info.index1;
  356 + if (component_info.index2)
  357 + components['index2'] = component_info.index2;
  358 + }
333 359 break;
334 360 case 'alias' :
335 361 nameToSent = "#"+data.records[0].get('text');
... ... @@ -352,7 +378,7 @@ Ext.define('amdaUI.SearchUI', {
352 378 var searchModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.search.id);
353 379  
354 380 if (searchModule)
355   - searchModule.addParam(nameToSent, !data.records[0].get('leaf') || data.records[0].get('needsArgs'));
  381 + searchModule.addParam(nameToSent, data.records[0].get('leaf'), data.records[0].get('needsArgs'), components);
356 382 return true;
357 383 }
358 384 });
... ...
php/classes/AmdaAction.php
... ... @@ -259,6 +259,7 @@ class AmdaAction {
259 259 }
260 260  
261 261  
  262 + $component_info = array();
262 263 if ($child->tagName == 'component')
263 264 {
264 265 $isParameter = true;
... ... @@ -274,8 +275,14 @@ class AmdaAction {
274 275 {
275 276 $timeRestriction = true;
276 277  
277   - }
278   -
  278 + }
  279 +
  280 + if ($child->hasAttribute("index1"))
  281 + $component_info["index1"] = $child->getAttribute('index1');
  282 + if ($child->hasAttribute("index2"))
  283 + $component_info["index2"] = $child->getAttribute('index2');
  284 +
  285 + $component_info["parentId"] = $child->parentNode->getAttribute('xml:id');
279 286 }
280 287  
281 288 if ($child->tagName == 'parameter' && $child->hasChildNodes()) $isScatter = false;
... ... @@ -325,7 +332,7 @@ class AmdaAction {
325 332 $alias = $objectMgr->getAlias($id);
326 333  
327 334 $childrenToReturn[] = array('text' => $name,'alias' => $alias,
328   - 'id' => $id,'nodeType' => $nodeType, 'info' => $info,
  335 + 'id' => $id,'nodeType' => $nodeType, 'info' => $info, "component_info" => $component_info,
329 336 'globalStart' => $globalStart, 'globalStop' => $globalStop, 'timeRestriction' => $timeRestriction,
330 337 'leaf' => $isLeaf, 'isParameter' => $isParameter, 'isScatter' => $isScatter,
331 338 'isSpectra' => $isSpectra,'isStack' => $isStack, 'needsArgs' => $needsArgs, 'help' => $help, 'notyet' => $not_yet);
... ... @@ -444,7 +451,7 @@ class AmdaAction {
444 451 $childrenToReturn[] = array('text' => $name,'alias' => $alias,
445 452 'id' => $id,'nodeType' => $nodeType, 'info' => $info, 'help' => $help,
446 453 'leaf' => $isLeaf, 'disable' => $disable, 'isParameter' => $isParameter,
447   - 'isScatter' => $isScatter, 'isSpectra' => $isSpectra, 'needsArgs' => $needsArgs);
  454 + 'isScatter' => $isScatter, 'isSpectra' => $isSpectra, 'needsArgs' => $needsArgs, "component_info" => $component_info);
448 455 }
449 456 else {
450 457 if ($child->tagName == 'dataCenter')
... ...