Blame view

js/app/models/PlotNode.js 3.88 KB
16035364   Benjamin Renard   First commit
1
2
3
4
5
6
/** 
 * Project  : AMDA-NG4
 * Name     : PlotNode.js
 * @class   amdaModel.PlotNode
 * @extends amdaModel.ExecutableNode
 * @brief   Basic Model of Node corresponding to a plot request
18d4a11e   Benjamin Renard   Save and load plo...
7
 * @author  Benjamin Renard
16035364   Benjamin Renard   First commit
8
9
10
 */

Ext.define('amdaModel.PlotNode', {
18d4a11e   Benjamin Renard   Save and load plo...
11
	extend: 'amdaModel.ExecutableNode',
663f6395   Elena.Budnik   nettoyage
12

f31bea1c   Benjamin Renard   wip for save plot
13
    fields : [
7c762483   Benjamin Renard   Fix some bugs rel...
14
        {name : 'tabs', type:'auto', defaultValue:false,  persist:  false}
f31bea1c   Benjamin Renard   wip for save plot
15
16
    ],

16035364   Benjamin Renard   First commit
17
18
    statics: {
        nodeType: 'request' 
16035364   Benjamin Renard   First commit
19
20
    },

f31bea1c   Benjamin Renard   wip for save plot
21
22
23
24
    requires:[
        'amdaModel.PlotTabNode'
    ],

18d4a11e   Benjamin Renard   Save and load plo...
25
    constructor : function(config){
16035364   Benjamin Renard   First commit
26
27
        this.callParent(arguments);
        this.set('moduleId',myDesktopApp.dynamicModules.plot.id);
2396ac7b   Benjamin Renard   Do not load plot ...
28
        this.set('objectDataModel','amdaPlotObj.PlotRequestObject');
18d4a11e   Benjamin Renard   Save and load plo...
29
        this.set('nodeType',this.self.nodeType);
a8c008f1   Benjamin Renard   Fix contextual menu
30
31
32
	if (this.get('leaf')) {
		this.updateTabs(this.get('tabs'));
	}
f31bea1c   Benjamin Renard   wip for save plot
33
34
    },

0ead0129   Benjamin Renard   Modify save plot ...
35
36
37
38
39
40
41
42
43
44
45
46
    updateTabs : function(tabs) {
	if (tabs) {
		var oneTab = (tabs.length == 1);
        	this.set('leaf', oneTab); 
		this.set('iconCls', oneTab ? 'icon-plot-page' : 'icon-plot-pages');
		this.removeAll();
		if (tabs.length > 1) {
			var me = this;
			Ext.Array.each(tabs, function(tab) {
				var tabNode = new amdaModel.PlotTabNode({text: tab.name, tabid: tab.id});
              			me.appendChild(tabNode);
			});
f31bea1c   Benjamin Renard   wip for save plot
47
		}
ebbb3638   Benjamin Renard   Edit plot tab on ...
48
		this.set('tabs', tabs);
f31bea1c   Benjamin Renard   wip for save plot
49
	}
16035364   Benjamin Renard   First commit
50
51
    },

0ead0129   Benjamin Renard   Modify save plot ...
52
53
54
55
    specialUpdate : function(res) {
	this.updateTabs(res.tabs);
    },

16035364   Benjamin Renard   First commit
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
    allMenuItems : function() {
        var menuItems =
         [{
             fnId : 'root-createDir',
             text : 'Create Folder'
         }, {
             fnId : 'dire-createDir',
             text : 'Create Folder'
         }, {
             fnId : 'dire-renameNode',
             text : 'Rename Folder'
         }, {
             fnId : 'dire-deleteNode',
             text : 'Delete Folder'
         }, {
            fnId : 'leaf-editPlot',
            text : 'Plot By Request'
         }, {
16035364   Benjamin Renard   First commit
74
75
76
77
78
             fnId : 'leaf-renameNode',
             text : 'Rename Request'
         }, {
             fnId : 'leaf-deleteNode',
             text : 'Delete Request'
bdcdb526   Benjamin Renard   Implements action...
79
80
81
82
         }, {
             fnId : 'leaf-insertTabs',
             text : 'Insert in current Plot Request'

16035364   Benjamin Renard   First commit
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
         }];

        return menuItems;
    }, 
    
    allMenuMultiItems : function() {
        var menuMulti = [
            {
                fnId : 'mult-deleteMulti',
                text : 'Delete selected Requests'
            }
        ];
        return menuMulti;
    },
    
18d4a11e   Benjamin Renard   Save and load plo...
98
99
100
101
102
103
104
105
    getAllContextMenuItems: function(){
        return this.allMenuItems();
    },
    
    getMultiContextMenuItems: function(){
        return this.allMenuMultiItems();
    },
    
16035364   Benjamin Renard   First commit
106
    onMenuItemClick : function(menu,item,event) {
f5aaaec9   Elena.Budnik   no Download from ...
107
		 
16035364   Benjamin Renard   First commit
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
        var fnId = Ext.util.Format.substr(item.fnId, 5, item.fnId.length);

        switch (fnId) {

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

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

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

        case 'editPlot':     
a73f0195   Benjamin Renard   Insert interval i...
125
            this.editLeaf(); 
16035364   Benjamin Renard   First commit
126
            break;
16035364   Benjamin Renard   First commit
127
128
129
130
	    
        case 'deleteMulti':
            this.deleteMulti();
            break;
bdcdb526   Benjamin Renard   Implements action...
131
132
        case 'insertTabs':
	    this.insertPlotTabsRequest();
16035364   Benjamin Renard   First commit
133
134
        default:
            break;
f5aaaec9   Elena.Budnik   no Download from ...
135
        }
7c762483   Benjamin Renard   Fix some bugs rel...
136
137
    },

429f876c   Benjamin Renard   Fix plot request ...
138
139
    isRealLeaf: function()
    {
7c762483   Benjamin Renard   Fix some bugs rel...
140
	var isFolder = (!this.isLeaf()) && (this.get('tabs') === false);
429f876c   Benjamin Renard   Fix plot request ...
141
        return !isFolder;
bdcdb526   Benjamin Renard   Implements action...
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
    },

    insertPlotTabsRequest: function() {
	var me = this;
	AmdaAction.getObject(me.get('id'), me.get('nodeType'), function (result,remoteEvent) {
		var paramObj = Ext.create(me.get('objectDataModel'), result);
		myDesktopApp.getLoadedModule(me.get('moduleId'), true, function (module) {
			module.createWindow(function () {
				var uiContent = module.getUiContent();
				if (uiContent != null) {
					paramObj.tabs().each(function (tab) {
						var tabData = tab.getJsonValues();
						uiContent.insertPlotTab(tabData);
					});
				}
			});
		});
	});
16035364   Benjamin Renard   First commit
160
161
162
    }
   
});