Blame view

js/app/views/ParamArgumentsUI.js 19.3 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
	inRebuild: false,

3e77ccb3   Benjamin Renard   Add missing requires
24
25
26
27
	requires: [
		'amdaPlotObj.PlotObjectConfig'
	],

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

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

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

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

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

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

29dfb596   Benjamin Renard   Rework of ParamAr...
53
54
55
		if (explorerModule) {
			explorerModule.getParamInfo(paramRequestObject.get('paramid'), function (paramInfo) {
				if (paramInfo) {
255b183d   Benjamin Renard   Fix
56
					paramRequestObject.set("channels-param-info", paramInfo.data.tables);
4dbd97ec   Menouard AZIB   Goal is reached b...
57

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

4dbd97ec   Menouard AZIB   Goal is reached b...
92
	initDimension: function (relatedDim, data) {
29dfb596   Benjamin Renard   Rework of ParamAr...
93
94
95
96
97
98
99
100
		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...
101
					myDesktopApp.warningMsg('Min/Max ' + this.getDimensionTitle(relatedDim, data) + ' values are undefined<br/>Arbitrary values are taken');
29dfb596   Benjamin Renard   Rework of ParamAr...
102
103
104
105
106
					minmax = {
						'min': 10,
						'max': 10000
					};
				}
4dbd97ec   Menouard AZIB   Goal is reached b...
107
108
109
110
				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...
111
112
113
114
115
116
			}
			return true;
		}
		return false;
	},

4dbd97ec   Menouard AZIB   Goal is reached b...
117
	getDimensionMinMaxValues: function (relatedDim, data) {
29dfb596   Benjamin Renard   Rework of ParamAr...
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
143
144
145
146
		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...
147
	getDimensionTitle: function (relatedDim, data) {
29dfb596   Benjamin Renard   Rework of ParamAr...
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
		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...
163
164

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

bb6e93d9   Benjamin Renard   Implement templat...
179
			this.paramRequestObject.set('template_args', templateArgsValues);
0314bd32   Benjamin Renard   Keep a registry o...
180
		}
4dbd97ec   Menouard AZIB   Goal is reached b...
181
182


bb6e93d9   Benjamin Renard   Implement templat...
183
184
		//Init values in interface
		this.items.each(function (item) {
29dfb596   Benjamin Renard   Rework of ParamAr...
185
186
187
188
			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...
189

29dfb596   Benjamin Renard   Rework of ParamAr...
190
191
192
193
				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...
194
195
				item.setValue(this.paramRequestObject.get(item.argId + '-index'));
				var sumInRangeField = item.up().down('[name=sum_fieldset_' + item.argId + ']');
29dfb596   Benjamin Renard   Rework of ParamAr...
196
197
				if (sumInRangeField) {
					//Fill fields
4dbd97ec   Menouard AZIB   Goal is reached b...
198
199
200
201
202
					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...
203
204
205
206
207
						sumInRangeField.expand();
					}
					else {
						sumInRangeField.collapse();
					}
690e0a87   Benjamin Renard   Add sum in table ...
208
				}
4dbd97ec   Menouard AZIB   Goal is reached b...
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
266
267
268
269
			}
			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 ...
270
		if (tables) {
4dbd97ec   Menouard AZIB   Goal is reached b...
271
			Ext.each(tables, function (table, index) {
7ac3ce50   Benjamin Renard   First implementat...
272
273
274
275
				if (table.relatedDim == relatedDim)
					relatedTable = table;
			}, this);
		}
690e0a87   Benjamin Renard   Add sum in table ...
276
		return relatedTable;
4dbd97ec   Menouard AZIB   Goal is reached b...
277
278
279
280
281
282
283
284
285
286
	},

	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 ...
287
		var relatedTable = this.getRelatedTableFromDim(relatedDim, data.tables);
1df8e90c   Benjamin Renard   Add selection for...
288
		var dimSize = data.dimensions[relatedDim];
4dbd97ec   Menouard AZIB   Goal is reached b...
289

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

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

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

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

7ac3ce50   Benjamin Renard   First implementat...
318
		var indexesCombo = Ext.create('Ext.form.ComboBox', {
4dbd97ec   Menouard AZIB   Goal is reached b...
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
			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...
337
		});
4dbd97ec   Menouard AZIB   Goal is reached b...
338

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

690e0a87   Benjamin Renard   Add sum in table ...
341
		if (relatedTable) {
29dfb596   Benjamin Renard   Rework of ParamAr...
342
			var sumTypes = Ext.create('Ext.data.Store', {
1df8e90c   Benjamin Renard   Add selection for...
343
344
				fields: ['type', 'name'],
				data: [
4dbd97ec   Menouard AZIB   Goal is reached b...
345
346
					{ 'type': 1, 'name': 'Between Values' },
					{ 'type': 2, 'name': 'Between Indexes' }
1df8e90c   Benjamin Renard   Add selection for...
347
348
				]
			});
29dfb596   Benjamin Renard   Rework of ParamAr...
349
			var sumItems = [
4dbd97ec   Menouard AZIB   Goal is reached b...
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
				{
					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...
372
				},
4dbd97ec   Menouard AZIB   Goal is reached b...
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
433
434
435
436
				{
					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 ...
437
			];
4dbd97ec   Menouard AZIB   Goal is reached b...
438

9a9c6ebf   Elena.Budnik   sum in variable r...
439
440
			var sumRangeFieldSet = Ext.create('Ext.form.FieldSet', {
				title: relatedTable.variable ? title + " - Sum. in range" : "Sum. in range",
690e0a87   Benjamin Renard   Add sum in table ...
441
				collapsed: true,
4dbd97ec   Menouard AZIB   Goal is reached b...
442
				checkboxName: 'sum_checkbox_' + relatedDim,
9a9c6ebf   Elena.Budnik   sum in variable r...
443
				checkboxToggle: true,
4dbd97ec   Menouard AZIB   Goal is reached b...
444
				name: 'sum_fieldset_' + relatedDim,
9a9c6ebf   Elena.Budnik   sum in variable r...
445
				layout: {
4dbd97ec   Menouard AZIB   Goal is reached b...
446
447
448
					type: 'vbox',
					pack: 'start',
					align: 'stretch'
690e0a87   Benjamin Renard   Add sum in table ...
449
				},
29dfb596   Benjamin Renard   Rework of ParamAr...
450
				items: sumItems,
690e0a87   Benjamin Renard   Add sum in table ...
451
				listeners: {
4dbd97ec   Menouard AZIB   Goal is reached b...
452
453
454
455
456
457
458
459
460
461
					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 ...
462
					},
4dbd97ec   Menouard AZIB   Goal is reached b...
463
464
465
466
467
468
469
					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...
470
471
					},
					scope: this
690e0a87   Benjamin Renard   Add sum in table ...
472
				}
9a9c6ebf   Elena.Budnik   sum in variable r...
473
			});
690e0a87   Benjamin Renard   Add sum in table ...
474
			this.add(sumRangeFieldSet);
4dbd97ec   Menouard AZIB   Goal is reached b...
475
			this.add(ruler);
690e0a87   Benjamin Renard   Add sum in table ...
476
		}
