Blame view

js/app/views/CatalogUI.js 18.2 KB
f792a3de   elena   catalog ihm
1
2
3
4
5
6
7
8
9
10
11
12
/**
 * Project       AMDA-NG
 * Name          CatalogUI.js
 * @class 	 amdaUI.catalogUI
 * @extends      Ext.container.Container
 * @brief	 Catalog Module UI definition (View)
 * @author 	 elena
 */

Ext.define('amdaUI.CatalogUI', {
	extend: 'Ext.container.Container',
	alias: 'widget.panelCatalog',
f9c8b272   elena   edit catalog
13
14
15
16
17
	
	requires: [
		'Ext.grid.plugin.BufferedRenderer'
	],
	
d18b535d   elena   catalog draft + c...
18
	isCatalog : true,
f792a3de   elena   catalog ihm
19
	
1340621c   Elena.Budnik   error msg when up...
20
	constructor: function(config) {
70aabdee   elena   catalog draft
21
		this.init(config);
f9c8b272   elena   edit catalog
22
23
		this.callParent(arguments);
		this.toReconfigure = true;
70aabdee   elena   catalog draft
24
		if (this.object) this.loadObject();	         
f792a3de   elena   catalog ihm
25
26
	},
	
1340621c   Elena.Budnik   error msg when up...
27
	setObject : function (object, toReconfigure) {	
f9c8b272   elena   edit catalog
28
29
30
31
		if (toReconfigure) 
			this.toReconfigure = true;
		// set object	        
		this.object = object;		 
048b4d77   elena   catalogs +
32
33
34
		// load object into view
		this.loadObject();
	},
f792a3de   elena   catalog ihm
35
	
d18b535d   elena   catalog draft + c...
36
37
38
	/**
	 * set params description into this.object
	 */
1340621c   Elena.Budnik   error msg when up...
39
	setParamInfo : function(parameters) {
70aabdee   elena   catalog draft
40
41
42
43
44
45
		var params = [];
		Ext.Array.each(parameters, function(item, index) {
			params[index] = item;	     	  
		}, this);
		
		this.object.set('parameters', params);	  
f792a3de   elena   catalog ihm
46
47
48
49
	},
	
	/**
	 * update this.object from form
1340621c   Elena.Budnik   error msg when up...
50
51
	 */	 
	updateObject : function(){  
d18b535d   elena   catalog draft + c...
52
	// get the basic form	
1340621c   Elena.Budnik   error msg when up...
53
54
		var basicForm = this.formPanel.getForm();        
		var updateStatus = true;
d18b535d   elena   catalog draft + c...
55

1340621c   Elena.Budnik   error msg when up...
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
		var fieldsWithoutName = basicForm.getFields().items;
		Ext.Array.each(fieldsWithoutName, function(item, index,allItems){
			if(item !== this.fieldName) { 		     
				if (!item.isValid()) {
					// set update isn't allowed
					updateStatus = false;    
				}
			}
		}, this);
			// if the update is allowed
		if (updateStatus) {
		/// real object update
		// update TimeTable object with the content of form
			basicForm.updateRecord(this.object);	
		}
		// return the update status  
		return updateStatus;	    
d18b535d   elena   catalog draft + c...
73
	},
f792a3de   elena   catalog ihm
74
	
1340621c   Elena.Budnik   error msg when up...
75
	updateCount : function() {
d18b535d   elena   catalog draft + c...
76
77
		this.object.set('nbIntervals',this.TTGrid.getStore().getTotalCount());		
		this.formPanel.getForm().findField('nbIntervals').setValue(this.object.get('nbIntervals'));
1340621c   Elena.Budnik   error msg when up...
78
	}, 
f9c8b272   elena   edit catalog
79
	
1340621c   Elena.Budnik   error msg when up...
80
81
	onAfterInit:  function(result, e) 
	{
70aabdee   elena   catalog draft
82
		var me = this;
1340621c   Elena.Budnik   error msg when up...
83
84
85
86
		if (!result) {			
			myDesktopApp.errorMsg(e.message);
			Ext.defer(function(){Ext.Msg.toFront()},10);
			 
3768c8a8   Elena.Budnik   RowNumberer catalofs
87
			return;
1340621c   Elena.Budnik   error msg when up...
88
89
		}
		else if (!result.success)
f9c8b272   elena   edit catalog
90
91
92
93
94
		{
			if (result.message)
				myDesktopApp.errorMsg(result.message);
			else
				myDesktopApp.errorMsg('Unknown error during catalog cache initialisation');
1340621c   Elena.Budnik   error msg when up...
95
96

			Ext.defer(function(){Ext.Msg.toFront()},10);
f9c8b272   elena   edit catalog
97
98
			return;
		}
1340621c   Elena.Budnik   error msg when up...
99
		
f9c8b272   elena   edit catalog
100
101
		if (me.toReconfigure) 
		{          	
70aabdee   elena   catalog draft
102
103
104
105
			var fields = [], columns = [], i = 3, width, index;

			var fieldsConfig =  [{ name : 'start' },{ name : 'stop' },{ name: 'cacheId', type : 'int'},
				{ name: 'isNew', type : 'boolean', defaultValue: false },
f9c8b272   elena   edit catalog
106
				{ name: 'isModified', type : 'boolean', defaultValue: false}
70aabdee   elena   catalog draft
107
108
109
110
			];
			
			for (var j = 0; j < 5; j++) fields[j] =  Ext.create('Ext.data.Field', fieldsConfig[j]);
				
3768c8a8   Elena.Budnik   RowNumberer catalofs
111
112
113
114
115
116
117
118
119
120
			columns[0] = Ext.create('Ext.grid.column.RowNumberer', { width: 50,
								renderer: function(value, metaData, record){
									var msg = record.index;
									if (record.get('isNew') || record.get('isModified')) {
										msg += ' *';
										metaData.style = 'font-weight: bold'
									}
									return msg;
								}
							});
d18b535d   elena   catalog draft + c...
121

3768c8a8   Elena.Budnik   RowNumberer catalofs
122
123
124
			columns[1] = Ext.create('Ext.grid.column.Column', { text: 'Start Time', sortable : true, dataIndex: 'start',  
						width : 120, menuDisabled: true, editor : { xtype:'datefield', allowBlank:false, hideTrigger: true, format : 'Y-m-d\\TH:i:s'}});
			columns[2] = Ext.create('Ext.grid.column.Column', { text: 'Stop Time', sortable : true,  dataIndex: 'stop',  
f9c8b272   elena   edit catalog
125
						width : 120, menuDisabled: true, editor : { xtype:'datefield', allowBlank:false, hideTrigger: true,  format : 'Y-m-d\\TH:i:s'}});
70aabdee   elena   catalog draft
126
127
		
			Ext.Array.each(result.parameters, function(obj) 
c865df36   Elena.Budnik   dateTime datatype...
128
129
			{			 
				index = 'param'+(i-1).toString();
3768c8a8   Elena.Budnik   RowNumberer catalofs
130

70aabdee   elena   catalog draft
131
				fields[i+2] = Ext.create('Ext.data.Field',{ name : index });
1340621c   Elena.Budnik   error msg when up...
132
			
c865df36   Elena.Budnik   dateTime datatype...
133
134
				if (obj.type == 1) // dateTime
				{
3768c8a8   Elena.Budnik   RowNumberer catalofs
135
					columns[i] = Ext.create('Ext.grid.column.Column', { text: obj.name, sortable : true,  dataIndex: index,  
c865df36   Elena.Budnik   dateTime datatype...
136
137
138
139
140
141
						width : 120, menuDisabled: true, editor : { xtype:'datefield', allowBlank:false, hideTrigger: true,  format : 'Y-m-d\\TH:i:s'}});
				}
				else
				{					 
					width = 50. *  parseInt(obj.size);				
					columns[i] = Ext.create('Ext.grid.column.Column', { text: obj.name, sortable : false,  dataIndex: index,  
f9c8b272   elena   edit catalog
142
						width : width, menuDisabled: true, editor: 'textfield' });
c865df36   Elena.Budnik   dateTime datatype...
143
				}
70aabdee   elena   catalog draft
144
145
				i++;
			});
1340621c   Elena.Budnik   error msg when up...
146

70aabdee   elena   catalog draft
147
148
149
150
151
152
153
154
155
			var store = Ext.create('Ext.data.Store', {
				fields: fields,
				autoDestroy: false,
				pageSize : 200,
				buffered : true, 
				purgePageCount: 0,
				remoteSort: true,
				proxy: {
					type: 'direct',
1340621c   Elena.Budnik   error msg when up...
156
					api : { read   :  AmdaAction.readTTCacheIntervals },
70aabdee   elena   catalog draft
157
158
159
160
161
162
163
164
165
166
167
168
169
					// remplir automatiquement tt, sharedtt , catalog, shared catalog
					extraParams : {'typeTT' : 'catalog'},
					reader:
					{
						type: 'json',
						root: 'intervals',
						totalProperty : 'totalCount'
					}
				},
				listeners: {
					scope : me,
					load: function(store,records) {        
						// myDesktopApp.EventManager.fireEvent('refresh');
1340621c   Elena.Budnik   error msg when up...
170
171
172
							me.TTGrid.getView().refresh();
							me.TTGrid.getSelectionModel().refresh();
							me.updateCount();
70aabdee   elena   catalog draft
173
174
175
176
						//Statistical plugin
						//   	this.fireEvent("refresh");
					}
				}
f9c8b272   elena   edit catalog
177
178
			});			
			
70aabdee   elena   catalog draft
179
			me.TTGrid.reconfigure(store, columns);
f9c8b272   elena   edit catalog
180
181
		}		
		me.TTGrid.getSelectionModel().deselectAll();
70aabdee   elena   catalog draft
182
183
184
185
186
187
188
	//         	        	
	//         	// clear filters
	//         	me.TTGrid.getStore().clearFilter(true);
	//         
	//     		//clear sort
	//         	me.TTGrid.getStore().sorters.clear();
	//         	//me.TTGrid.getStore().sorters = new Ext.util.MixedCollection();
f9c8b272   elena   edit catalog
189
	         	
1340621c   Elena.Budnik   error msg when up...
190
		//set cache token to the Catalog object
f9c8b272   elena   edit catalog
191
		me.object.set('cacheToken', result.token);
e1fd05b4   Elena.Budnik   visu from cacheCat
192
		me.setParamInfo(result.parameters);	
f9c8b272   elena   edit catalog
193
		me.TTGrid.getStore().load();
70aabdee   elena   catalog draft
194
			
f9c8b272   elena   edit catalog
195
196
197
198
199
200
		me.status = result.status;
	},
	
	/**
	 * load object catalog into this view
	 */
1340621c   Elena.Budnik   error msg when up...
201
	loadObject : function(){ 	  
f9c8b272   elena   edit catalog
202
203
204
205
206
		// load object into form
		this.formPanel.getForm().loadRecord(this.object);
	
		this.status = null;
		
1340621c   Elena.Budnik   error msg when up...
207
208
		if (this.object.get('fromPlugin')){			
			if (this.object.get('objFormat') && this.object.get('objFormat') != ''){
70aabdee   elena   catalog draft
209
				//From uploaded file
901ba3f3   Elena.Budnik   upload catalog
210
				AmdaAction.initTTCacheFromUploadedFile(this.object.get('objName'), this.object.get('objFormat'), this.isCatalog, this.onAfterInit, this);
70aabdee   elena   catalog draft
211
			}
1340621c   Elena.Budnik   error msg when up...
212
			else {
f9c8b272   elena   edit catalog
213
214
				//From tmp object (ie Statistics result)		    
				AmdaAction.initTTCacheFromTmpObject(this.object.get('folderId'), this.object.get('objName'), this.isCatalog, this.onAfterInit, this);
70aabdee   elena   catalog draft
215
216
			}
		}
1340621c   Elena.Budnik   error msg when up...
217
		else {
169f14d2   Benjamin Renard   Add shared object...
218
			var typeTT = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id).linkedNode.data.nodeType;
1340621c   Elena.Budnik   error msg when up...
219
220
			if (this.object.get('id') == '') {														  				
				//TODO ?  
70aabdee   elena   catalog draft
221
			}	
1340621c   Elena.Budnik   error msg when up...
222
			else {
70aabdee   elena   catalog draft
223
				//From existing TT file
169f14d2   Benjamin Renard   Add shared object...
224
				AmdaAction.initTTCacheFromTT(this.object.get('id'), typeTT, this.onAfterInit, this);
70aabdee   elena   catalog draft
225
226
			}
		}
d18b535d   elena   catalog draft + c...
227
	},
70aabdee   elena   catalog draft
228
	
d18b535d   elena   catalog draft + c...
229
	checkIntervalsStatusForSave : function(onStatusOk) {
70aabdee   elena   catalog draft
230
		onStatusOk();
d18b535d   elena   catalog draft + c...
231
232
233
234
235
	},
	
	/*	    
	 * save method called by Save button
	 */
70aabdee   elena   catalog draft
236
237
	saveProcess : function(toRename)
	{
f9c8b272   elena   edit catalog
238
239
240
		var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id);
		//  store / columns are the same - not needed to reconfigure grid
		this.toReconfigure = false;
d18b535d   elena   catalog draft + c...
241
            // if the name has been modified this is a creation
1340621c   Elena.Budnik   error msg when up...
242
		if (this.fclose()) {         
70aabdee   elena   catalog draft
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
			if (this.object.isModified('name') || this.object.get('fromPlugin')) {				
				// if object already has an id : it's a 'rename' of an existing  
				if (this.object.get('id')){
					// the context Node is the parent node of current edited one
					var contextNode = module.linkedNode.parentNode;
					// link a new node to the TimeTableModule
					module.createLinkedNode();
					// set the contextNode
					module.linkedNode.set('contextNode',contextNode);
					// create a new object linked
					module.createObject(this.object.getJsonValues());
					
					var obj = module.linkedNode.get('object');                                                    
					// synchronisation of objects
					this.object = obj;
					if (toRename) module.linkedNode.toRename = true;
				} 
c5984b95   elena   dblclk catalog
260
				module.linkedNode.create(/*{callback : function() {module.linkedNode.update();}, scope : this}*/);
70aabdee   elena   catalog draft
261
			} else {
f9c8b272   elena   edit catalog
262
				//update				
70aabdee   elena   catalog draft
263
				module.linkedNode.update();
1340621c   Elena.Budnik   error msg when up...
264
			}	
70aabdee   elena   catalog draft
265
		}
f792a3de   elena   catalog ihm
266
267
	},
	
