Blame view

js/app/views/SearchUI.js 22 KB
16035364   Benjamin Renard   First commit
1
2
3
4
5
6
7
8
9
10
/**
 * Project   : AMDA-NG
 * Name      : SearchUI.js
 * @class 	 amdaUI.SearchUI
 * @extends      Ext.container.Container 
 * @brief    Search Module UI definition (View)
 * @author CDA
 * @version $Id: SearchUI.js 2467 2014-07-10 16:06:26Z myriam $  
 */

3ab0bee9   Elena.Budnik   aprams with args ...
11
12
Ext.define('amdaUI.SearchUI', 
{
16035364   Benjamin Renard   First commit
13
14
15
16
17
18
19
	extend: 'Ext.container.Container',
	alias: 'widget.panelSearch',
	
	requires: [
	 	'amdaUI.CalculatorUI',
	 	'amdaUI.TimeSelectorUI',
	 	'extensions.SelectableTextArea',
51713556   Benjamin Renard   Templated paramet...
20
21
	 	'amdaUI.ParamArgumentsPlug',
		'amdaModel.RequestParamObject'
16035364   Benjamin Renard   First commit
22
23
	],    
 
3ab0bee9   Elena.Budnik   aprams with args ...
24
25
26
27
28
29
30
31
32
33
	constructor: function(config) 
	{	          
		this.init(config);
		this.callParent(arguments);	
		// load object into view    
		this.loadObject();
		
		var searchArgsPlug = this.getPlugin('search-param-components-plugin');
		if (searchArgsPlug)
			searchArgsPlug.onApply = this.onApplyParameterArgs;
16035364   Benjamin Renard   First commit
34
35
	},

3ab0bee9   Elena.Budnik   aprams with args ...
36
37
38
	addTT : function(newTTName,newTTid)
	{
		this.timeSelector.addTT(newTTName,newTTid);
16035364   Benjamin Renard   First commit
39
40
	},
	
3ab0bee9   Elena.Budnik   aprams with args ...
41
42
43
44
45
46
47
48
	addTTs : function(TTarray) 
	{
		// set TTTab	    
		this.timeSelector.setTTTab(TTarray);
	},
        
	addParam : function(newParamName, isLeaf, needArgs, components) 
	{
51713556   Benjamin Renard   Templated paramet...
49
		if (needArgs || components)
3ab0bee9   Elena.Budnik   aprams with args ...
50
51
52
53
				this.editParameterArgs(newParamName, components);
		else
			this.addParamInEditor(newParamName);
	},
33ce72a7   Benjamin Renard   Do not show argum...
54
        
3ab0bee9   Elena.Budnik   aprams with args ...
55
56
57
58
59
60
61
	addParamInEditor : function(param) 
	{
		var selection = this.constructionField.getSelection();
		this.constructionField.setValue(selection.beforeText + param + selection.afterText);
		this.constructionField.focus();
		this.constructionField.setCaretPosition(this.constructionField.getValue().length);
	},
7ac3ce50   Benjamin Renard   First implementat...
62
        
3ab0bee9   Elena.Budnik   aprams with args ...
63
64
65
66
67
	onApplyParameterArgs : function(uiScope, paramRequestObject) 
	{
		var fullParam = paramRequestObject.getParamFullName();
		uiScope.addParamInEditor(fullParam);
	},
16035364   Benjamin Renard   First commit
68
        
3ab0bee9   Elena.Budnik   aprams with args ...
69
70
	editParameterArgs: function(name, components) 
	{
29dfb596   Benjamin Renard   Rework of ParamAr...
71
72
		var paramObj = amdaModel.RequestParamObject.getEmptyObj();
		paramObj.paramid = name;
63ac7745   Benjamin Renard   Support component...
73
        	
3ab0bee9   Elena.Budnik   aprams with args ...
74
75
76
77
78
79
80
81
82
83
84
		if (components) {
			if (components['index1']) {
				paramObj['dim1-index'] = components['index1'];
				++paramObj['type'];
			}
			
			if (components['index2']) {
				paramObj['dim2-index'] = components['index2'];
				++paramObj['type'];
			}
		}
63ac7745   Benjamin Renard   Support component...
85
        	
3ab0bee9   Elena.Budnik   aprams with args ...
86
87
88
89
90
91
		var paramArgsPlug = this.getPlugin('search-param-components-plugin');
		if (paramArgsPlug) {
			var workinRequestParamObject = Ext.create('amdaModel.RequestParamObject', paramObj);
			paramArgsPlug.show('search-param-components-plugin', workinRequestParamObject);
		}
	},
7ac3ce50   Benjamin Renard   First implementat...
92
        
3ab0bee9   Elena.Budnik   aprams with args ...
93
94
95
96
97
	/**
	* Set Start-Stop from parameter info (Local & MyData)
	*/ 
	setTimeFromData : function(obj) 
	{																				
8f85fbfa   Benjamin Renard   Remove deprecated...
98
99
		if (!obj.start || !obj.stop)
			return;
3ab0bee9   Elena.Budnik   aprams with args ...
100
101
102
103
104
		var dateStart = new Date(obj.start.replace(/[T|Z]/g,' ').replace(/\-/g,'\/')); 
		var dateStop = new Date(obj.stop.replace(/[T|Z]/g,' ').replace(/\-/g,'\/')); 
		
		this.down('form').getForm().setValues({ startDate : dateStart, stopDate : dateStop });
	},
16035364   Benjamin Renard   First commit
105
        
3ab0bee9   Elena.Budnik   aprams with args ...
106
107
108
109
110
	setObject : function(obj) 
	{             
		this.object = obj;  
		this.loadObject();
	},
16035364   Benjamin Renard   First commit
111
112
113
114
	
	/**
	 * update this.object from form
	 */
3ab0bee9   Elena.Budnik   aprams with args ...
115
116
117
118
119
120
121
	updateObject : function()
	{    
		// get the basic form
		var basicForm = this.formPanel.getForm();
		// get the timeSource selected
		var timeSource = this.timeSelector.getActiveTimeSource();	    
		var updateStatus = true;
16035364   Benjamin Renard   First commit
122

3ab0bee9   Elena.Budnik   aprams with args ...
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
		var fieldsWithoutName = basicForm.getFields().items;
		Ext.Array.each(fieldsWithoutName, function(item, index,allItems)
		{
			if(item !== this.fieldName) 
			{ 		     
				if (!item.isValid()) 
				{
					if ((timeSource === amdaModel.AmdaTimeObject.inputTimeSrc[0]) &&
							((item.name == 'startDate') || (item.name == 'stopDate') || (item.name == 'duration'))) {
								updateStatus = true;
						}
					else {
						// set update isn't allowed
						updateStatus = false;
						return false;
					}       
				}
			}
		}, this);
16035364   Benjamin Renard   First commit
142

3ab0bee9   Elena.Budnik   aprams with args ...
143
		if (timeSource === amdaModel.AmdaTimeObject.inputTimeSrc[0] // timeSource  'TimeTable'
16035364   Benjamin Renard   First commit
144
145
		    && this.timeSelector.TTGrid.getStore().count() == 0) {

3ab0bee9   Elena.Budnik   aprams with args ...
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
			Ext.Msg.show({
				title: 'Warning', msg: 'You chose Time Selection `by TimeTable` but no timeTable was added!'
				+'<br>You must add one or choose Time Selection `by Interval`', 
				icon: Ext.MessageBox.WARNING, buttons: Ext.Msg.OK
			}); 
			updateStatus = false;    
		}
		// if the update is allowed
		if (updateStatus) 
		{
		/// real object update
		// update TimeTable object with the content of form
			basicForm.updateRecord(this.object);
			this.object.set('timesrc', timeSource);
			// set valid intervals into TimeTable object
			if (timeSource === amdaModel.AmdaTimeObject.inputTimeSrc[0]) {	      
				this.object.set('timeTables',this.timeSelector.TTGrid.getStore().data.items);
			}
		}    
		// return the update status
		return updateStatus;	    
16035364   Benjamin Renard   First commit
167
168
169
	},
	
	/**
3ab0bee9   Elena.Budnik   aprams with args ...
170
171
172
173
174
175
176
177
		* load this.object into form
		*/
	loadObject : function()
	{
		// load object into form		
		this.formPanel.getForm().loadRecord(this.object);       
		// set object's TTs into the timeselector
		this.addTTs(this.object.get('timeTables'));	 
16035364   Benjamin Renard   First commit
178
179
180
181
182
	},
	
	/**
	 * save method called by Save button to launch the save process
	 */
3ab0bee9   Elena.Budnik   aprams with args ...
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
	saveProcess : function(toRename)
	{
		// if the TimeTable object has been modified	  
		if (this.object.dirty) 
		{            
			// Search module
			var searchModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.search.id);//('search-win');           
			// if the name has been modified this is a creation
			if (this.object.isModified('name'))
			{
				// if object already has an id : it's a 'rename' of an existing Condition
				if (this.object.get('id'))
				{
					// the context Node is the parent node of current edited one
					var contextNode = searchModule.linkedNode.parentNode;
					// link a new node to the TimeTableModule
					searchModule.createLinkedNode();
					// set the contextNode
					searchModule.linkedNode.set('contextNode',contextNode);
					// create a new object linked
					searchModule.createObject(this.object.getJsonValues());            
					var searchObj = searchModule.linkedNode.get('object');                           
					// synchronisation of objects		     
					this.object = searchObj; 		      
					if (toRename) searchModule.linkedNode.toRename = true;
				}               
				searchModule.linkedNode.create();
			} else {           
				searchModule.linkedNode.set('contextNode',searchModule.contextNode); 
				// this.object.fireEvent('modify');
				searchModule.linkedNode.update();
			}
		}
16035364   Benjamin Renard   First commit
216
217
218
219
220
	},
	
	/**
	 * overwrite metod called by Save button
	 */
3ab0bee9   Elena.Budnik   aprams with args ...
221
222
223
224
225
226
	overwriteProcess : function(btn)
	{	
		if (btn == 'cancel') return;	
					
		this.fieldName.clearInvalid();    
		this.saveProcess(true);		
16035364   Benjamin Renard   First commit
227
228
229
230
231
	},
	
	/**
	 * search method called by 'Do Search' button to launch the search process
	 */
3ab0bee9   Elena.Budnik   aprams with args ...
232
233
234
235
236
237
	doSearch : function()
	{	     
		var searchModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.search.id);
		searchModule.linkedNode.execute();
		// fire execution  
		//  this.object.fireEvent('execute',this.object.dirty);
16035364   Benjamin Renard   First commit
238
239
	},
        
