Commit 127a15bb3c1a2215f8aa41db3235aa240c37f85c

Authored by soufiane elbouazaoui
1 parent 0e875406

update with add parameters

js/app/views/PlotComponents/intervalSelection/InsertToTTCatlog.js
1 1 Ext.define('amdaPlotComp.intervalSelection.InsertToTTCatlog', {
2 2 extend: 'Ext.form.FieldSet',
3 3  
4   - collapsible: false,
  4 + collapsible: true,
5 5 layout: LAYOUT_STYLE,
6 6 title: 'Add in Time Table or Catalog',
7 7 name: 'tt-insertion-fieldset',
... ... @@ -26,6 +26,7 @@ Ext.define('amdaPlotComp.intervalSelection.InsertToTTCatlog', {
26 26 });
27 27  
28 28 Ext.apply(self, {
  29 +
29 30 items: [{
30 31 xtype: 'combo',
31 32 fieldLabel: 'Insert In',
... ... @@ -70,13 +71,11 @@ Ext.define('amdaPlotComp.intervalSelection.InsertToTTCatlog', {
70 71 notifyDrop: function (ddSource, e, data) {
71 72 if (!this.valid)
72 73 return false;
73   - console.log("here")
74 74 field.setValue(data.records[0].get('text'));
75 75 var store = field.getStore();
76 76 store.loadData([{ text: data.records[0].get('text') }], false);
77 77 field.setValue(data.records[0].get('text'));
78 78 field.fireEvent('select', field, [field.getStore().findRecord('text', data.records[0].get('text'))]);
79   - // field.collapse();
80 79 return true;
81 80 }
82 81 });
... ... @@ -108,7 +107,6 @@ Ext.define('amdaPlotComp.intervalSelection.InsertToTTCatlog', {
108 107 field.fireEvent('select', field, [store.findRecord('text', newValue)]);
109 108 field.expand();
110 109 } else {
111   - //field.setValue('');
112 110 store.removeAll();
113 111 var parametersGrid = self.down('#parametersGrid');
114 112 parametersGrid.getStore().removeAll();
... ... @@ -116,7 +114,6 @@ Ext.define('amdaPlotComp.intervalSelection.InsertToTTCatlog', {
116 114 }
117 115 }
118 116  
119   - // Clear the field and parameters when TTCatType changes
120 117 self._getFieldTypeTTCat().on('change', function () {
121 118 field.setValue('');
122 119 store.removeAll();
... ... @@ -124,8 +121,6 @@ Ext.define('amdaPlotComp.intervalSelection.InsertToTTCatlog', {
124 121 parametersGrid.getStore().removeAll();
125 122 });
126 123  
127   -
128   - // Keep focus on the text field
129 124 field.focus(false, 100);
130 125 });
131 126 },
... ... @@ -140,13 +135,13 @@ Ext.define('amdaPlotComp.intervalSelection.InsertToTTCatlog', {
140 135 var nodeWithSameName = ttCatRootNode.findChild('text', selectedName, true);
141 136  
142 137 if (nodeWithSameName) {
143   - console.log('2', selectedName);
144 138 var opt = {
145 139 'typeTT': 'catalog',
146 140 'id': nodeWithSameName.data.id,
147 141 'name': selectedName
148 142 };
149 143 AmdaAction.readIntervalsForChart(opt, function (result, e) {
  144 + console.log('Catalog parameters:', result.intervals);
150 145 if (result && result.success) {
151 146 store.removeAll();
152 147 Ext.Array.each(result.parameters, function (param) {
... ... @@ -158,14 +153,12 @@ Ext.define('amdaPlotComp.intervalSelection.InsertToTTCatlog', {
158 153 }
159 154 });
160 155 }else{
161   - console.log('No node with name', selectedName);
162 156 store.removeAll();
163 157 }
164 158 }
165 159 },
166 160 blur: function (field) {
167 161 var value = field.getRawValue();
168   - console.log('selecting field', value);
169 162 field.fireEvent('select', field);
170 163 }
171 164 }
... ... @@ -173,23 +166,24 @@ Ext.define('amdaPlotComp.intervalSelection.InsertToTTCatlog', {
173 166 {
174 167 xtype: 'panel',
175 168 layout: 'fit',
  169 + title: 'Parameters',
176 170 hidden: true,
177   - tbar: [
178   - {
179   - xtype: 'tbtext',
180   - text: 'Parameters'
181   - },
182   - '->',
183   - {
184   - iconCls: 'icon-add',
185   - text: 'Add Parameter',
186   - handler: function () {
187   - var grid = this.up('panel').down('#parametersGrid');
188   - var store = grid.getStore();
189   - store.add({ name: '', value: '' });
190   - }
191   - }
192   - ],
  171 + // tbar: [
  172 + // {
  173 + // xtype: 'tbtext',
  174 + // text: 'Parameters'
  175 + // },
  176 + // '->',
  177 + // {
  178 + // iconCls: 'icon-add',
  179 + // text: 'Add Parameter',
  180 + // handler: function () {
  181 + // var grid = this.up('panel').down('#parametersGrid');
  182 + // var store = grid.getStore();
  183 + // store.add({ name: '', value: '' });
  184 + // }
  185 + // }
  186 + // ],
193 187 items: [
194 188 {
195 189 xtype: 'grid',
... ... @@ -233,6 +227,7 @@ Ext.define('amdaPlotComp.intervalSelection.InsertToTTCatlog', {
233 227  
234 228 var TTCatType = self._getFieldTypeTTCat().getValue();
235 229 var TTCatName = self._getFieldNameTTCat().getValue();
  230 + var parametersGrid = this.down('#parametersGrid');
236 231  
237 232 var isCatalog = (TTCatType == 'catalog');
238 233 myDesktopApp.getLoadedModule(isCatalog ? this.catModuleId : this.ttModuleId, true, function (module) {
... ... @@ -240,6 +235,7 @@ Ext.define('amdaPlotComp.intervalSelection.InsertToTTCatlog', {
240 235 if (me.linkedTTCatNode && (me.linkedTTCatNode.get('text') == TTCatName) && (me.linkedTTCatNode.get('nodeType') == TTCatType)) {
241 236 if (targetModuleUI)
242 237 me.insertInterval();
  238 +
243 239 else {
244 240 me.linkedTTCatNode.editLeaf(function () {
245 241 me.insertInterval();
... ... @@ -255,13 +251,38 @@ Ext.define('amdaPlotComp.intervalSelection.InsertToTTCatlog', {
255 251  
256 252 if (TTCatName != ''){
257 253 nodeWithSameName = ttCatRootNode.findChild('text', TTCatName, true);
  254 +
258 255  
259 256 if(nodeWithSameName){
260 257 var readdata = function (result, e) {
261   - console.log('the result', result.parameters);
  258 +
  259 + console.log('the result', result.intervals);
  260 +
  261 +
262 262 }
  263 +
  264 + var obj = {
  265 + 'cacheId': 0,
  266 + 'isCatalog': true,
  267 + 'data': {}
  268 + };
  269 +
  270 + obj['data']["cat_param_id_1"] = "2";
  271 + console.log('the obj', obj);
  272 +
  273 + AmdaAction.modifyCacheInterval(obj, function (result1, e) {;
  274 + console.log('the result1', result1);
  275 + var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id);
  276 + console.log("module", module)
  277 + if (module)
  278 + module.getUiContent();
  279 +
  280 + }, nodeWithSameName);
  281 +
  282 +
263 283 var opt = {
264   - 'typeTT': 'catalog', 'id': nodeWithSameName.data.id,
  284 + 'typeTT': 'catalog',
  285 + 'id': nodeWithSameName.data.id,
265 286 'name': TTCatName
266 287 };
267 288 AmdaAction.readIntervalsForChart(opt, readdata);
... ... @@ -271,6 +292,7 @@ Ext.define('amdaPlotComp.intervalSelection.InsertToTTCatlog', {
271 292 }
272 293  
273 294 if (nodeWithSameName !== null){
  295 + //nodeWithSameNameintervals
274 296 me.linkedTTCatNode = nodeWithSameName;}
275 297 else {
276 298 module.createLinkedNode();
... ... @@ -280,6 +302,7 @@ Ext.define('amdaPlotComp.intervalSelection.InsertToTTCatlog', {
280 302 name: TTCatName,
281 303 fromPlugin: true
282 304 };
  305 +
283 306 if (isCatalog) {
284 307 Ext.Msg.prompt('Define Parameters', 'Please enter parameters number for the new catalog:', function (btn, text) {
285 308 if (btn == 'ok') {
... ... @@ -304,6 +327,7 @@ Ext.define('amdaPlotComp.intervalSelection.InsertToTTCatlog', {
304 327  
305 328 me.linkedTTCatNode.editLeaf(function () {
306 329 me.insertInterval();
  330 + console.log('the end', me.linkedTTCatNode);
307 331 });
308 332 });
309 333 }
... ... @@ -337,32 +361,52 @@ Ext.define('amdaPlotComp.intervalSelection.InsertToTTCatlog', {
337 361  
338 362 myDesktopApp.getLoadedModule(isCatalog ? this.catModuleId : this.ttModuleId, true, function (module) {
339 363 var targetModuleUI = module.getUiContent();
340   - console.log(targetModuleUI.object.data.parameters);
  364 + // var parametersStore = parametersGrid.getStore();
  365 +
  366 +
  367 + // parametersStore.each(function(record) {
  368 + // // targetModuleUI.object.data.nbColumns += 1;
  369 + // //targetModuleUI.object.data.nbParameters += 1;
  370 + // targetModuleUI.object.data.parameters.push({
  371 + // id: "cat_param_id_" + (targetModuleUI.object.data.nbParameters+1),
  372 + // name: record.get('name'),
  373 + // //value: record.get('value'),
  374 + // size: 1,
  375 + // type: 0,
  376 + // description: "",
  377 + // status: ""
  378 + // });
  379 + // });
  380 +
  381 +
341 382 if (targetModuleUI)
342   - targetModuleUI.addInterval(start, stop);
  383 + // targetModuleUI.object.data.parameters[0].status = 'new';
  384 + console.log('target 1 ', targetModuleUI);
  385 +
  386 + targetModuleUI.addInterval(start, stop);
  387 + console.log('target 2 ', targetModuleUI);
343 388 });
344 389 },
345   - getCatalogParameters: function(catalogId) {
346   - const self = this;
  390 + // getCatalogParameters: function(catalogId) {
  391 + // const self = this;
347 392  
348   - AmdaAction.readIntervalsForChart({
349   - 'typeTT': 'catalog',
350   - 'id': catalogId,
351   - 'name': this.linkedTTCatNode.get('name')
352   - }, function(result, e) {
353   - if (result && result.success) {
354   - console.log('Catalog parameters:', result.parameters);
355   - const parametersGrid = self.down('#parametersGrid');
356   - const store = parametersGrid.getStore();
357   - store.removeAll();
  393 + // AmdaAction.readIntervalsForChart({
  394 + // 'typeTT': 'catalog',
  395 + // 'id': catalogId,
  396 + // 'name': this.linkedTTCatNode.get('name')
  397 + // }, function(result, e) {
  398 + // if (result && result.success) {
  399 + // const parametersGrid = self.down('#parametersGrid');
  400 + // const store = parametersGrid.getStore();
  401 + // store.removeAll();
358 402  
359   - Ext.Array.each(result.parameters, function(param) {
360   - store.add({
361   - name: param.id,
362   - value: ''
363   - });
364   - });
365   - }
366   - });
367   - }
  403 + // Ext.Array.each(result.parameters, function(param) {
  404 + // store.add({
  405 + // name: param.id,
  406 + // value: ''
  407 + // });
  408 + // });
  409 + // }
  410 + // });
  411 + // }
368 412 });
... ...