d18b535d   elena   catalog draft + c...
268
	/**
f9c8b272   elena   edit catalog
269
270
	 * overwrite metod called by Save button
	 */
1340621c   Elena.Budnik   error msg when up...
271
	overwriteProcess : function(btn) {	
f9c8b272   elena   edit catalog
272
273
274
275
276
277
278
279
		if (btn == 'cancel') return;
               
		this.fieldName.clearInvalid();
		this.saveProcess(true);		
		
	},
	
	/**
d18b535d   elena   catalog draft + c...
280
281
282
	 * Check if changes were made before closing window 
	 * @return true if changes
	 */	
1340621c   Elena.Budnik   error msg when up...
283
	fclose : function() {
d18b535d   elena   catalog draft + c...
284
285
286
287
		if (this.status == null)
			return false;
		
		var isDirty = this.formPanel.getForm().isDirty() || (this.status.isModified) || (this.status.nbModified > 0) || (this.status.nbNew > 0);
1340621c   Elena.Budnik   error msg when up...
288
		return isDirty;
d18b535d   elena   catalog draft + c...
289
	},
f9c8b272   elena   edit catalog
290
 	    
70aabdee   elena   catalog draft
291
292
293
	init : function (config) 
	{	  
		this.object =   config.object;
f792a3de   elena   catalog ihm
294
	  
70aabdee   elena   catalog draft
295
296
297
298
299
300
301
302
303
		this.fieldName = new Ext.form.field.Text({
			fieldLabel: 'Name',
			allowBlank : false,
			stripCharsRe: /(^\s+|\s+$)/g,
			emptyText: 'Please no spaces!',
			name: 'name',
			validateOnChange: false,
			validateOnBlur: false,
			validFlag: false,
1340621c   Elena.Budnik   error msg when up...
304
305
306
			validator : function() {
				return this.validFlag;
			}
70aabdee   elena   catalog draft
307
		});
f9c8b272   elena   edit catalog
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
		
		var cellEditing = Ext.create('Ext.grid.plugin.CellEditing',{
//			clicksToEdit: 2,
			onEditComplete : function(ed, value, startValue) {
				var me = this,
				activeColumn = me.getActiveColumn(),
				context = me.context,
				record;

				if (activeColumn) {
					record = context.record;

					me.setActiveEditor(null);
					me.setActiveColumn(null);
					me.setActiveRecord(null);
				
					context.value = value;
					if (!me.validateEdit()) {
						me.editing = false;
						return;
					}

					// Only update the record if the new value is different than the
					// startValue. When the view refreshes its el will gain focus
					if (!record.isEqual(value, startValue)) {
					var obj = {};					
					 
					obj['cacheId']  = record.get('cacheId');
					obj['isCatalog'] = true;
					obj[activeColumn.dataIndex] = value;								  
					
					//Interval is modified on the server side
					me.editing = true;
					
1340621c   Elena.Budnik   error msg when up...
342
					AmdaAction.modifyTTCacheInterval(obj, function (result, e) {						
f9c8b272   elena   edit catalog
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
						var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id);
						if (module)
							module.getUiContent().status = result.status;
						context.grid.getSelectionModel().deselectAll();
						context.store.reload({
							callback : function(records, options, success) {
								context.view.bufferedRenderer.scrollTo(context.rowIdx, true, function() {
									me.fireEvent('edit', me, context);
									me.editing = false;
								}, me);	    	            
							}
						});
						}, this);
					}
					else
1340621c   Elena.Budnik   error msg when up...
358
						me.editing = false;
f9c8b272   elena   edit catalog
359
360
361
				}
			}	
		});