3ab0bee9   Elena.Budnik   aprams with args ...
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
	/**
	*   Check if brackets are balanced
	*/        
	isBalanced : function(str)
	{ 
		str =  (""+str).replace(/[^()\[\]{}]/g, ""); 
		var bracket = {
						"]": "[",
						"}": "{",
						")": "("
					},
		openBrackets = [], 
		isClean = true,
		i = 0,
		len = str.length;
16035364   Benjamin Renard   First commit
255

3ab0bee9   Elena.Budnik   aprams with args ...
256
257
258
259
260
261
262
263
264
265
266
		for(; isClean && i<len; i++ ){                
				if( bracket[ str[ i ] ] ){
					isClean = ( openBrackets.pop() === bracket[ str[ i ] ] );
				}else{
					openBrackets.push(str[i]);
				}
		}
		if (!(isClean && !openBrackets.length)) return 'Brackets are not balanced';
			
		return true; 
	},
16035364   Benjamin Renard   First commit
267
        
3ab0bee9   Elena.Budnik   aprams with args ...
268
269
270
271
272
273
274
275
276
277
278
	/**
	* Update constructionField (Search Condition) in window search        
	*/     
	updateConstruct : function(oldval,newval) 
	{
		var expression = this.constructionField.value;
		oldval = oldval.replace(/[(]/g,"\\(");
		oldval = oldval.replace(/[)]/g,"\\)");	
		var reg=new RegExp(oldval, "g");
		expression = expression.replace(reg, newval);
		this.constructionField.setValue(expression);
16035364   Benjamin Renard   First commit
279
280
281
282
283
284
	},

	/**
	 * Check if changes were made before closing window 
	 * @return true if changes
	 */	   
