TimeTableNode.js 4.47 KB
/** 
 * Project  : AMDA-NG4
 * Name     : TimeTableNode.js
 * @class   amdaModel.TimeTableNode
 * @extends amdaModel.InteractiveNode
 * @brief   Basic Model of Node corresponding to a amda Time Table
 * @author  
 * @version $Id: TimeTableNode.js 1904 2013-11-25 12:42:02Z elena $
 */

Ext.define('amdaModel.TimeTableNode', {

    extend: 'amdaModel.InteractiveNode',
    
    statics: {
        nodeType: 'timeTable',
        objectName: 'Time Table'
    },

    constructor : function(config)
    {	
        this.callParent(arguments);
        this.set('moduleId',myDesktopApp.dynamicModules.tt.id);
        this.set('objectDataModel','amdaModel.TimeTable');       
        if (this.get('leaf')) this.set('iconCls', 'icon-timetable');
    },
  
    localMenuItems : function() 
    {
        var menuItems =
         [/*{
            fnId : 'dire-shareNode',
            text : 'Share content',
            hidden : true
        },{
            fnId : 'leaf-shareLeaf',
            text : 'Share Time Table',
            hidden : true
        },*/{
            fnId : 'leaf-download',
            text : 'Download Time Table',
            hidden : true
        },{
            fnId : 'leaf-operations',
            text : 'Operations',
            hidden : true
        }];
     
        return menuItems;
    },

    localMultiMenuItems : function() {
        var menuItems =
         [/*{
            fnId : 'mult-shareMulti',
            text : 'Share selected '+this.self.objectName+'s'
        },*/{
            fnId : 'mult-downloadMulti',
            text : 'Download selected '+this.self.objectName+'s'
        },{
            fnId : 'mult-operationsMulti',
            text : 'Operations'
        }];
     
        return menuItems;
    },
    
    getAllContextMenuItems: function(){
        
        var menuItems = this.allMenuItems();
        var locMenuItems = this.localMenuItems();
        
        return  Ext.Array.merge(menuItems,locMenuItems);       
    },
    
     getMultiContextMenuItems: function(){
        
        var menuItems = this.allMenuMultiItems();
        var locMenuItems = this.localMultiMenuItems();
        
        return  Ext.Array.merge(menuItems,locMenuItems);       
    },
    
    onMenuItemClick : function(menu,item,event) {
 
        this.callParent(arguments);
        
	    var fnId = Ext.util.Format.substr(item.fnId, 5, item.fnId.length);

	    switch (fnId) {
	    
 	    case 'shareNode':		 
 	    case 'shareLeaf':   
 	        this.shareNode(this); 
 	        break;

	    case 'download':
	    	this.ttDownload();
	    	break;
	    	
	    case 'operations':
	        this.ttOperations();
	        break;

//	    case 'deleteMulti':
//	        this.deleteMulti();
//	        break;

	    case 'shareMulti':
	        this.shareMulti();
	        break;

	    case 'downloadMulti':
	        this.downloadMulti();
	        break;

	    case 'operationsMulti':
	        this.operationsMulti();
	        break;

	    default:
	        break;
	    } // switch end 
	 
     },
 
     ttDownload : function() {
    	 // download Module
    	 var me = this;
    	 myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.download.id, true, function (module) {
    		 module.createWindow();
        	 var uidownload = module.getUiContent();
      	     uidownload.addTTdownload(me.get('text'), me.get('id'));
    	 });
     },
     
     ttOperations : function() {
         var me = this;
         myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.tt_op.id, true, function (module) {
        	 module.createWindow();
        	 module.getUiContent().addTT(me.get('text'), me.get('id'));
         });

     },
 
     shareNode: function(node) {
         alert("NOT IMPLEMENTED YET");
     },
     
     shareMulti: function(){
         var selection = this.myGetOwnerTree().getSelectionModel().selected.items;
         alert(selection.length+' to share!');
         alert("NOT IMPLEMENTED YET");
     },
     
     downloadMulti: function(){
         var selection = this.myGetOwnerTree().getSelectionModel().selected.items;
//         alert(selection.length+' to download!');
         Ext.Array.each(selection,function(item,index,allItems){
             item.ttDownload();
         })
     },
     
     operationsMulti: function(){
         var selection = this.myGetOwnerTree().getSelectionModel().selected.items;
         alert(selection.length+' time tables to send into operationsTT module!');
         Ext.Array.each(selection,function(item,index,allItems){
             item.ttOperations();
         })
     }
});