d18b535d   elena   catalog draft + c...
362

70aabdee   elena   catalog draft
363
364
365
366
		this.TTGrid =  Ext.create('Ext.grid.Panel', { 
			height: 530,
			columns: [ ],
			frame: true,
f9c8b272   elena   edit catalog
367
			columnLines: true,
1340621c   Elena.Budnik   error msg when up...
368
			//	selType: 'cellmodel',
f9c8b272   elena   edit catalog
369
			plugins: [ cellEditing, { ptype : 'bufferedrenderer'} ],
70aabdee   elena   catalog draft
370
371
372
			dockedItems: [{
				xtype: 'toolbar', 
				items: [{
1340621c   Elena.Budnik   error msg when up...
373
374
375
376
377
378
379
380
381
382
					iconCls: 'icon-add',
					scope: this,
					handler: function(){ 
						cellEditing.cancelEdit();
						var store = this.TTGrid.getStore();
							
						var selection = this.TTGrid.getView().getSelectionModel().getSelection()[0];
						var row = 0;
						if (selection)
							row = store.indexOf(selection) + 1;
70aabdee   elena   catalog draft
383
						this.TTGrid.getSelectionModel().deselectAll();
1340621c   Elena.Budnik   error msg when up...
384
385
386
									
						var me = this;
						AmdaAction.addTTCacheInterval({'index' : row, 'isCatalog' : true}, function (result, e) {
70aabdee   elena   catalog draft
387
							this.status = result.status;
1340621c   Elena.Budnik   error msg when up...
388
389
390
391
392
393
394
395
							this.TTGrid.getStore().reload({
								callback : function(records, options, success) {
									me.TTGrid.getView().bufferedRenderer.scrollTo(row, false, function() {
										me.TTGrid.getView().select(row);
										cellEditing.startEditByPosition({row: row, column: 1});	
									}, me);	
								}
							});
70aabdee   elena   catalog draft
396
397
						}, this);
					}
1340621c   Elena.Budnik   error msg when up...
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
				},{
					iconCls: 'icon-delete',
					disabled: true,
					itemId: 'delete',
					scope: this,
					handler:  function(){
						var selection = this.TTGrid.getView().getSelectionModel().getSelection()[0];
						if (selection) 
						{
							var rowId = selection.get('cacheId');						
							this.TTGrid.getSelectionModel().deselectAll();
							AmdaAction.removeTTCacheIntervalFromId(rowId, this.isCatalog, function (result, e) {
								this.status = result.status;
								this.TTGrid.getStore().reload();
							}, this);
						}
					}
70aabdee   elena   catalog draft
415
416
417
				}]
			}]
		});
