Blame view

js/app/views/ParamArgumentsUI.js 17.6 KB
7ac3ce50   Benjamin Renard   First implementat...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/**
 * Project   : AMDA-NG
 * Name      : ParamArgumentsUI.js
 * @class   amdaUI.ParamArgumentsUI
 * @extends Ext.container.Container
 * @brief   Parameter arguments definition (View)
 * @author  Benjamin Renard
 * @version $Id: ParamArgumentsUI.js benjamin $
 */


Ext.define('amdaUI.ParamArgumentsUI', {
	extend: 'Ext.container.Container',
	alias: 'widget.paramArguments',
4dbd97ec   Menouard AZIB   Goal is reached b...
15

51b7c77c   Benjamin Renard   Add templated par...
16
	regexp_istemplate: /^template_(.*)/,
4dbd97ec   Menouard AZIB   Goal is reached b...
17

bb6e93d9   Benjamin Renard   Implement templat...
18
	paramRequestObject: null,
7ac3ce50   Benjamin Renard   First implementat...
19
	onChange: null,
690e0a87   Benjamin Renard   Add sum in table ...
20
21
	onModifyHeight: null,
	pluginOwner: null,
4dbd97ec   Menouard AZIB   Goal is reached b...
22
23
24
25
	inRebuild: false,

	constructor: function (config) {
		this.init(config);
7ac3ce50   Benjamin Renard   First implementat...
26
27
		this.callParent(arguments);
	},
4dbd97ec   Menouard AZIB   Goal is reached b...
28
29

	init: function (config) {
7ac3ce50   Benjamin Renard   First implementat...
30
31
32
33
		var myConf = {
			layout: {
				type: 'vbox',
				align: 'stretch'
4dbd97ec   Menouard AZIB   Goal is reached b...
34
			},
7ac3ce50   Benjamin Renard   First implementat...
35
		};
4dbd97ec   Menouard AZIB   Goal is reached b...
36
37

		Ext.apply(this, Ext.apply(arguments, myConf));
7ac3ce50   Benjamin Renard   First implementat...
38
	},
4dbd97ec   Menouard AZIB   Goal is reached b...
39
40

	editParameter: function (paramRequestObject, uiScope, onReady) {
bb6e93d9   Benjamin Renard   Implement templat...
41
		this.paramRequestObject = paramRequestObject;
29dfb596   Benjamin Renard   Rework of ParamAr...
42

7ac3ce50   Benjamin Renard   First implementat...
43
		var me = this;
7bc1d734   Benjamin Renard   Fix bug in derive...
44
		me.getEl().mask();
29dfb596   Benjamin Renard   Rework of ParamAr...
45
		me.resetArguments();
4dbd97ec   Menouard AZIB   Goal is reached b...
46

29dfb596   Benjamin Renard   Rework of ParamAr...
47
		var explorerModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.explorer.id);
4dbd97ec   Menouard AZIB   Goal is reached b...
48

29dfb596   Benjamin Renard   Rework of ParamAr...
49
50
51
		if (explorerModule) {
			explorerModule.getParamInfo(paramRequestObject.get('paramid'), function (paramInfo) {
				if (paramInfo) {
4dbd97ec   Menouard AZIB   Goal is reached b...
52
53
					paramRequestObject.set(amdaPlotObj.PlotObjectConfig.bgSubstraction.tableName, paramInfo.data.tables);

29dfb596   Benjamin Renard   Rework of ParamAr...
54
55
56
					if (!paramRequestObject.get('is-init')) {
						if (paramInfo.data && paramInfo.data.dimensions) {
							//Init each dimensions and set parameter type (0: scalar, 1: vector or 2: Tab2D)
4dbd97ec   Menouard AZIB   Goal is reached b...
57
							paramRequestObject.set('type', 0);
29dfb596   Benjamin Renard   Rework of ParamAr...
58
							if (me.initDimension('dim1', paramInfo.data)) {
4dbd97ec   Menouard AZIB   Goal is reached b...
59
								paramRequestObject.set('type', paramRequestObject.get('type') + 1);
29dfb596   Benjamin Renard   Rework of ParamAr...
60
61
							}
							if (me.initDimension('dim2', paramInfo.data)) {
4dbd97ec   Menouard AZIB   Goal is reached b...
62
								paramRequestObject.set('type', paramRequestObject.get('type') + 1);
29dfb596   Benjamin Renard   Rework of ParamAr...
63
64
65
							}
							if (paramRequestObject.get('type') == 2) {
								//Tab2D
4dbd97ec   Menouard AZIB   Goal is reached b...
66
								var dim2RelatedTable = me.getRelatedTableFromDim('dim2', paramInfo.data.tables);
29dfb596   Benjamin Renard   Rework of ParamAr...
67
68
69
								if (!dim2RelatedTable.variable) {
									paramRequestObject.set('dim2-index', 0);
								}
367b8867   Benjamin Renard   Select sum in ran...
70
71
72
								else {
									paramRequestObject.set('dim2-sum-type', 1);
								}
29dfb596   Benjamin Renard   Rework of ParamAr...
73
							}
29dfb596   Benjamin Renard   Rework of ParamAr...
74
						}
eac92219   Benjamin Renard   Do not call onCha...
75
						paramRequestObject.set('is-init', true);
29dfb596   Benjamin Renard   Rework of ParamAr...
76
77
78
					}
					me.rebuildAll(paramInfo, uiScope);
				}
bb6e93d9   Benjamin Renard   Implement templat...
79
				if (onReady)
0314bd32   Benjamin Renard   Keep a registry o...
80
					onReady(uiScope);
7bc1d734   Benjamin Renard   Fix bug in derive...
81
				me.getEl().unmask();
4dbd97ec   Menouard AZIB   Goal is reached b...
82
			});
29dfb596   Benjamin Renard   Rework of ParamAr...
83
84
		}
		else
7bc1d734   Benjamin Renard   Fix bug in derive...
85
			me.getEl().unmask();
29dfb596   Benjamin Renard   Rework of ParamAr...
86
	},
dc9e2c14   Elena.Budnik   init + message + ...
87

4dbd97ec   Menouard AZIB   Goal is reached b...
88
	initDimension: function (relatedDim, data) {
29dfb596   Benjamin Renard   Rework of ParamAr...
89
90
91
92
93
94
95
96
		if (!data || !data.dimensions || !data.dimensions[relatedDim] || this.paramRequestObject.get('is-init')) {
			return false;
		}
		if (data.dimensions[relatedDim] && (parseInt(data.dimensions[relatedDim]) > 1)) {
			var relatedTable = this.getRelatedTableFromDim(relatedDim, data.tables);
			if (relatedTable) {
				var minmax = this.getDimensionMinMaxValues(relatedDim, data);
				if (!minmax) {
4dbd97ec   Menouard AZIB   Goal is reached b...
97
					myDesktopApp.warningMsg('Min/Max ' + this.getDimensionTitle(relatedDim, data) + ' values are undefined<br/>Arbitrary values are taken');
29dfb596   Benjamin Renard   Rework of ParamAr...
98
99
100
101
102
					minmax = {
						'min': 10,
						'max': 10000
					};
				}
4dbd97ec   Menouard AZIB   Goal is reached b...
103
104
105
106
				this.paramRequestObject.set(relatedDim + '-min-value', minmax['min']);
				this.paramRequestObject.set(relatedDim + '-max-value', minmax['max']);
				this.paramRequestObject.set(relatedDim + '-min-index', 0);
				this.paramRequestObject.set(relatedDim + '-max-index', parseInt(data.dimensions[relatedDim]) - 1);
29dfb596   Benjamin Renard   Rework of ParamAr...
107
108
109
110
111
112
			}
			return true;
		}
		return false;
	},

4dbd97ec   Menouard AZIB   Goal is reached b...
113
	getDimensionMinMaxValues: function (relatedDim, data) {
29dfb596   Benjamin Renard   Rework of ParamAr...
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
		var relatedTable = this.getRelatedTableFromDim(relatedDim, data.tables);
		if (relatedTable.variable) {
			if (Ext.Object.isEmpty(relatedTable.minmax)) {
				//Not defined
				return null;
			}
			return {
				'min': relatedTable.minmax.min,
				'max': relatedTable.minmax.max
			};
		}
		var minValue = null;
		var maxValue = null;
		Ext.Object.each(relatedTable.channels, function (argKey, argDef) {
			var crtMin = (parseFloat(argDef.min) < parseFloat(argDef.max)) ? parseFloat(argDef.min) : parseFloat(argDef.max);
			if (!minValue || minValue > crtMin) {
				minValue = crtMin;
			}
			var crtMax = (parseFloat(argDef.max) > parseFloat(argDef.min)) ? parseFloat(argDef.max) : parseFloat(argDef.min);
			if (!maxValue || maxValue < crtMax) {
				maxValue = crtMax;
			}
		});
		return {
			'min': (minValue < maxValue) ? minValue : maxValue,
			'max': (maxValue > minValue) ? maxValue : minValue
		};
	},

4dbd97ec   Menouard AZIB   Goal is reached b...
143
	getDimensionTitle: function (relatedDim, data) {
29dfb596   Benjamin Renard   Rework of ParamAr...
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
		var relatedTable = this.getRelatedTableFromDim(relatedDim, data.tables);
		var title = 'Unknown';
		if (relatedTable) {
			title = relatedTable.name;
			if (relatedTable.units != '')
				title += ' (' + relatedTable.units + ')';
		}
		else if (relatedDim == "dim1") {
			title = 'Dim. 1';
		}
		else if (relatedDim == "dim2") {
			title = 'Dim. 2';
		}
		return title;
	},
4dbd97ec   Menouard AZIB   Goal is reached b...
159
160

	rebuildAll: function (paramInfoResult, uiScope) {
eac92219   Benjamin Renard   Do not call onCha...
161
		this.inRebuild = true;
29dfb596   Benjamin Renard   Rework of ParamAr...
162
		//Rebuild arguments selection
0314bd32   Benjamin Renard   Keep a registry o...
163
		this.rebuildArguments(paramInfoResult, uiScope);
bb6e93d9   Benjamin Renard   Implement templat...
164
165
166
167
		//Add default template args values
		var templateArgsValues = this.paramRequestObject.get('template_args');
		if (!templateArgsValues)
			templateArgsValues = {};
4dbd97ec   Menouard AZIB   Goal is reached b...
168
		if (paramInfoResult.template && paramInfoResult.template.arguments) {
0314bd32   Benjamin Renard   Keep a registry o...
169
170
			//Add default template args definition if needed
			Ext.Object.each(paramInfoResult.template.arguments, function (argKey, argDef) {
bb6e93d9   Benjamin Renard   Implement templat...
171
172
				if (!templateArgsValues[argKey])
					templateArgsValues[argKey] = argDef['default'];
0314bd32   Benjamin Renard   Keep a registry o...
173
			}, this);
4dbd97ec   Menouard AZIB   Goal is reached b...
174

bb6e93d9   Benjamin Renard   Implement templat...
175
			this.paramRequestObject.set('template_args', templateArgsValues);
0314bd32   Benjamin Renard   Keep a registry o...
176
		}
4dbd97ec   Menouard AZIB   Goal is reached b...
177
178


bb6e93d9   Benjamin Renard   Implement templat...
179
180
		//Init values in interface
		this.items.each(function (item) {
29dfb596   Benjamin Renard   Rework of ParamAr...
181
182
183
184
			if (!item.argId)
				return;
			if (this.regexp_istemplate.test(item.argId)) {
				var arg_key = this.regexp_istemplate.exec(item.argId)[1];
4dbd97ec   Menouard AZIB   Goal is reached b...
185

29dfb596   Benjamin Renard   Rework of ParamAr...
186
187
188
189
				if (this.paramRequestObject.get('template_args') && this.paramRequestObject.get('template_args')[arg_key])
					item.setValue(this.paramRequestObject.get('template_args')[arg_key]);
			}
			else if (item.argId == 'dim1' || item.argId == 'dim2') {
4dbd97ec   Menouard AZIB   Goal is reached b...
190
191
				item.setValue(this.paramRequestObject.get(item.argId + '-index'));
				var sumInRangeField = item.up().down('[name=sum_fieldset_' + item.argId + ']');
29dfb596   Benjamin Renard   Rework of ParamAr...
192
193
				if (sumInRangeField) {
					//Fill fields
4dbd97ec   Menouard AZIB   Goal is reached b...
194
195
196
197
198
					sumInRangeField.down('textfield[name=value_min_' + item.argId + ']').setValue(this.paramRequestObject.get(item.argId + '-min-value'));
					sumInRangeField.down('textfield[name=value_max_' + item.argId + ']').setValue(this.paramRequestObject.get(item.argId + '-max-value'));
					sumInRangeField.down('textfield[name=index_min_' + item.argId + ']').setValue(this.paramRequestObject.get(item.argId + '-min-index'));
					sumInRangeField.down('textfield[name=index_max_' + item.argId + ']').setValue(this.paramRequestObject.get(item.argId + '-max-index'));
					if (this.paramRequestObject.get(item.argId + '-sum-type') > 0) {
29dfb596   Benjamin Renard   Rework of ParamAr...
199
200
201
202
203
						sumInRangeField.expand();
					}
					else {
						sumInRangeField.collapse();
					}
690e0a87   Benjamin Renard   Add sum in table ...
204
				}
4dbd97ec   Menouard AZIB   Goal is reached b...
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
			}
			else
				item.setValue(this.paramRequestObject.get(item.argId));
			this.inRebuild = false;
		}, this);
	},

	getValues: function () {
		var values = { type: paramRequestObject.get('type') };
		this.items.each(function (item) {
			if (!item.argId)
				return;
			if (this.regexp_istemplate.test(item.argId)) {
				var arg_key = this.regexp_istemplate.exec(item.argId)[1];
				if (!values['template_args'])
					values['template_args'] = {};
				values['template_args'][arg_key] = item.getValue();
			}
			else
				values[item.argId] = item.getValue();
		}, this);

		return values;
	},

	resetValues: function () {
		this.items.each(function (item) {
			if (item.reset)
				item.reset();
		});
	},

	resetArguments: function (noArgsMsg) {
		this.removeAll();
		if (!noArgsMsg)
			this.add(new Ext.form.Label({ text: 'No argument for this parameter', argId: null }));
	},

	rebuildArguments: function (result, uiScope) {
		this.resetArguments(true);

		if (result.data && result.data.dimensions) {
			if (result.data.dimensions.dim1 && (parseInt(result.data.dimensions.dim1) > 1) || this.getRelatedTableFromDim('dim1', result.data.tables)) {
				this.buildDimIndexSelection("dim1", result.data, uiScope);
			}
			if (result.data.dimensions.dim2 && (parseInt(result.data.dimensions.dim2) > 1) || this.getRelatedTableFromDim('dim2', result.data.tables)) {
				this.buildDimIndexSelection("dim2", result.data, uiScope);
			}
		}

		var isTemplate = (result.template && result.template.arguments);
		if (isTemplate)
			this.buildTemplateArguments(result.template.arguments, uiScope);

		if ((this.paramRequestObject.get('type') == 0) && !isTemplate)
			//Add no args message
			this.resetArguments(false);
	},

	getRelatedTableFromDim: function (relatedDim, tables) {
		var relatedTable = null;
690e0a87   Benjamin Renard   Add sum in table ...
266
		if (tables) {
4dbd97ec   Menouard AZIB   Goal is reached b...
267
			Ext.each(tables, function (table, index) {
7ac3ce50   Benjamin Renard   First implementat...
268
269
270
271
				if (table.relatedDim == relatedDim)
					relatedTable = table;
			}, this);
		}
690e0a87   Benjamin Renard   Add sum in table ...
272
		return relatedTable;
4dbd97ec   Menouard AZIB   Goal is reached b...
273
274
275
276
277
278
279
280
281
282
	},

	buildDimIndexSelection: function (relatedDim, data, uiScope) {
		var ruler = {
			xtype: 'box',
			autoEl: {
				tag: 'hr'
			}
		};
		//Check if this dimension is attached to a table
690e0a87   Benjamin Renard   Add sum in table ...
283
		var relatedTable = this.getRelatedTableFromDim(relatedDim, data.tables);
1df8e90c   Benjamin Renard   Add selection for...
284
		var dimSize = data.dimensions[relatedDim];
4dbd97ec   Menouard AZIB   Goal is reached b...
285

29dfb596   Benjamin Renard   Rework of ParamAr...
286
		var title = this.getDimensionTitle(relatedDim, data);
4dbd97ec   Menouard AZIB   Goal is reached b...
287

7ac3ce50   Benjamin Renard   First implementat...
288
		var indexes = [];
4dbd97ec   Menouard AZIB   Goal is reached b...
289
290
		indexes.push({ 'key': '*', 'value': 'All' });

7ac3ce50   Benjamin Renard   First implementat...
291
		if (relatedTable) {
690e0a87   Benjamin Renard   Add sum in table ...
292
			//If it's not a variable table => enable channel selection
690e0a87   Benjamin Renard   Add sum in table ...
293
294
			if (!relatedTable.variable)
				Ext.Object.each(relatedTable.channels, function (index, channel) {
4dbd97ec   Menouard AZIB   Goal is reached b...
295
					indexes.push({ 'key': index.toString(), 'value': index + ' : [' + channel.min + ', ' + channel.max + ']' });
690e0a87   Benjamin Renard   Add sum in table ...
296
				});
7ac3ce50   Benjamin Renard   First implementat...
297
298
299
		}
		else {
			//Else, use components
7ac3ce50   Benjamin Renard   First implementat...
300
			Ext.Object.each(data.components, function (index, component) {
bb6e93d9   Benjamin Renard   Implement templat...
301
				if (relatedDim == "dim1" && component.index_1 != "")
4dbd97ec   Menouard AZIB   Goal is reached b...
302
					indexes.push({ 'key': component.index_1, 'value': index + ' : ' + component.name });
bb6e93d9   Benjamin Renard   Implement templat...
303
				else if (relatedDim == "dim2" && component.index_2 != "")
4dbd97ec   Menouard AZIB   Goal is reached b...
304
					indexes.push({ 'key': component.index_2, 'value': index + ' : ' + component.name });
7ac3ce50   Benjamin Renard   First implementat...
305
306
			});
		}
dc9e2c14   Elena.Budnik   init + message + ...
307

7ac3ce50   Benjamin Renard   First implementat...
308
309
		//Add combo box
		var indexesStore = Ext.create('Ext.data.Store', {
4dbd97ec   Menouard AZIB   Goal is reached b...
310
311
			fields: ['key', 'value'],
			data: indexes
7ac3ce50   Benjamin Renard   First implementat...
312
313
		});

7ac3ce50   Benjamin Renard   First implementat...
314
		var indexesCombo = Ext.create('Ext.form.ComboBox', {
4dbd97ec   Menouard AZIB   Goal is reached b...
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
			fieldLabel: title,
			store: indexesStore,
			queryMode: 'local',
			displayField: 'value',
			valueField: 'key',
			value: '*',
			editable: false,
			argId: relatedDim,
			hidden: (relatedTable ? relatedTable.variable : false),
			listeners: {
				change: function (field, newValue, oldValue, eOpts) {
					this.paramRequestObject.set(relatedDim + '-index', newValue);
					if (!this.inRebuild && (this.onChange != null))
						this.onChange(uiScope, relatedDim, newValue, oldValue, false);
				},
				scope: this
			}

7ac3ce50   Benjamin Renard   First implementat...
333
		});
4dbd97ec   Menouard AZIB   Goal is reached b...
334

7ac3ce50   Benjamin Renard   First implementat...
335
		this.add(indexesCombo);
4dbd97ec   Menouard AZIB   Goal is reached b...
336

690e0a87   Benjamin Renard   Add sum in table ...
337
		if (relatedTable) {
29dfb596   Benjamin Renard   Rework of ParamAr...
338
			var sumTypes = Ext.create('Ext.data.Store', {
1df8e90c   Benjamin Renard   Add selection for...
339
340
				fields: ['type', 'name'],
				data: [
4dbd97ec   Menouard AZIB   Goal is reached b...
341
342
					{ 'type': 1, 'name': 'Between Values' },
					{ 'type': 2, 'name': 'Between Indexes' }
1df8e90c   Benjamin Renard   Add selection for...
343
344
				]
			});
29dfb596   Benjamin Renard   Rework of ParamAr...
345
			var sumItems = [
4dbd97ec   Menouard AZIB   Goal is reached b...
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
				{
					xtype: 'combobox',
					name: 'sum_type_' + relatedDim,
					store: sumTypes,
					queryMode: 'local',
					editable: false,
					displayField: 'name',
					valueField: 'type',
					fieldLabel: 'Type',
					value: 1,
					listeners: {
						change: function (field, newValue, oldValue, eOpts) {
							this.paramRequestObject.set(relatedDim + '-sum-type', newValue);
							field.up().down('[name=value_min_' + relatedDim + ']').setVisible(newValue == 1);
							field.up().down('[name=value_max_' + relatedDim + ']').setVisible(newValue == 1);
							field.up().down('[name=index_min_' + relatedDim + ']').setVisible(newValue == 2);
							field.up().down('[name=index_max_' + relatedDim + ']').setVisible(newValue == 2);
							if (!this.inRebuild && (this.onChange != null))
								this.onChange(uiScope, relatedDim, newValue, oldValue, false);
						},
						scope: this
					}
1df8e90c   Benjamin Renard   Add selection for...
368
				},
4dbd97ec   Menouard AZIB   Goal is reached b...
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
				{
					xtype: 'numberfield',
					name: 'value_min_' + relatedDim,
					fieldLabel: 'Min.',
					decimalPrecision: 3,
					value: 0.,
					listeners: {
						change: function (field, newValue, oldValue, eOpts) {
							this.paramRequestObject.set(relatedDim + '-min-value', newValue);
							if (!this.inRebuild && (this.onChange != null))
								this.onChange(uiScope, relatedDim, newValue, oldValue, false);
						},
						scope: this
					}
				},
				{
					xtype: 'numberfield',
					name: 'value_max_' + relatedDim,
					fieldLabel: 'Max.',
					decimalPrecision: 3,
					value: 0.,
					listeners: {
						change: function (field, newValue, oldValue, eOpts) {
							this.paramRequestObject.set(relatedDim + '-max-value', newValue);
							if (!this.inRebuild && (this.onChange != null))
								this.onChange(uiScope, relatedDim, newValue, oldValue, false);
						},
						scope: this
					}
				},
				{
					xtype: 'numberfield',
					name: 'index_min_' + relatedDim,
					fieldLabel: 'Min.',
					allowDecimals: false,
					value: 0,
					minValue: 0,
					hidden: true,
					listeners: {
						change: function (field, newValue, oldValue, eOpts) {
							this.paramRequestObject.set(relatedDim + '-min-index', newValue);
							if (!this.inRebuild && (this.onChange != null))
								this.onChange(uiScope, relatedDim, newValue, oldValue, false);
						},
						scope: this
					}
				},
				{
					xtype: 'numberfield',
					name: 'index_max_' + relatedDim,
					fieldLabel: 'Max.',
					allowDecimals: false,
					value: 0,
					minValue: 0,
					hidden: true,
					listeners: {
						change: function (field, newValue, oldValue, eOpts) {
							this.paramRequestObject.set(relatedDim + '-max-index', newValue);
							if (!this.inRebuild && (this.onChange != null))
								this.onChange(uiScope, relatedDim, newValue, oldValue, false);
						},
						scope: this
					}
				}
690e0a87   Benjamin Renard   Add sum in table ...
433
			];
4dbd97ec   Menouard AZIB   Goal is reached b...
434

9a9c6ebf   Elena.Budnik   sum in variable r...
435
436
			var sumRangeFieldSet = Ext.create('Ext.form.FieldSet', {
				title: relatedTable.variable ? title + " - Sum. in range" : "Sum. in range",
690e0a87   Benjamin Renard   Add sum in table ...
437
				collapsed: true,
4dbd97ec   Menouard AZIB   Goal is reached b...
438
				checkboxName: 'sum_checkbox_' + relatedDim,
9a9c6ebf   Elena.Budnik   sum in variable r...
439
				checkboxToggle: true,
4dbd97ec   Menouard AZIB   Goal is reached b...
440
				name: 'sum_fieldset_' + relatedDim,
9a9c6ebf   Elena.Budnik   sum in variable r...
441
				layout: {
4dbd97ec   Menouard AZIB   Goal is reached b...
442
443
444
					type: 'vbox',
					pack: 'start',
					align: 'stretch'
690e0a87   Benjamin Renard   Add sum in table ...
445
				},
29dfb596   Benjamin Renard   Rework of ParamAr...
446
				items: sumItems,
690e0a87   Benjamin Renard   Add sum in table ...
447
				listeners: {
4dbd97ec   Menouard AZIB   Goal is reached b...
448
449
450
451
452
453
454
455
456
457
					expand: function (fieldset, eOpts) {
						if (this.paramRequestObject.get(relatedDim + '-sum-type') == 0) {
							this.paramRequestObject.set(relatedDim + '-sum-type', 1);
						}
						fieldset.down('[name=sum_type_' + relatedDim + ']').setValue(this.paramRequestObject.get(relatedDim + '-sum-type'));
						indexesCombo.setDisabled(true);
						if (!this.inRebuild && (this.onChange != null))
							this.onChange(uiScope, relatedDim, true, false, false);
						if (this.onModifyHeight)
							this.onModifyHeight(this.pluginOwner);
690e0a87   Benjamin Renard   Add sum in table ...
458
					},
4dbd97ec   Menouard AZIB   Goal is reached b...
459
460
461
462
463
464
465
					collapse: function (fieldset, eOpts) {
						indexesCombo.setDisabled(false);
						this.paramRequestObject.set(relatedDim + '-sum-type', 0);
						if (!this.inRebuild && (this.onChange != null))
							this.onChange(uiScope, relatedDim, false, true, false);
						if (this.onModifyHeight)
							this.onModifyHeight(this.pluginOwner);
29dfb596   Benjamin Renard   Rework of ParamAr...
466
467
					},
					scope: this
690e0a87   Benjamin Renard   Add sum in table ...
468
				}
9a9c6ebf   Elena.Budnik   sum in variable r...
469
			});
690e0a87   Benjamin Renard   Add sum in table ...
470
			this.add(sumRangeFieldSet);
4dbd97ec   Menouard AZIB   Goal is reached b...
471
			this.add(ruler);
690e0a87   Benjamin Renard   Add sum in table ...
472
		}
7ac3ce50   Benjamin Renard   First implementat...
473
		return indexesCombo;
9a9c6ebf   Elena.Budnik   sum in variable r...
474
	},
4dbd97ec   Menouard AZIB   Goal is reached b...
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565

	buildTemplateArguments: function (arguments, uiScope) {
		var me = this;
		Ext.Object.each(arguments, function (key, argument) {
			switch (argument.type) {
				case 'float':
					var argumentField = Ext.create('Ext.form.NumberField', {
						argId: 'template_' + key,
						fieldLabel: argument.name,
						decimalPrecision: 3,
						allowBlank: false,
						value: parseFloat(argument.default),
						listeners: {
							change: function (field, newValue, oldValue, eOpts) {
								var template_args = me.paramRequestObject.get('template_args');
								if (!template_args)
									template_args = {};
								template_args[key] = newValue;
								me.paramRequestObject.set('template_args', template_args);
								if (!this.inRebuild && (me.onChange != null))
									me.onChange(uiScope, key, newValue, oldValue, true);
							},
							scope: me
						}
					});

					me.add(argumentField);
					break;
				case 'list':
					var items = [];
					Ext.Object.each(argument.items, function (itemKey, itemName) {
						items.push({ 'key': itemKey, 'value': itemName });
					});

					var itemsStore = Ext.create('Ext.data.Store', {
						fields: ['key', 'value'],
						data: items
					});

					var itemsCombo = Ext.create('Ext.form.ComboBox', {
						fieldLabel: argument.name,
						store: itemsStore,
						queryMode: 'local',
						displayField: 'value',
						valueField: 'key',
						value: argument.default,
						editable: false,
						argId: 'template_' + key,
						listeners: {
							change: function (field, newValue, oldValue, eOpts) {
								var template_args = me.paramRequestObject.get('template_args');
								if (!template_args)
									template_args = {};
								template_args[key] = newValue;
								me.paramRequestObject.set('template_args', template_args);
								if (!this.inRebuild && (me.onChange != null))
									me.onChange(uiScope, key, newValue, oldValue, true);
							},
							scope: me
						}

					});

					me.add(itemsCombo);
					break;
				case 'bool':
					var argumentField = Ext.create('Ext.form.Checkbox', {
						argId: 'template_' + key,
						fieldLabel: argument.name,
						value: (parseInt(argument.default) == 1),
						listeners: {
							change: function (field, newValue, oldValue, eOpts) {
								var template_args = me.paramRequestObject.get('template_args');
								if (!template_args)
									template_args = {};
								template_args[key] = newValue;
								me.paramRequestObject.set('template_args', template_args);
								if (!this.inRebuild && (me.onChange != null))
									me.onChange(uiScope, key, newValue, oldValue, true);
							},
							scope: me
						}
					});

					me.add(argumentField);
					break;
				default:
					console.log('Template argument type not yet implemented: ' + argument.type);
			}
		});
	}
bf776dc8   Benjamin Renard   working
566
});