3ab0bee9   Elena.Budnik   aprams with args ...
285
286
287
	fclose : function() 
	{
		var form = this.formPanel.getForm();
16035364   Benjamin Renard   First commit
288
289
290
291
		var isDirty = form.isDirty();
		return isDirty;
	},
	
3ab0bee9   Elena.Budnik   aprams with args ...
292
293
294
295
296
297
	/**
	*  Component configiration / init
	*/
	init : function(config)	
	{	  
		this.timeSelector = new amdaUI.TimeSelectorUI({id: 'SearchTimeSelector',flex: 2});
16035364   Benjamin Renard   First commit
298

3ab0bee9   Elena.Budnik   aprams with args ...
299
300
		this.fieldName = new Ext.form.field.Text({
				labelAlign: 'top', itemId: 'formParamName',
5e6d074f   Elena.Budnik   infobull for para...
301
				fieldLabel: 'Request Name',
69c5bc1e   Benjamin Renard   Add modif. time f...
302
				labelPad: 0,
3ab0bee9   Elena.Budnik   aprams with args ...
303
				name : 'name',
69c5bc1e   Benjamin Renard   Add modif. time f...
304
				width: 165,
3ab0bee9   Elena.Budnik   aprams with args ...
305
306
307
308
309
310
311
312
313
314
				allowBlank : false,
				stripCharsRe: /(^\s+|\s+$)/g,
				validateOnChange: false,
				validateOnBlur: false,
				validFlag: false,
				validator : function() 
				{
					return this.validFlag;
				}
		});
16035364   Benjamin Renard   First commit
315

3ab0bee9   Elena.Budnik   aprams with args ...
316
317
318
		this.constructionField = new extensions.SelectableTextArea(
		{
				labelAlign: 'top',
69c5bc1e   Benjamin Renard   Add modif. time f...
319
				labelPad: 0,
3ab0bee9   Elena.Budnik   aprams with args ...
320
				itemId: 'formSearchCondition',
5e6d074f   Elena.Budnik   infobull for para...
321
				fieldLabel:'<img amda_clicktip="constructParameter" src="js/resources/images/16x16/info_mini.png"/>&nbsp;Data Mining Condition',
3ab0bee9   Elena.Budnik   aprams with args ...
322
323
324
325
326
				allowBlank : false, blankText : 'Condition expression is required',
				name: 'expression',
				validateOnChange: false,
				validateOnBlur: false,
				validator : this.isBalanced,
69c5bc1e   Benjamin Renard   Add modif. time f...
327
				flex : 2,
3ab0bee9   Elena.Budnik   aprams with args ...
328
329
330
331
332
333
334
335
336
337
338
339
				listeners :
				{
					render : function(o,op)
					{
						var me = this;
						var el = me.bodyEl;
						var dropTarget = Ext.create('Ext.dd.DropTarget', el, 
						{
							ddGroup: 'explorerTree',
							notifyEnter : function(ddSource, e, data){ },
							notifyOver  : function(ddSource, e, data)
							{ 
8497e83c   Elena.Budnik   redmine 5515
340
								if (data.records[0].get('nodeType') == 'localParam' && data.records[0].get('notyet')) {
3ab0bee9   Elena.Budnik   aprams with args ...
341
342
343
										this.valid = false;
										return this.dropNotAllowed;   
								}
8497e83c   Elena.Budnik   redmine 5515
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
								if (((data.records[0].get('nodeType') == 'localParam')   ||
										(data.records[0].get('nodeType') == 'remoteParam') || 
										(data.records[0].get('nodeType') == 'remoteSimuParam') ||
										(data.records[0].get('nodeType') == 'derivedParam') ||
										(data.records[0].get('nodeType') == 'myDataParam') ||
										(data.records[0].get('nodeType') == 'alias')) &&
										(data.records[0].isLeaf() || data.records[0].get('isParameter'))  &&
										!data.records[0].data.disable)
								{
									this.valid = true;
									return this.dropAllowed;
								}
								
								this.valid = false;
								return this.dropNotAllowed;
3ab0bee9   Elena.Budnik   aprams with args ...
359
360
361
362
363
364
365
366
367
368
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
							},
							notifyDrop  : function(ddSource, e, data)
							{
								if (!this.valid) return false;
															
								var nameToSent;
								var components = null;
								switch (data.records[0].get('nodeType'))
								{
									case 'localParam' :
									case 'remoteParam' :
									case 'remoteSimuParam' :    
										nameToSent = data.records[0].get('id');
										if (data.records[0].get('alias')!= "" )
											nameToSent = "#"+data.records[0].get('alias');
											var component_info = data.records[0].get('component_info');
											if (component_info && component_info.parentId) 
											{													
												if ( component_info.index1 && component_info.index2 )
												{															 
													nameToSent = component_info.parentId;
													components = [];												
													if (component_info.index1)
														components['index1'] = component_info.index1;
													if (component_info.index2)
														components['index2'] = component_info.index2;
												}	
												if ( data.records[0].get('needsArgs') )
												{															
													nameToSent = component_info.parentId;	
													if (component_info.index1)
													{
														components = [];	
														components['index1'] = component_info.index1;
													}
												}													
											}
											break;
										case 'alias' :
											nameToSent = "#"+data.records[0].get('text');
											break;
										case 'derivedParam' :
											nameToSent = "ws_"+data.records[0].get('text');
											break;
										case 'myDataParam' :
											var name = data.records[0].get('text');
											nameToSent = "wsd_"+name;
											var size = data.records[0].get('size');
											if (size &&  size > 1) {
												nameToSent += "(0)";
												myDesktopApp.warningMsg("parameter "+name+" is array of size: "+size+"<br/>Please put index");
											}
											break;
										default :
											return false;
									}
									var searchModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.search.id);
									
b1fab76f   Benjamin Renard   Give the possibil...
417
418
419
420
421
422
423
424
425
426
									if (searchModule) {
										if (data.records[0].get('predefinedArgs')) {
											searchModule.parseTemplatedParam(nameToSent, function(param_info) {
												searchModule.addParam(param_info.paramid, data.records[0].get('leaf'), true, components, param_info.template_args);
											});
										}
										else {
											searchModule.addParam(nameToSent, data.records[0].get('leaf'), data.records[0].get('needsArgs'), components);
										}
									}
3ab0bee9   Elena.Budnik   aprams with args ...
427
428
429
430
431
432
									return true;
								}
						});
					}
				}
		});