f792a3de   elena   catalog ihm
418
 
1340621c   Elena.Budnik   error msg when up...
419
		this.formPanel =  Ext.create('Ext.form.Panel', { 
f13f0bd4   Elena.Budnik   New Catalog creation
420
421
422
423
424
			region : 'center',
			layout:  'hbox', 
			bodyStyle: {background : '#dfe8f6'},
			defaults: { border : false, align: 'stretch', bodyStyle: {background : '#dfe8f6'},  padding: '3'},
			fieldDefaults: { labelWidth: 80, labelAlign : 'top' },
1340621c   Elena.Budnik   error msg when up...
425
			items: [{            
f13f0bd4   Elena.Budnik   New Catalog creation
426
427
428
				xtype: 'form',		            
				flex: 1,
				buttonAlign: 'left',
1340621c   Elena.Budnik   error msg when up...
429
				// title : 'Information',		   
f13f0bd4   Elena.Budnik   New Catalog creation
430
431
432
433
434
435
				layout: {type: 'vbox', pack: 'start', align: 'stretch'},
				items : [
					this.fieldName,
					{
						xtype: 'fieldcontainer',
						layout: 'hbox',		      
1340621c   Elena.Budnik   error msg when up...
436
						items: [{
f13f0bd4   Elena.Budnik   New Catalog creation
437
438
439
440
441
								xtype:'datefield', fieldLabel:'Creation date',
								name: 'created', disabled: true, 
								hideTrigger: true, format: 'Y/m/d H:i:s'
							},			  
							{ xtype: 'splitter' },			 			 
1340621c   Elena.Budnik   error msg when up...
442
							{ xtype:'textfield', fieldLabel: 'Intervals', name: 'nbIntervals', disabled: true }
f13f0bd4   Elena.Budnik   New Catalog creation
443
444
445
446
447
448
449
450
451
452
453
454
						]                                                                       
					},
					{
						xtype: 'textarea',
						name: 'description',
						fieldLabel: 'Description',
						height: 200
					},
					{
						xtype: 'component',
						height: 180
					}], 
1340621c   Elena.Budnik   error msg when up...
455
					dockedItems:[{
f13f0bd4   Elena.Budnik   New Catalog creation
456
457
458
						xtype: 'toolbar',
						dock: 'bottom', 
						ui: 'footer',
1340621c   Elena.Budnik   error msg when up...
459
						items: [{
f13f0bd4   Elena.Budnik   New Catalog creation
460
461
462
463
464
465
466
467
468
469
470
							type: 'button',
							text: 'Create New Catalog',
							scope : this,
							handler: function () 
							{ 											
								var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id);	
										
								if (!module) return;
								var obj = module.linkedNode.get('object');
								
								if (obj && obj.get('id') == '' && !obj.get('fromPlugin')) {
1340621c   Elena.Budnik   error msg when up...
471
472
									var me = this;
									
f13f0bd4   Elena.Budnik   New Catalog creation
473
474
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
									Ext.Msg.prompt('Define Parameters', 'Please enter parameters number:', function(btn, text){
										if (btn == 'ok'){
											AmdaAction.initTTCache(me.isCatalog, text, me.onAfterInit, me); 
										}
									}, this);
								}	
							}
						}]
					},
					{  
						xtype: 'toolbar',
						dock: 'bottom', 
						ui: 'footer',
						items: [
						{
							type: 'button',
							text: 'Save',
							scope : this,
							handler: function () 
							{
								if (this.updateObject())
								{
									var basicForm = this.formPanel.getForm();      
									// if there's at least one record in the store of TTGrid
									if (this.TTGrid.getStore().getTotalCount() > 0) 
									{
										// update TimeTable object which the content of form
										basicForm.updateRecord(this.object);
d18b535d   elena   catalog draft + c...
501

f13f0bd4   Elena.Budnik   New Catalog creation
502
										var me = this;
1340621c   Elena.Budnik   error msg when up...
503
										this.checkIntervalsStatusForSave(function () {
f13f0bd4   Elena.Budnik   New Catalog creation
504
505
506
507
508
509
											//Name validation
											var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id);	
											
											if (!module) return;
											module.linkedNode.isValidName(me.fieldName.getValue(), function (res) 
											{
1340621c   Elena.Budnik   error msg when up...
510
												if (!res) {
f13f0bd4   Elena.Budnik   New Catalog creation
511
512
513
514
515
516
													me.fieldName.validFlag = 'Error during object validation';
													myDesktopApp.errorMsg(me.fieldName.validFlag);
													me.fieldName.validate();
													return;
												}
												
1340621c   Elena.Budnik   error msg when up...
517
518
519
												if (!res.valid) {
													if (res.error) {
														if (res.error.search('subtree') != -1) {  							
f13f0bd4   Elena.Budnik   New Catalog creation
520
521
522
523
524
525
526
527
528
529
530
531
532
															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;
													}
1340621c   Elena.Budnik   error msg when up...
533
													else {
f13f0bd4   Elena.Budnik   New Catalog creation
534
535
536
537
538
539
540
541
542
543
544
545
546
														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);
											});
										});                            
									} 
1340621c   Elena.Budnik   error msg when up...
547
									else {
f13f0bd4   Elena.Budnik   New Catalog creation
548
549
550
551
										Ext.Msg.alert('No intervals', 'Your time table is invalid, <br>you must have at least one interval');
									}
								}
							} 
1340621c   Elena.Budnik   error msg when up...
552
						},{
f13f0bd4   Elena.Budnik   New Catalog creation
553
							type: 'button',
08eee02f   Elena.Budnik   reset catalogUI
554
555
							text: 'Reset',
							scope : this,
c865df36   Elena.Budnik   dateTime datatype...
556
							disabled: true,
1340621c   Elena.Budnik   error msg when up...
557
							handler: function() {
08eee02f   Elena.Budnik   reset catalogUI
558
559
560
561
562
// 								var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id);			
// 								module.createLinkedNode();
// 								module.createObject();
// 								this.setObject(module.getLinkedNode().get('object'), true);                           
							} 
f13f0bd4   Elena.Budnik   New Catalog creation
563
564
565
566
567
568
569
570
571
572
						},	
						{   
							type: 'button',
							text: 'Share',
							disabled: true 
						},
						{   
							type: 'button',
							text: 'Visualize',
							scope: this,
1340621c   Elena.Budnik   error msg when up...
573
							handler: function() {
f13f0bd4   Elena.Budnik   New Catalog creation
574
								var me = this;
9d412dda   elena   catalog tmp and r...
575
					
1340621c   Elena.Budnik   error msg when up...
576
								myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.visu.id, true, function (module) {	 	 							
f13f0bd4   Elena.Budnik   New Catalog creation
577
									//temporary linked node - as  Visu module is 'pseudo' interactive - no 'save', no 'execute'
e1fd05b4   Elena.Budnik   visu from cacheCat
578
									var temporaryNode = Ext.create('amdaModel.CatalogNode', { leaf : true });
f13f0bd4   Elena.Budnik   New Catalog creation
579
580
581
									if (temporaryNode) temporaryNode.set('object',me.object); 
									module.setLinkedNode(temporaryNode);
									
1340621c   Elena.Budnik   error msg when up...
582
									module.createWindow(); 
f13f0bd4   Elena.Budnik   New Catalog creation
583
584
								});     
							}
1340621c   Elena.Budnik   error msg when up...
585
						}]
f13f0bd4   Elena.Budnik   New Catalog creation
586
587
588
589
590
591
592
					}]
				},
				{
					xtype: 'form',               
					bodyStyle: {background : '#dfe8f6'},
					//padding: '3',
					flex: 2,
1340621c   Elena.Budnik   error msg when up...
593
					items : [ this.TTGrid ] 
f13f0bd4   Elena.Budnik   New Catalog creation
594
595
				}]  
			}); 
