Blame view

js/app/models/TimeTableNode.js 4.17 KB
16035364   Benjamin Renard   First commit
1
2
3
4
5
6
7
8
/** 
 * 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 $
16035364   Benjamin Renard   First commit
9
10
11
12
13
14
15
16
17
18
19
 */

Ext.define('amdaModel.TimeTableNode', {

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

3a5f60a1   elena   proper use os sta...
20
21
    constructor : function(config)
    {	
16035364   Benjamin Renard   First commit
22
        this.callParent(arguments);
3a5f60a1   elena   proper use os sta...
23
24
        this.set('moduleId',myDesktopApp.dynamicModules.tt.id);
        this.set('objectDataModel','amdaModel.TimeTable');       
16035364   Benjamin Renard   First commit
25
26
27
        if (this.get('leaf')) this.set('iconCls', 'icon-timetable');
    },
  
3a5f60a1   elena   proper use os sta...
28
29
    localMenuItems : function() 
    {
16035364   Benjamin Renard   First commit
30
        var menuItems =
169f14d2   Benjamin Renard   Add shared object...
31
32
         [
        {
16035364   Benjamin Renard   First commit
33
34
35
            fnId : 'leaf-shareLeaf',
            text : 'Share Time Table',
            hidden : true
169f14d2   Benjamin Renard   Add shared object...
36
        },{
16035364   Benjamin Renard   First commit
37
38
39
40
41
42
43
44
45
46
47
48
49
50
            fnId : 'leaf-download',
            text : 'Download Time Table',
            hidden : true
        },{
            fnId : 'leaf-operations',
            text : 'Operations',
            hidden : true
        }];
     
        return menuItems;
    },

    localMultiMenuItems : function() {
        var menuItems =
169f14d2   Benjamin Renard   Add shared object...
51
52
         [
        {
16035364   Benjamin Renard   First commit
53
            fnId : 'mult-downloadMulti',
d18b535d   elena   catalog draft + c...
54
            text : 'Download selected '+this.self.objectName+'s'
16035364   Benjamin Renard   First commit
55
56
57
58
59
60
61
62
63
        },{
            fnId : 'mult-operationsMulti',
            text : 'Operations'
        }];
     
        return menuItems;
    },
    
    getAllContextMenuItems: function(){
d18b535d   elena   catalog draft + c...
64
65
        
        var menuItems = this.allMenuItems();
16035364   Benjamin Renard   First commit
66
        var locMenuItems = this.localMenuItems();
d18b535d   elena   catalog draft + c...
67
68
        
        return  Ext.Array.merge(menuItems,locMenuItems);       
16035364   Benjamin Renard   First commit
69
70
    },
    
d18b535d   elena   catalog draft + c...
71
72
73
74
75
76
     getMultiContextMenuItems: function(){
        
        var menuItems = this.allMenuMultiItems();
        var locMenuItems = this.localMultiMenuItems();
        
        return  Ext.Array.merge(menuItems,locMenuItems);       
16035364   Benjamin Renard   First commit
77
    },
d18b535d   elena   catalog draft + c...
78
    
16035364   Benjamin Renard   First commit
79
80
81
82
83
84
85
86
    onMenuItemClick : function(menu,item,event) {
 
        this.callParent(arguments);
        
	    var fnId = Ext.util.Format.substr(item.fnId, 5, item.fnId.length);

	    switch (fnId) {
	    
16035364   Benjamin Renard   First commit
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
 	    case 'shareLeaf':   
 	        this.shareNode(this); 
 	        break;

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

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

16035364   Benjamin Renard   First commit
103
104
105
106
107
108
109
	    case 'downloadMulti':
	        this.downloadMulti();
	        break;

	    case 'operationsMulti':
	        this.operationsMulti();
	        break;
5cfea1f2   elena   vizu draft
110
111
112
113
	   
	    case 'visu':
	        this.visu();
	        break;
16035364   Benjamin Renard   First commit
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140

	    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) {
169f14d2   Benjamin Renard   Add shared object...
141
142
143
    	 myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.tt.id, true, function (module) {
        	 module.shareTT({'name' : node.get('text'), 'id' : node.get('id')});
         });
16035364   Benjamin Renard   First commit
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
     },
     
     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();
         })
     }
});