Commit 7c762483e11bbffc10e321739167c00e7578b916

Authored by Benjamin Renard
1 parent 0c99c4b7

Fix some bugs related to the save of a plot request

js/app/models/PlotNode.js
... ... @@ -11,7 +11,7 @@ Ext.define('amdaModel.PlotNode', {
11 11 extend: 'amdaModel.ExecutableNode',
12 12  
13 13 fields : [
14   - {name : 'tabs', type:'auto', defaultValue:[], persist: false}
  14 + {name : 'tabs', type:'auto', defaultValue:false, persist: false}
15 15 ],
16 16  
17 17 statics: {
... ... @@ -128,6 +128,18 @@ Ext.define('amdaModel.PlotNode', {
128 128 default:
129 129 break;
130 130 }
  131 + },
  132 +
  133 + rename: function(value,callBackFn) {
  134 + var isFolder = (!this.isLeaf()) && (this.get('tabs') === false);
  135 + var dataToSend = {id : this.get('id'), old_name: this.modified.text, name: value, parent : this.data.parentId, leaf: !isFolder, nodeType: this.get('nodeType')};
  136 + AmdaAction.renameObject(dataToSend, callBackFn);
  137 + },
  138 +
  139 + renameDD: function(parentId, callBackFn) {
  140 + var isFolder = (!this.isLeaf()) && (this.get('tabs') === false);
  141 + var dataToSend = {id : this.get('id'), old_name: this.get('name'), name: this.get('name'), parent : parentId, leaf: !isFolder, nodeType: this.get('nodeType')};
  142 + AmdaAction.renameObject(dataToSend, callBackFn);
131 143 }
132 144  
133 145 });
... ...
js/app/views/ExplorerUI.js
... ... @@ -354,6 +354,7 @@ Ext.define('amdaUI.ExplorerUI', {
354 354 case 'remoteParam' :
355 355 case 'remoteSimuParam' :
356 356 case 'myData' :
  357 + case 'plottab' :
357 358 return false;
358 359 default :
359 360 if (draggedRecord.data.id == targetNode.data.nodeType+'-treeRootNode')
... ...
js/app/views/PlotComponents/PlotTabPanel.js
... ... @@ -92,11 +92,25 @@ Ext.define('amdaPlotComp.PlotTabPanel', {
92 92  
93 93 updatePlotTabs: function()
94 94 {
  95 + var me = this;
  96 + var haveSelectedTab = false;
  97 + this.object.tabs().each(function (rec, index) {
  98 + if (rec.get('id') == me.object.get('active-tab-id')) {
  99 + haveSelectedTab = true;
  100 + }
  101 + });
  102 +
95 103 var i = 0;
96 104 for (i = 0; i < this.items.getCount(); ++i)
97 105 {
98   - var tabNumber = i+1;
99 106 var tabObj = this.object.tabs().getAt(i);
  107 + if (!haveSelectedTab) {
  108 + //Set first tab as the selected one
  109 + this.setActiveTab(this.items.getAt(i));
  110 + this.object.set('active-tab-id', tabObj.get('id'));
  111 + haveSelectedTab = true;
  112 + }
  113 + var tabNumber = i+1;
100 114 this.items.getAt(i).setTitle((tabObj.get('tab-name') != '') ? tabObj.get('tab-name') : 'Plot '+tabNumber);
101 115 this.items.getAt(i).items.getAt(0).setTabObject(this.object.tabs().getAt(i));
102 116 }
... ...
php/classes/RequestMgr.php
... ... @@ -190,7 +190,7 @@ class RequestMgr extends AmdaObjectMgr
190 190 * Make new request/condition resource file (JSON!!) and add it to content file
191 191 * ATTENTION : it is not DD parameter!!!
192 192 */
193   - protected function createParameter($p)
  193 + protected function createParameter($p, $folder)
194 194 {
195 195 if ($this -> objectExistsByName($p->name))
196 196 {
... ... @@ -230,7 +230,7 @@ class RequestMgr extends AmdaObjectMgr
230 230 if (isset($p->tabs)) {
231 231 foreach ($p->tabs as $index => $tab) {
232 232 $additional['tabs'][$index] = array(
233   - "name" => "Plot ".($index+1),
  233 + "name" => (!empty($tab->{'tab-name'})) ? $tab->{'tab-name'} : "Plot ".($index+1),
234 234 "id" => $tab->id,
235 235 );
236 236 }
... ... @@ -243,7 +243,7 @@ class RequestMgr extends AmdaObjectMgr
243 243 $file = fopen($this->descFileName, 'w');
244 244 fwrite($file, json_encode($p));
245 245 fclose($file);
246   -
  246 +
247 247 $this -> addToContent($p, $folder);
248 248  
249 249 return array('id' => $this->id, 'info' => $info) + $additional;
... ...