From f13f0bd4fe63006414cab48ad2e424399f054fa1 Mon Sep 17 00:00:00 2001
From: Elena.Budnik <ebudnik@irap.omp.eu>
Date: Wed, 17 May 2017 18:42:09 +0200
Subject: [PATCH] New Catalog creation

---
 js/app/controllers/CatalogModule.js     |  14 +-------------
 js/app/controllers/InteractiveModule.js |   7 ++++---
 js/app/views/CatalogUI.js               | 382 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
 3 files changed, 220 insertions(+), 183 deletions(-)

diff --git a/js/app/controllers/CatalogModule.js b/js/app/controllers/CatalogModule.js
index ab79d17..ef70640 100644
--- a/js/app/controllers/CatalogModule.js
+++ b/js/app/controllers/CatalogModule.js
@@ -33,19 +33,7 @@ Ext.define('amdaDesktop.CatalogModule', {
 	uiType : 'panelCatalog',
 	helpTitle : 'Help on Catalog Module',
 	helpFile : 'catalogHelp',
-	
-	operationOnShow: function() {				
-		var obj = this.linkedNode.get('object');
-		if (obj && obj.get('id') == '' && !obj.get('fromPlugin')) {
-			Ext.Msg.prompt('Define Parameters', 'Please enter parameters number:', function(btn, text){
-			if (btn == 'ok'){
-				AmdaAction.initTTCache(this.getUiContent().isCatalog, text, this.getUiContent().onAfterInit, this.getUiContent()); 
-			}
-		}, this);
-		}
-								  
-	},
-	
+		
 	shareCatalog : function(catObj) {
 		var win = myDesktopApp.desktop.getWindow('sharecat-win');     
         if(!win)
diff --git a/js/app/controllers/InteractiveModule.js b/js/app/controllers/InteractiveModule.js
index e3456fc..a8f9ccd 100644
--- a/js/app/controllers/InteractiveModule.js
+++ b/js/app/controllers/InteractiveModule.js
@@ -132,9 +132,10 @@ Ext.define('amdaDesktop.InteractiveModule', {
 					this.getUiContent().updateObject();
 				},
 				show: function() {
-					// configuration of empty catalog
-					if (this.isOperationOnShow)
-						 Ext.Function.defer(this.operationOnShow, 2000, this);
+// 					// configuration of empty catalog
+// 					if (this.isOperationOnShow)
+// 						// Ext.Function.defer(this.operationOnShow, 2000, this);
+// 						this.operationOnShow();
 					if (onShowEvent)
 						onShowEvent();
 				}	 
diff --git a/js/app/views/CatalogUI.js b/js/app/views/CatalogUI.js
index 49e8af9..87dc492 100644
--- a/js/app/views/CatalogUI.js
+++ b/js/app/views/CatalogUI.js
@@ -418,177 +418,225 @@ Ext.define('amdaUI.CatalogUI', {
 			}]
 		});
  
-	  this.formPanel =  Ext.create('Ext.form.Panel', { 
-	      region : 'center',
-	      layout:  'hbox', 
-	      bodyStyle: {background : '#dfe8f6'},
-	      defaults: { border : false, align: 'stretch', bodyStyle: {background : '#dfe8f6'},  padding: '3'},
-	      fieldDefaults: { labelWidth: 80, labelAlign : 'top' },
-	      items: [ 
-		{            
-		    xtype: 'form',		            
-		    flex: 1,
-		    buttonAlign: 'left',
-//		    title : 'Information',		   
-		    layout: {type: 'vbox', pack: 'start', align: 'stretch'},
-		    items : [
-		     this.fieldName,
-		      {
-		      xtype: 'fieldcontainer',
-		      layout: 'hbox',		      
-		      items: [
-			  {
-			      xtype:'datefield', fieldLabel:'Creation date',
-			      name: 'created', disabled: true, 
-			      hideTrigger: true, format: 'Y/m/d H:i:s'
-			  },			  
-			  { xtype: 'splitter' },			 			 
-			  { xtype:'textfield', fieldLabel: 'Intervals', name: 'nbIntervals', disabled: true}
-			]                                                                       
-		      },
-		      {
-			  xtype: 'textarea',
-			  name: 'description',
-			  fieldLabel: 'Description',
-			  height: 200
-		      },
-		      {
-			  xtype: 'component',
-			  height: 180
-		      }
-		      ],
-		      fbar:[
-			  {   
-			      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);
+		this.formPanel =  Ext.create('Ext.form.Panel', 
+		{ 
+			region : 'center',
+			layout:  'hbox', 
+			bodyStyle: {background : '#dfe8f6'},
+			defaults: { border : false, align: 'stretch', bodyStyle: {background : '#dfe8f6'},  padding: '3'},
+			fieldDefaults: { labelWidth: 80, labelAlign : 'top' },
+			items: [ 
+			{            
+				xtype: 'form',		            
+				flex: 1,
+				buttonAlign: 'left',
+	//		    title : 'Information',		   
+				layout: {type: 'vbox', pack: 'start', align: 'stretch'},
+				items : [
+					this.fieldName,
+					{
+						xtype: 'fieldcontainer',
+						layout: 'hbox',		      
+						items: [
+							{
+								xtype:'datefield', fieldLabel:'Creation date',
+								name: 'created', disabled: true, 
+								hideTrigger: true, format: 'Y/m/d H:i:s'
+							},			  
+							{ xtype: 'splitter' },			 			 
+							{ xtype:'textfield', fieldLabel: 'Intervals', name: 'nbIntervals', disabled: true}
+						]                                                                       
+					},
+					{
+						xtype: 'textarea',
+						name: 'description',
+						fieldLabel: 'Description',
+						height: 200
+					},
+					{
+						xtype: 'component',
+						height: 180
+					}], 
+					dockedItems:[
+					{
+						xtype: 'toolbar',
+						dock: 'bottom', 
+						ui: 'footer',
+						items: [
+						{
+							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')) {
+									var me = this
+									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);
 
-                            			var me = this;
-                            			this.checkIntervalsStatusForSave(function () {
-						    //Name validation
-						    var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id);	
-						    if (!module)
-							    return;
-						    module.linkedNode.isValidName(me.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);
-						    });
-                            			});                            
-  				              } else {
-  				                // warning:
-  				                Ext.Msg.alert('No intervals', 'Your time table is invalid, <br>you must have at least one interval');
-  				              }
-                                    }
-                           } 
-			  },{   
-			      type: 'button',
-			      text: 'Share',
-			      disabled: true 
-			  },
-			  {   
-			      type: 'button',
-			      text: 'Visualize',
-			      scope: this,
-			      handler: function() {
-				 var me = this;
-	 
-				 myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.visu.id, true, function (module) {	 	 
+										var me = this;
+										this.checkIntervalsStatusForSave(function () 
+										{
+											//Name validation
+											var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id);	
+											
+											if (!module) return;
+											module.linkedNode.isValidName(me.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);
+											});
+										});                            
+									} 
+									else 
+									{
+										// warning:
+										Ext.Msg.alert('No intervals', 'Your time table is invalid, <br>you must have at least one interval');
+									}
+								}
+							} 
+						},
+						{
+							type: 'button',
+							text: 'Reset' 
+						},	
+						{   
+							type: 'button',
+							text: 'Share',
+							disabled: true 
+						},
+						{   
+							type: 'button',
+							text: 'Visualize',
+							scope: this,
+							handler: function() 
+							{
+								var me = this;
 					
-					//temporary linked node - as  Visu module is 'pseudo' interactive - no 'save', no 'execute'
-					var temporaryNode = Ext.create('amdaModel.CatalogNode', {
-						leaf : true 
-					}); 
-					
-					if (temporaryNode) temporaryNode.set('object',me.object); 
-					module.setLinkedNode(temporaryNode);
-					
-					module.createWindow(); 					 					 
-				});     
-			      }
-			  } 
-			]
-		}, {
-		    xtype: 'form',		               
-		    bodyStyle: {background : '#dfe8f6'},
-//		    padding: '3',
-		    flex: 2,
-		    items : [
-		      this.TTGrid
-		    ] 
-		}
-	    ]  
-	}); 
+								myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.visu.id, true, function (module) 
+								{	 	 							
+									//temporary linked node - as  Visu module is 'pseudo' interactive - no 'save', no 'execute'
+									var temporaryNode = Ext.create('amdaModel.CatalogNode', {
+										leaf : true 
+									}); 
+									
+									if (temporaryNode) temporaryNode.set('object',me.object); 
+									module.setLinkedNode(temporaryNode);
+									
+									module.createWindow(); 					 					 
+								});     
+							}
+						}]					
+					}]
+				},
+				{
+					xtype: 'form',               
+					bodyStyle: {background : '#dfe8f6'},
+					//padding: '3',
+					flex: 2,
+					items : [
+						this.TTGrid
+					] 
+				}]  
+			}); 
 	 
