Blame view

js/app/controllers/ResultModule.js 3.05 KB
16035364   Benjamin Renard   First commit
1
2
3
4
5
6
7
8

/** 
 * Project   : AMDA-NG
 * Name      : ResultModule.js
 * @class    amdaDesktop.ResultModule
 * @extends  amdaDesktop.InteractiveModule
 * @brief    Result Module controller definition 
 * @author   
29c449bb   Elena.Budnik   format + redmine ...
9
 * @version $Id: ResultModule.js 1052 2012-07-20 14:21:37Z elena $ 
16035364   Benjamin Renard   First commit
10
11
12
13
14
 */

Ext.define('amdaDesktop.ResultModule', {
	extend: 'amdaDesktop.InteractiveModule',
	
29c449bb   Elena.Budnik   format + redmine ...
15
	requires: ['amdaUI.ResultUI'],
16035364   Benjamin Renard   First commit
16
17
18
19

	contentId : 'resultUI',
	width :  500, 
	height : 250,
29c449bb   Elena.Budnik   format + redmine ...
20
21
22
23
24
	
	/**
	* @cfg {String} data models
	* @required
	*/
16035364   Benjamin Renard   First commit
25
26
27
28
29
30
31
32
33
34
	nodeDataModel :  'amdaModel.BkgJobNode',
	uiType : 'panelResult',
	nodeType : null,
	helpTitle :'Help on Result Module',
	
	init : function() {	
		//force the launcher to null to don't add this item on start menu
		this.launcher = null;
	},
	
29c449bb   Elena.Budnik   format + redmine ...
35
36
37
	/**
	* Window Creation method of the Module
	*/
16035364   Benjamin Renard   First commit
38
	createWindow : function () {
29c449bb   Elena.Budnik   format + redmine ...
39
40
41
42
43
		// init Result Win 	 
		var desktop = this.app.getDesktop();
		var win = desktop.getWindow(this.id);
		if (!win) {
			win = desktop.createWindow({
16035364   Benjamin Renard   First commit
44
45
46
47
48
49
50
51
52
53
54
55
				id : this.id,
				title : this.title,
				width : this.width,
				height : this.height,
				iconCls : this.icon,
				border : false,
				constrainHeader : true,
				layout : 'fit',
				stateful : true,
				stateId  : this.id,
				stateEvents: ['move','show','resize'],
//				closable : false,
29c449bb   Elena.Budnik   format + redmine ...
56
57
58
59
60
61
62
63
64
65
66
				tools : [{
					type:'help',
					qtip: this.helpTitle,
					handler: function(event, toolEl, panel){
						//TODO: help logic
					}
				}],
				items : [ {
					xtype :  this.uiType,					    
					id : this.contentId
				}],
16035364   Benjamin Renard   First commit
67
				listeners: {
29c449bb   Elena.Budnik   format + redmine ...
68
69
70
71
					scope: this,
					beforeclose : function() {
						if (this.linkedNodes) this.linkedNodes.clear();
					}
16035364   Benjamin Renard   First commit
72
73
				}
			});
29c449bb   Elena.Budnik   format + redmine ...
74
75
		}	 
		win.show();
16035364   Benjamin Renard   First commit
76
	    
29c449bb   Elena.Budnik   format + redmine ...
77
78
79
80
81
82
83
84
85
		var linkedNode = this.getLinkedNode();
		
		if (win && linkedNode.get('jobType')) {      
			if (!this.linkedNodes ||
			!this.linkedNodes.getByKey(linkedNode.get('processId'))){	 
				this.getUiContent().setResult(linkedNode);	
				this.addLinkedNode(linkedNode);
			}
		}	
16035364   Benjamin Renard   First commit
86
87
	},	
	
29c449bb   Elena.Budnik   format + redmine ...
88
	//TODO override interactive module method : is it needed???	
16035364   Benjamin Renard   First commit
89
90
91
92
	setLinkedNode : function (myLinkedNode){
		this.linkedNode = myLinkedNode;
	},

29c449bb   Elena.Budnik   format + redmine ...
93
94
95
96
	/**
	* add the current node into this module
	* @param {amdaModel.InteractiveNode} myLinkedNode
	*/
16035364   Benjamin Renard   First commit
97
	addLinkedNode : function (myLinkedNode){
29c449bb   Elena.Budnik   format + redmine ...
98
99
100
101
102
103
104
105
		if (!this.linkedNodes){
			this.linkedNodes = new Ext.util.MixedCollection();
		}
		
		if (myLinkedNode.get('processId')){
			// add new linkedNode to this module
			this.linkedNodes.add(myLinkedNode.get('processId'),myLinkedNode);	
		}	  
16035364   Benjamin Renard   First commit
106
107
	},
	
29c449bb   Elena.Budnik   format + redmine ...
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
	/**
	* remove deleted node from this module; delete corresponding FieldSet
	* @param {amdaModel.InteractiveNode} linkedNode 
	* @param int index
	*/
	removeLinkedNode : function(linkedNode, index) {	     	   
		this.linkedNodes.remove(index);
		
		var type = linkedNode.get('jobType');
		var processId = linkedNode.get('processId');	 
		var tabPanel = this.getUiContent().items.items[0];
		var thePanel;
		tabPanel.items.each(function(item){
			if (item.id == 'tab-'+type) {
				thePanel = item;
				thePanel.items.each(function(item) {
					if (processId == item.intId){
							thePanel.remove(item);
					}
				});
			}
		});
	}
});