16035364   Benjamin Renard   First commit
433

69c5bc1e   Benjamin Renard   Add modif. time f...
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
		var samplingmode_store = new Ext.data.ArrayStore({
			fields: ['id', 'name'],
			data: [
				['timestep', 'Time Step'],
				['refparam', 'Ref. Parameter']
			]
		});

		this.timeStepField = new Ext.form.NumberField({
			fieldLabel: '<img amda_clicktip="resamplingStep" src="js/resources/images/16x16/info_mini.png"/>&nbsp;Time Step (sec)',
			labelAlign: 'top',
			labelPad: 0,
			blankText : 'Time Step is required',
			name : 'sampling',
			minValue : 0.001,
			decimalPrecision : 10,
			hideTrigger: true,
			width: 165,
b78325f1   Benjamin Renard   Add validation fo...
452
453
454
455
456
457
458
459
460
461
462
463
464
			validateOnBlur: false,
			allowBlank: false,
			isValid: function() {
				var me = this,
					disabled = me.disabled,
					validate = me.forceValidation || !disabled;
				
				if (!me.isVisible()) {
					return true;
				}

				return validate ? me.validateValue(me.processRawValue(me.getRawValue())) : disabled;
			}
69c5bc1e   Benjamin Renard   Add modif. time f...
465
466
467
468
469
470
471
472
473
		});

		this.refParamField = new Ext.form.TextField({
			fieldLabel: '<img amda_clicktip="resamplingRefParam" src="js/resources/images/16x16/info_mini.png"/>&nbsp;Reference Param.',
			labelAlign: 'top',
			labelPad: 0,
			name : 'reference_param',
			width: 165,
			hidden: true,
b78325f1   Benjamin Renard   Add validation fo...
474
			allowBlank: false,
69c5bc1e   Benjamin Renard   Add modif. time f...
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
			listeners: {
				afterrender: function(field, eOpts ){
					var paramTarget = new Ext.dd.DropTarget(field.el.dom,
						{
							ddGroup: 'explorerTree',
							notifyEnter: function(ddSource, e, data) {
							},
							notifyDrop: function(ddSource, e, data) {
								var selectedRecord = ddSource.dragData.records[0];
								switch (selectedRecord.$className) {
									case 'amdaModel.LocalParamNode'   :
									case 'amdaModel.RemoteParamNode'  :
									case 'amdaModel.RemoteSimuParamNode'  :
										if (!selectedRecord.get('isParameter') || selectedRecord.get('disable'))
											return false;
										if (selectedRecord.get('alias') != "" )
											field.setValue("#"+selectedRecord.get('alias'));
										else
											field.setValue(selectedRecord.get('id'));
										return true;
									case 'amdaModel.AliasNode'        :
										if (!selectedRecord.isLeaf())
											return false;
										field.setValue("#"+selectedRecord.get('text'));
										return true;
									case 'amdaModel.DerivedParamNode' :
										if (!selectedRecord.isLeaf())
											return false;
										field.setValue("ws_"+selectedRecord.get('text'));
										return true;
									case 'amdaModel.MyDataParamNode' :
										if (!selectedRecord.isLeaf())
											return false;
										field.setValue("wsd_"+selectedRecord.get('text'));
										return true;
									default:
										return false;
								}
								return true;
							}
						}
					);
				},
				scope: this
b78325f1   Benjamin Renard   Add validation fo...
519
520
521
522
523
524
525
526
527
528
529
			},
			isValid: function() {
				var me = this,
					disabled = me.disabled,
					validate = me.forceValidation || !disabled;

				if (!me.isVisible()) {
					return true;
				}

				return validate ? me.validateValue(me.processRawValue(me.getRawValue())) : disabled;
69c5bc1e   Benjamin Renard   Add modif. time f...
530
531
532
533
534
535
536
537
538
539
540
541
			}
		});

		this.samplingDefContainer = new Ext.container.Container({
			border: false,
			items: [
				this.timeStepField,
				this.refParamField
			],
			width: 165
		});

