TimeTableModule.js 3.57 KB
/**
 * Project   : AMDA-NG
 * Name      : TimeTableModule.js
 * @class    amdaDesktop.TimeTableModule
 * @extends  amdaDesktop.InteractiveModule
 * @brief  	 Time Table Module controller definition 
 * @author   Myriam
 * @version $Id: TimeTableModule.js 1605 2013-06-11 13:38:47Z myriam $ 
 ******************************************************************************
 *    FT Id     :   Date   : Name - Description
 ******************************************************************************
 *	           08/06/2011: Myriam - Migration extjs4
 */

Ext.define('amdaDesktop.TimeTableModule', {
	extend: 'amdaDesktop.InteractiveModule',
	
	requires: [
         'amdaUI.TimeTableUI',
         'amdaUI.ShareObjectUI'
    ],
    
	contentId : 'timeTableUi',
	
    /**
     * @cfg {String} data models
     * @required
     */
	nodeDataModel : 'amdaModel.TimeTableNode',
	
    /**
     * @cfg {String} window definitions
     * @required
     */
	width : 850,
	height: 650,
	uiType : 'panelTimeTable',
	helpTitle : 'Help on Time Table Module',
	helpFile : 'timetableHelp',
	
	/**
	 * @override
	 */
	createWindow : function(onshowfn) {

	    this.callParent(arguments);
	    var win = this.app.getDesktop().getWindow(this.id);	

		if (win) {
			/* Reset if form in form ( OperationsTT in TimeTable ) */
			this.getUiContent().down('form').getForm().reset();
		}
	},
	
	shareTT : function(ttObj) {
		var win = myDesktopApp.desktop.getWindow('sharett-win');     
        if(!win)
        {
        	var me = this;
        	var win = myDesktopApp.desktop.createWindow(
            {
            	border: false,
                id : 'sharett-win',
                title : 'Share TimeTable',
                width : 400,
                height : 300,
                layout : 'fit',
                maximizable : false,
                items : [
                         {
                        	 xtype : 'shareobject',
                        	 id : 'shareTTUI',
                        	 onAfterShareObject : function(folder_id, object_id) {
                        		 win.close();
                        		 var explorerTree = Ext.getCmp(amdaUI.ExplorerUI.RESRC_TAB.TREE_ID);	
                        		 var sharedTTRootNode = explorerTree.getRootNode().findChild('id','sharedtimeTable-treeRootNode',true);
                        		 amdaModel.InteractiveNode.preloadNodes(sharedTTRootNode, function() {
                        			 sharedTTRootNode.expand();
                        			 var folderNode = explorerTree.getRootNode().findChild('id', folder_id, true);
                        			 folderNode.removeAll();
                        			 folderNode.set('loaded',false);
                        			 amdaModel.InteractiveNode.preloadNodes(folderNode, function() {
                        				 folderNode.expand();
                        				 var objectNode = explorerTree.getRootNode().findChild('id',object_id,true);
                            			 sharedTTRootNode.myGetOwnerTree().getSelectionModel().select(objectNode);
                            		 });
                        		 });
                        	 }
                         }
                ]
            });	
        }
        
        var sharePanel = win.down('#shareTTUI');
        if (sharePanel)
        	sharePanel.setProperties('timeTable', ttObj);
        
        AmdaAction.getObject(ttObj.id, 'timeTable', function(result,remoteEvent) {
            	if (result) {
            		if (result.description)
            			sharePanel.setDescription(result.description);
            	} 
        	}, this.getObjectCallback, this);
        
        win.show();
	}
 
});