Commit d648a5c0dd3ea97c0118d359bbb6fd56de994569
1 parent
ebbb3638
Exists in
master
and in
102 other branches
Insert plot tab in current request
Showing
3 changed files
with
74 additions
and
6 deletions
Show diff stats
js/app/models/PlotObjects/PlotRequestObject.js
... | ... | @@ -73,8 +73,17 @@ Ext.define('amdaPlotObj.PlotRequestObject', { |
73 | 73 | |
74 | 74 | createNewTab: function() { |
75 | 75 | this.set('last-tab-id', this.get('last-tab-id') + 1); |
76 | - var recs = this.tabs().add({id : this.get('last-tab-id')}); | |
77 | - recs[0].setDefaultValues(); | |
76 | + var data = {id: this.get('last-tab-id')}; | |
77 | + var applyDefault = true; | |
78 | + if ((arguments.length > 0) && arguments[0]) { | |
79 | + data = arguments[0]; | |
80 | + data['id'] = this.get('last-tab-id'); | |
81 | + applyDefault = false; | |
82 | + } | |
83 | + var recs = this.tabs().add(data); | |
84 | + if (applyDefault) { | |
85 | + recs[0].setDefaultValues(); | |
86 | + } | |
78 | 87 | this.dirty = true; |
79 | 88 | return recs[0]; |
80 | 89 | }, | ... | ... |
js/app/models/PlotTabNode.js
... | ... | @@ -65,11 +65,11 @@ Ext.define('amdaModel.PlotTabNode', { |
65 | 65 | switch (fnId) { |
66 | 66 | |
67 | 67 | case 'openTab': |
68 | - console.log('openTab'); | |
68 | + this.insertPlotTabRequest(true); | |
69 | 69 | break; |
70 | 70 | |
71 | 71 | case 'insertTab': |
72 | - console.log('insertTab'); | |
72 | + this.insertPlotTabRequest(false); | |
73 | 73 | break; |
74 | 74 | |
75 | 75 | case 'renameTab': |
... | ... | @@ -80,11 +80,61 @@ Ext.define('amdaModel.PlotTabNode', { |
80 | 80 | } |
81 | 81 | }, |
82 | 82 | |
83 | + insertPlotTabRequest : function(inNewRequest) { | |
84 | + var me = this; | |
85 | + amdaModel.InteractiveNode.preloadNodes(this.parentNode.getRootNode(), function() { | |
86 | + AmdaAction.getObject(me.parentNode.get('id'), me.parentNode.get('nodeType'), function (result,remoteEvent) { | |
87 | + var paramObj = Ext.create(me.parentNode.get('objectDataModel'), result); | |
88 | + var tabData = null; | |
89 | + paramObj.tabs().each(function(tab) { | |
90 | + if (tab.get('id') == me.get('tabid')) { | |
91 | + tabData = tab.getJsonValues(); | |
92 | + } | |
93 | + }); | |
94 | + if (tabData != null) { | |
95 | + if (inNewRequest) { | |
96 | + tabData['id'] = 1; | |
97 | + paramObj.set('id',''); | |
98 | + paramObj.set('name', ''); | |
99 | + paramObj.set('folderId', ''); | |
100 | + paramObj.set('active-tab-id', 1); | |
101 | + paramObj.set('last-tab-id', 1); | |
102 | + paramObj.set('last-plotted-tab', 1); | |
103 | + paramObj.loadTabs([tabData]); | |
104 | + myDesktopApp.getLoadedModule(me.get('moduleId'), true, function (module) { | |
105 | + module.setContextNode(me.parentNode.getRootNode()); | |
106 | + module.createWindow(function () { | |
107 | + var uiContent = module.getUiContent(); | |
108 | + if (uiContent != null) { | |
109 | + uiContent.resetProcess(paramObj.getJsonValues()); | |
110 | + } | |
111 | + }); | |
112 | + }); | |
113 | + } | |
114 | + else { | |
115 | + myDesktopApp.getLoadedModule(me.get('moduleId'), true, function (module) { | |
116 | + module.createWindow(function () { | |
117 | + var uiContent = module.getUiContent(); | |
118 | + if (uiContent != null) { | |
119 | + var tabObj = new amdaPlotObj.PlotTabObject(tabData); | |
120 | + uiContent.insertPlotTab(tabData); | |
121 | + } | |
122 | + }); | |
123 | + }); | |
124 | + } | |
125 | + } | |
126 | + }, me); | |
127 | + }); | |
128 | + }, | |
129 | + | |
83 | 130 | editPlotTab : function() { |
84 | 131 | var me = this; |
85 | 132 | this.parentNode.editLeaf(function () { |
86 | 133 | myDesktopApp.getLoadedModule(me.get('moduleId'), true, function (module) { |
87 | - module.forceTabSelection(me.get('tabid')); | |
134 | + var uiContent = module.getUiContent(); | |
135 | + if (uiContent != null) { | |
136 | + uiContent.forceActiveTab(me.get('tabid')); | |
137 | + } | |
88 | 138 | }); |
89 | 139 | }); |
90 | 140 | } | ... | ... |
js/app/views/PlotUI.js
... | ... | @@ -84,7 +84,11 @@ Ext.define('amdaUI.PlotUI', { |
84 | 84 | resetProcess : function(){ |
85 | 85 | var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id); |
86 | 86 | plotModule.createLinkedNode(); |
87 | - plotModule.createObject(); | |
87 | + var obj = null; | |
88 | + if ((arguments.length > 0) && (arguments[0] != null)) { | |
89 | + obj = arguments[0]; | |
90 | + } | |
91 | + plotModule.createObject(obj); | |
88 | 92 | this.setObject(plotModule.linkedNode.get('object')); |
89 | 93 | }, |
90 | 94 | |
... | ... | @@ -181,6 +185,11 @@ Ext.define('amdaUI.PlotUI', { |
181 | 185 | } |
182 | 186 | } |
183 | 187 | }, |
188 | + | |
189 | + insertPlotTab : function(tabData) { | |
190 | + var newTab = this.object.createNewTab(tabData); | |
191 | + this.plotTabs.addPlotTab(newTab,true); | |
192 | + }, | |
184 | 193 | |
185 | 194 | updateLinkedToMultiPlotMode : function(isLinkedToMultiPlotMode) { |
186 | 195 | this.timeSelector.setVisible(isLinkedToMultiPlotMode); | ... | ... |