3ab0bee9   Elena.Budnik   aprams with args ...
542
543
544
545
546
547
548
549
550
		this.formPanel = new Ext.form.Panel(
		{
				region : 'center',  
				bodyStyle: { background : '#dfe8f6' },  
				border: false, buttonAlign: 'left',
				trackResetOnLoad: true,  //reset to the last loaded record
				layout : { 
					type : 'vbox',
					align: 'stretch',
69c5bc1e   Benjamin Renard   Add modif. time f...
551
					defaultMargins: {top: 5, left:5, bottom:10, right:10}
3ab0bee9   Elena.Budnik   aprams with args ...
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
				},
				id: 'formSearch',
				defaults: {
					border: false
				},
				items : [
				{ 
					xtype: 'container',
					flex: 2.5,
					layout: {
							type: 'hbox',  
							align: 'stretch'
					},
					items: [
						{
							flex: 3,
							xtype: 'container',
							border: false,
							layout: {
								type: 'table',
								columns: 3
							},
							defaultType: 'textfield',
							defaults: {
69c5bc1e   Benjamin Renard   Add modif. time f...
576
577
								labelAlign: 'top',
								labelPad: 0
3ab0bee9   Elena.Budnik   aprams with args ...
578
579
580
							},
							items: [   
								this.fieldName,
69c5bc1e   Benjamin Renard   Add modif. time f...
581
								{ xtype: 'component', width: 45},
3ab0bee9   Elena.Budnik   aprams with args ...
582
								{
69c5bc1e   Benjamin Renard   Add modif. time f...
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
									fieldLabel: 'Last modification',
									xtype: 'displayfield',
									name : 'last_update',
									width: 165,
									renderer: function(value, field) {
										var tpl = new Ext.XTemplate('<p style="font-style:italic;color:gray;margin:0;">{date}</>');
										var mod_date = 'Not saved';
										if (value > 0)
											mod_date = Ext.Date.format(new Date(value*1000), "Y-m-d\\TH:i:s");
										return tpl.apply({date: mod_date});
									},
								},
								{
                                                                	xtype: 'combo',
									fieldLabel: 'Sampling mode',
									name: 'sampling_mode',
									queryMode: 'local',
									editable: false,
									valueField: 'id',
									displayField: 'name',
									store: samplingmode_store,
									value: samplingmode_store.first(),
									width: 165,
									listeners: {
										change: function(field, value) {
											this.timeStepField.setVisible(value != 'refparam');
											this.refParamField.setVisible(value == 'refparam');
										},
										scope: this
									}
								},
								{
									xtype:'component', width: 45
3ab0bee9   Elena.Budnik   aprams with args ...
616
								},
69c5bc1e   Benjamin Renard   Add modif. time f...
617
								this.samplingDefContainer,
3ab0bee9   Elena.Budnik   aprams with args ...
618
619
								{
									xtype :'displayfield', width: 165,
69c5bc1e   Benjamin Renard   Add modif. time f...
620
621
622
									hideLabel: true,
									fieldStyle: 'display:inline-block;text-align:right',
									value: '<b style="top: 50%;position: relative;">Data Gap&nbsp;<img amda_clicktip="dataGap" src="js/resources/images/16x16/info_mini.png"/></b>'
3ab0bee9   Elena.Budnik   aprams with args ...
623
624
								},
								{
69c5bc1e   Benjamin Renard   Add modif. time f...
625
									xtype:'component', width: 45
3ab0bee9   Elena.Budnik   aprams with args ...
626
								},
3ab0bee9   Elena.Budnik   aprams with args ...
627
628
629
630
631
632
								{
									xtype: 'numberfield',  name: 'gap',
									fieldLabel: 'if no data for interval', minValue : 1,
									labelAlign: 'top', hideTrigger : true, width: 165
								},
								{
0f7460c1   Elena.Budnik   redmine 5518
633
									xtype: 'textarea',
3ab0bee9   Elena.Budnik   aprams with args ...
634
									name: 'description', 
0f7460c1   Elena.Budnik   redmine 5518
635
									fieldLabel:'Description',
3ab0bee9   Elena.Budnik   aprams with args ...
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
									width: 375, height: 70,
									colspan: 3
								}
							]	
						},   
						this.timeSelector
					]
				},
				this.constructionField
			],
			fbar: [
				{
					text: 'Do Search',
					scope : this,
					handler: function(button){
							// update object with user's values
							// if the return is true (object had been updated)
							if(this.updateObject()){
								// launch the search process                           
								this.doSearch();			   			 
							}
					}
				},
				{
					text: 'Save Request',
					scope: this,
					handler: function()
					{
						// update object with user's values 
						// if the return is true (object had been updated)
						if (this.updateObject())
						{
							var searchModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.search.id);	
							if (!searchModule)
								return;
							var me = this;
						
							searchModule.linkedNode.isValidName(this.fieldName.getValue(), function (res) {
								if (!res)
								{
									me.fieldName.validFlag = 'Error during object validation';
									myDesktopApp.errorMsg(me.fieldName.validFlag);
									me.fieldName.validate();
									return;
								}
						
								if (!res.valid)
								{
									if (res.error)
									{
										if (res.error.search('subtree') != -1) {  							
											Ext.MessageBox.show({title:'Warning', 
												msg: res.error+'<br/>Do you want to overwrite it?',
												width: 300,
												buttons: Ext.MessageBox.OKCANCEL, 
												fn : me.overwriteProcess,
												icon: Ext.MessageBox.WARNING,
												scope : me
											});
											me.fieldName.validFlag = true;
										}
										else
											me.fieldName.validFlag = res.error;
									}
									else
									{
										me.fieldName.validFlag = 'Invalid object name';
										myDesktopApp.errorMsg(me.fieldName.validFlag);
									}
									me.fieldName.validate();
									return;
								}
									
								me.fieldName.validFlag = true;
								me.fieldName.validate();
								me.saveProcess(false);
							});  
						}                              
					}
				},
				{
					text: 'Reset',
					scope : this,
					handler: function()
					{
						var searchModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.search.id);			
						searchModule.createLinkedNode();
						searchModule.createObject();
						this.setObject(searchModule.getLinkedNode().get('object'));                           
					}
				}
			] 
		});		