-	 this.TTGrid.getSelectionModel().on('selectionchange', function(selModel,selections){
-		this.TTGrid.down('#delete').setDisabled(selections.length === 0); 
-        }, this); 
+		this.TTGrid.getSelectionModel().on('selectionchange', function(selModel,selections)
+		{
+			this.TTGrid.down('#delete').setDisabled(selections.length === 0); 
+		}, this); 
 	
-	var myConf = {
-		    layout: 'border',
-		    items: [		   
-			  this.formPanel, 		     
-			  {
-			    xtype: 'panel', 
-			    region: 'south',
-			    title: 'Information',
-			    collapsible: true,
-			    height: 100,
-			    autoHide: false,
-			    bodyStyle: 'padding:5px',
-			    iconCls:  'icon-information',
-			      loader: {
-				autoLoad: true,
-				url: helpDir+'catalogHOWTO'
-			      } 
-			  }
-		    ] 
-	      };
+		var myConf = 
+		{
+			layout: 'border',
+			items: [		   
+				this.formPanel, 		     
+				{
+					xtype: 'panel', 
+					region: 'south',
+					title: 'Information',
+					collapsible: true,
+					height: 100,
+					autoHide: false,
+					bodyStyle: 'padding:5px',
+					iconCls:  'icon-information',
+					loader: 
+					{
+						autoLoad: true,
+						url: helpDir+'catalogHOWTO'
+					} 
+				}
+			] 
+		};
 	    
-	Ext.apply (this, Ext.apply(arguments, myConf));	
-    }
+		Ext.apply (this, Ext.apply(arguments, myConf));	
+	}
 	 
 });	
--
libgit2 0.21.2