f792a3de   elena   catalog ihm
596
	 
1340621c   Elena.Budnik   error msg when up...
597
		this.TTGrid.getSelectionModel().on('selectionchange', function(selModel,selections) {
f13f0bd4   Elena.Budnik   New Catalog creation
598
599
			this.TTGrid.down('#delete').setDisabled(selections.length === 0); 
		}, this); 
f792a3de   elena   catalog ihm
600
	
1340621c   Elena.Budnik   error msg when up...
601
		var myConf = {
f13f0bd4   Elena.Budnik   New Catalog creation
602
603
604
605
606
607
608
609
			layout: 'border',
			items: [		   
				this.formPanel, 		     
				{
					xtype: 'panel', 
					region: 'south',
					title: 'Information',
					collapsible: true,
42863f42   Elena.Budnik   collapseMode: "he...
610
					collapseMode: 'header',
f13f0bd4   Elena.Budnik   New Catalog creation
611
612
613
614
615
616
617
618
619
620
621
					height: 100,
					autoHide: false,
					bodyStyle: 'padding:5px',
					iconCls:  'icon-information',
					loader: 
					{
						autoLoad: true,
						url: helpDir+'catalogHOWTO'
					} 
				}
			] 
1340621c   Elena.Budnik   error msg when up...
622
		};	    
f13f0bd4   Elena.Budnik   New Catalog creation
623
		Ext.apply (this, Ext.apply(arguments, myConf));	
1340621c   Elena.Budnik   error msg when up...
624
	}	 
f792a3de   elena   catalog ihm
625
});