7ac3ce50   Benjamin Renard   First implementat...
477
		return indexesCombo;
9a9c6ebf   Elena.Budnik   sum in variable r...
478
	},
4dbd97ec   Menouard AZIB   Goal is reached b...
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

	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;
98c92bbf   Erdogan Furkan   #10557 - Done (Ma...
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
				case 'int':
					var argumentField = Ext.create('Ext.form.NumberField', {
						argId: 'template_' + key,
						fieldLabel: argument.name,
						value: parseInt(argument.default),
						regex: /^\d+$/,
						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 'date':
					var argumentField = Ext.create('Ext.form.field.Date', {
						argId: 'template_' + key,
						fieldLabel: argument.name,
520baf1e   Benjamin Renard   Fix timezone
592
593
						allowBlank: false,
						format: 'Y/m/d H:i:s.u',
98c92bbf   Erdogan Furkan   #10557 - Done (Ma...
594
595
596
597
598
599
600
601
						minValue:'1970/01/01 00:00:00.000',
						value: parseInt(argument.default),
						listeners: {
							change: function (field, newValue, oldValue, eOpts) {
								var template_args = me.paramRequestObject.get('template_args');
								if (!template_args)
									template_args = {};
								
520baf1e   Benjamin Renard   Fix timezone
602
603
								if(field.isValid()){
									template_args[key] = (newValue.getTime() - newValue.getTimezoneOffset() * 60000)/1000.;
98c92bbf   Erdogan Furkan   #10557 - Done (Ma...
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
								}
								else{
									template_args[key] = 0;
								}
								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;
4dbd97ec   Menouard AZIB   Goal is reached b...
620
621
622
623
624
				default:
					console.log('Template argument type not yet implemented: ' + argument.type);
			}
		});
	}
bf776dc8   Benjamin Renard   working
625
});