Blame view

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

4dbd97ec   Menouard AZIB   Goal is reached b...
24
25
	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) {
255b183d   Benjamin Renard   Fix
52
					paramRequestObject.set("channels-param-info", paramInfo.data.tables);
4dbd97ec   Menouard AZIB   Goal is reached b...
53

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

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

4dbd97ec   Menouard AZIB   Goal is reached b...
124
	getDimensionMinMaxValues: function (relatedDim, data) {
29dfb596   Benjamin Renard   Rework of ParamAr...
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
		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...
154
	getDimensionTitle: function (relatedDim, data) {
29dfb596   Benjamin Renard   Rework of ParamAr...
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
		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...
170
171

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

bb6e93d9   Benjamin Renard   Implement templat...
186
			this.paramRequestObject.set('template_args', templateArgsValues);
0314bd32   Benjamin Renard   Keep a registry o...
187
		}
4dbd97ec   Menouard AZIB   Goal is reached b...
188
189


bb6e93d9   Benjamin Renard   Implement templat...
190
191
		//Init values in interface
		this.items.each(function (item) {
29dfb596   Benjamin Renard   Rework of ParamAr...
192
193
194
195
			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...
196

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

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

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

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

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

7ac3ce50   Benjamin Renard   First implementat...
319
320
		//Add combo box
		var indexesStore = Ext.create('Ext.data.Store', {
4dbd97ec   Menouard AZIB   Goal is reached b...
321
322
			fields: ['key', 'value'],
			data: indexes
7ac3ce50   Benjamin Renard   First implementat...
323
324
		});

7ac3ce50   Benjamin Renard   First implementat...
325
		var indexesCombo = Ext.create('Ext.form.ComboBox', {
4dbd97ec   Menouard AZIB   Goal is reached b...
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
			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...
344
		});
4dbd97ec   Menouard AZIB   Goal is reached b...
345

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

690e0a87   Benjamin Renard   Add sum in table ...
348
		if (relatedTable) {
29dfb596   Benjamin Renard   Rework of ParamAr...
349
			var sumTypes = Ext.create('Ext.data.Store', {
1df8e90c   Benjamin Renard   Add selection for...
350
351
				fields: ['type', 'name'],
				data: [
4dbd97ec   Menouard AZIB   Goal is reached b...
352
353
					{ 'type': 1, 'name': 'Between Values' },
					{ 'type': 2, 'name': 'Between Indexes' }
1df8e90c   Benjamin Renard   Add selection for...
354
355
				]
			});
29dfb596   Benjamin Renard   Rework of ParamAr...
356
			var sumItems = [
4dbd97ec   Menouard AZIB   Goal is reached b...
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
				{
					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...
379
				},
4dbd97ec   Menouard AZIB   Goal is reached b...
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
437
438
439
440
441
442
443
				{
					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 ...
444
			];
4dbd97ec   Menouard AZIB   Goal is reached b...
445

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

	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...
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
				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
599
600
						allowBlank: false,
						format: 'Y/m/d H:i:s.u',
98c92bbf   Erdogan Furkan   #10557 - Done (Ma...
601
602
603
604
605
606
607
608
						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
609
610
								if(field.isValid()){
									template_args[key] = (newValue.getTime() - newValue.getTimezoneOffset() * 60000)/1000.;
98c92bbf   Erdogan Furkan   #10557 - Done (Ma...
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
								}
								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...
627
628
629
630
631
				default:
					console.log('Template argument type not yet implemented: ' + argument.type);
			}
		});
	}
bf776dc8   Benjamin Renard   working
632
});