Commit 9def38fe2f51f520d2d0d23c8d4150023ed51a2d
1 parent
127a15bb
Exists in
master
and in
2 other branches
Add parameters and values to the interval
Showing
2 changed files
with
47 additions
and
75 deletions
Show diff stats
js/app/views/CatalogUI.js
... | ... | @@ -106,10 +106,13 @@ Ext.define('amdaUI.CatalogUI', { |
106 | 106 | return updateStatus; |
107 | 107 | }, |
108 | 108 | |
109 | - addInterval: function (start, stop) { | |
110 | - var row = this.TTGrid.getStore().getTotalCount(); | |
109 | + addInterval: function (start, stop, index, parametersData) { | |
110 | + | |
111 | + //var row = this.TTGrid.getStore().getTotalCount(); | |
112 | + var row = index; | |
111 | 113 | var me = this; |
112 | 114 | this.TTGrid.getSelectionModel().deselectAll(); |
115 | + | |
113 | 116 | AmdaAction.addCacheInterval({'start': start, 'stop': stop, 'index': row, 'isCatalog': true}, function (result, e) { |
114 | 117 | this.status = result.status; |
115 | 118 | if (!this.TTGrid.getStore().loading) { |
... | ... | @@ -122,6 +125,16 @@ Ext.define('amdaUI.CatalogUI', { |
122 | 125 | }); |
123 | 126 | } |
124 | 127 | }, this); |
128 | + | |
129 | + // update the parameters | |
130 | + if(index){ | |
131 | + var obj = { | |
132 | + 'cacheId': index, | |
133 | + 'isCatalog': true, | |
134 | + 'data': parametersData | |
135 | + }; | |
136 | + AmdaAction.modifyCacheInterval(obj); | |
137 | + } | |
125 | 138 | }, |
126 | 139 | |
127 | 140 | updateCount: function () { |
... | ... |
js/app/views/PlotComponents/intervalSelection/InsertToTTCatlog.js
... | ... | @@ -81,6 +81,7 @@ Ext.define('amdaPlotComp.intervalSelection.InsertToTTCatlog', { |
81 | 81 | }); |
82 | 82 | }, |
83 | 83 | change: function (field, newValue) { |
84 | + // change event to handle the case when the user types a name | |
84 | 85 | var explorerTree = Ext.getCmp(amdaUI.ExplorerUI.RESRC_TAB.TREE_ID); |
85 | 86 | var ttCatRootNode = explorerTree.getRootNode().findChild('id', 'catalog-treeRootNode', true); |
86 | 87 | |
... | ... | @@ -125,6 +126,7 @@ Ext.define('amdaPlotComp.intervalSelection.InsertToTTCatlog', { |
125 | 126 | }); |
126 | 127 | }, |
127 | 128 | select: function (combo) { |
129 | + // select event to handle the case when the user selects a name from the dropdown | |
128 | 130 | if(self._getFieldTypeTTCat().getValue() == 'catalog'){ |
129 | 131 | var selectedName = combo.getRawValue(); |
130 | 132 | var panel = combo.up('fieldset').down('panel'); |
... | ... | @@ -135,38 +137,49 @@ Ext.define('amdaPlotComp.intervalSelection.InsertToTTCatlog', { |
135 | 137 | var nodeWithSameName = ttCatRootNode.findChild('text', selectedName, true); |
136 | 138 | |
137 | 139 | if (nodeWithSameName) { |
140 | + | |
138 | 141 | var opt = { |
139 | 142 | 'typeTT': 'catalog', |
140 | 143 | 'id': nodeWithSameName.data.id, |
141 | 144 | 'name': selectedName |
142 | 145 | }; |
146 | + | |
147 | + // Get parameters for the selected catalog | |
143 | 148 | AmdaAction.readIntervalsForChart(opt, function (result, e) { |
144 | - console.log('Catalog parameters:', result.intervals); | |
145 | 149 | if (result && result.success) { |
146 | 150 | store.removeAll(); |
147 | 151 | Ext.Array.each(result.parameters, function (param) { |
148 | 152 | store.add({ |
149 | 153 | name: param.name, |
154 | + id : param.id, | |
150 | 155 | value: '' |
151 | 156 | }); |
152 | 157 | }); |
153 | 158 | } |
154 | 159 | }); |
155 | - }else{ | |
160 | + } else { | |
156 | 161 | store.removeAll(); |
157 | 162 | } |
158 | 163 | } |
164 | + self.selectUsed = true; // flag to indicate that the select event was triggered by the user | |
159 | 165 | }, |
160 | 166 | blur: function (field) { |
161 | - var value = field.getRawValue(); | |
162 | - field.fireEvent('select', field); | |
167 | + // blur event to handle the case when the user types a name and then clicks outside the field | |
168 | + if (!self.selectUsed) { | |
169 | + var value = field.getRawValue(); | |
170 | + field.fireEvent('select', field); | |
171 | + } | |
172 | + self.selectUsed = false; | |
173 | + | |
163 | 174 | } |
164 | 175 | } |
165 | 176 | }, |
166 | 177 | { |
178 | + // Panel for parameters | |
167 | 179 | xtype: 'panel', |
168 | 180 | layout: 'fit', |
169 | 181 | title: 'Parameters', |
182 | + collapsible: true, | |
170 | 183 | hidden: true, |
171 | 184 | // tbar: [ |
172 | 185 | // { |
... | ... | @@ -227,8 +240,6 @@ Ext.define('amdaPlotComp.intervalSelection.InsertToTTCatlog', { |
227 | 240 | |
228 | 241 | var TTCatType = self._getFieldTypeTTCat().getValue(); |
229 | 242 | var TTCatName = self._getFieldNameTTCat().getValue(); |
230 | - var parametersGrid = this.down('#parametersGrid'); | |
231 | - | |
232 | 243 | var isCatalog = (TTCatType == 'catalog'); |
233 | 244 | myDesktopApp.getLoadedModule(isCatalog ? this.catModuleId : this.ttModuleId, true, function (module) { |
234 | 245 | var targetModuleUI = module.getUiContent(); |
... | ... | @@ -251,48 +262,9 @@ Ext.define('amdaPlotComp.intervalSelection.InsertToTTCatlog', { |
251 | 262 | |
252 | 263 | if (TTCatName != ''){ |
253 | 264 | nodeWithSameName = ttCatRootNode.findChild('text', TTCatName, true); |
254 | - | |
255 | - | |
256 | - if(nodeWithSameName){ | |
257 | - var readdata = function (result, e) { | |
258 | - | |
259 | - console.log('the result', result.intervals); | |
260 | - | |
261 | - | |
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 | - | |
283 | - var opt = { | |
284 | - 'typeTT': 'catalog', | |
285 | - 'id': nodeWithSameName.data.id, | |
286 | - 'name': TTCatName | |
287 | - }; | |
288 | - AmdaAction.readIntervalsForChart(opt, readdata); | |
289 | - } | |
290 | - | |
291 | - | |
292 | 265 | } |
293 | 266 | |
294 | 267 | if (nodeWithSameName !== null){ |
295 | - //nodeWithSameNameintervals | |
296 | 268 | me.linkedTTCatNode = nodeWithSameName;} |
297 | 269 | else { |
298 | 270 | module.createLinkedNode(); |
... | ... | @@ -327,7 +299,6 @@ Ext.define('amdaPlotComp.intervalSelection.InsertToTTCatlog', { |
327 | 299 | |
328 | 300 | me.linkedTTCatNode.editLeaf(function () { |
329 | 301 | me.insertInterval(); |
330 | - console.log('the end', me.linkedTTCatNode); | |
331 | 302 | }); |
332 | 303 | }); |
333 | 304 | } |
... | ... | @@ -353,38 +324,26 @@ Ext.define('amdaPlotComp.intervalSelection.InsertToTTCatlog', { |
353 | 324 | * add Interval to Time table or Catalog |
354 | 325 | */ |
355 | 326 | insertInterval: function () { |
356 | - const start = this.parent.getField1Value(); | |
357 | - const stop = this.parent.getField2Value(); | |
327 | + const self = this; | |
328 | + const start = self.parent.getField1Value(); | |
329 | + const stop = self.parent.getField2Value(); | |
358 | 330 | |
359 | - const TTCatType = this._getFieldTypeTTCat().getValue(); | |
331 | + const TTCatType = self._getFieldTypeTTCat().getValue(); | |
360 | 332 | const isCatalog = (TTCatType == 'catalog'); |
361 | 333 | |
362 | - myDesktopApp.getLoadedModule(isCatalog ? this.catModuleId : this.ttModuleId, true, function (module) { | |
334 | + myDesktopApp.getLoadedModule(isCatalog ? self.catModuleId : self.ttModuleId, true, function (module) { | |
363 | 335 | var targetModuleUI = module.getUiContent(); |
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 | - | |
336 | + var parametersGrid = self.down('#parametersGrid'); | |
337 | + var parametersStore = parametersGrid.getStore(); | |
338 | + var parametersData = {}; | |
339 | + var index = targetModuleUI.object.data.nbIntervals; | |
340 | + | |
341 | + // Add parameters and values to the interval | |
342 | + parametersStore.each(function(record) { | |
343 | + parametersData[record.get('id')] = record.get('value'); | |
344 | + }); | |
382 | 345 | if (targetModuleUI) |
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); | |
346 | + targetModuleUI.addInterval(start, stop, index, parametersData); | |
388 | 347 | }); |
389 | 348 | }, |
390 | 349 | // getCatalogParameters: function(catalogId) { |
... | ... |