16035364   Benjamin Renard   First commit
729
                
3ab0bee9   Elena.Budnik   aprams with args ...
730
731
732
733
734
735
736
737
738
739
		var myConf = {
			layout: 'border',
			defaults: { layout: 'fit', border: false },
			items: 
			[
				this.formPanel,                         
				{
					xtype: 'panel', region: 'south',
					title: 'Information',
					collapsible: true,
42863f42   Elena.Budnik   collapseMode: "he...
740
					collapseMode: 'header',
3ab0bee9   Elena.Budnik   aprams with args ...
741
742
743
744
745
746
747
748
749
750
751
752
753
754
					height: 100,
					autoHide: false,
					iconCls: 'icon-information',
					bodyStyle: 'padding:5px',
					loader: 
					{
						autoLoad: true,
						url: helpDir+'dataMiningHOWTO'
					}				 
				}  
			],
			plugins: [ 
				{ptype: 'calculator', myBtns:[], context: 'Condition'}, 
				{ptype: 'paramArgumentsPlugin', pluginId: 'search-param-components-plugin'}
5e6d074f   Elena.Budnik   infobull for para...
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
			],
			listeners:{
				click: {
					element: 'el',
					fn: function(e,t) { 
						var me = t,
						text = me.getAttribute('amda_clicktip');
						if (text) {
							e.preventDefault();
							AmdaAction.getInfo({name : text}, function(res,e) {					    					   
								if (res.success) myDesktopApp.infoMsg(res.result);
							}); 
						}
					}
				}
			}
3ab0bee9   Elena.Budnik   aprams with args ...
771
		};
16035364   Benjamin Renard   First commit
772

647d796e   Elena.Budnik   small nettoyage
773
		Ext.apply(this, Ext.apply(arguments, myConf));	    	    
3ab0bee9   Elena.Budnik   aprams with args ...
774
	}
16035364   Benjamin Renard   First commit
775
776
    
});