Bug #4650: Fix sunstone tab actions dependencies

This commit is contained in:
Carlos Martín committed 2016-07-19 14:26:41 +02:00
1 parent eed6b268ad
commit 19434406f9
6 files changed
+42 -24

No files matched your search

+5 -1
View File
@@ -145,7 +145,11 @@ define(function(require) {
'logo': (_config['view']["small_logo"] || "images/one_small_logo.png"),
'vmLogos': (_config['vm_logos']),
'enabledTabs': _config['view']['enabled_tabs'],
'onedConf': _config['oned_conf']
'onedConf': _config['oned_conf'],
"allTabs": function() {
return Object.keys(_config['view']['tabs']);
}
}
return Config;
+30 -16
View File
@@ -38,17 +38,14 @@ define(function(require) {
};
var _addMainTabs = function() {
_addActions();
$.each(Config.enabledTabs, function(i, tabName){
var name = './tabs/' + tabName;
var tabObj = require(name);
var _tabId = tabObj.tabId;
SunstoneCfg["tabs"][_tabId] = tabObj;
var actions = tabObj.actions;
if (actions) {
_addActions(actions)
}
var panels = tabObj.panels;
if (panels) {
_addPanels(_tabId, panels)
@@ -76,11 +73,18 @@ define(function(require) {
});
}
var _addActions = function(actions) {
$.each(actions, function(actionName, action) {
SunstoneCfg["actions"][actionName] = action;
})
return false;
var _addActions = function() {
$.each(Config.allTabs(), function(i, tabName){
var name = './tabs/' + tabName;
var tabObj = require(name);
var actions = tabObj.actions;
if (actions) {
$.each(actions, function(actionName, action) {
SunstoneCfg["actions"][actionName] = action;
});
}
});
}
var _addDialogs = function(dialogs) {
@@ -963,13 +967,11 @@ define(function(require) {
* tab will be used
*/
function _hideFormPanelLoading(tabId) {
var context;
if (tabId){
context = $("#" + tabId);
} else {
context = $(".tab:visible"); // current tab
tabId = context.attr("id");
if (tabId == undefined){
tabId = _getTab()
}
var context = $("#" + tabId);
//$(".sunstone-form", context).html(content);
$(".loadingForm", context).hide();
@@ -988,11 +990,19 @@ define(function(require) {
}
function _hideFormPanel(tabId) {
if (tabId == undefined){
tabId = _getTab()
}
var context = $("#" + tabId);
$('[href="back"]', context).trigger("click");
}
function _popFormPanelLoading(tabId) {
if (tabId == undefined){
tabId = _getTab()
}
var context = $("#" + tabId);
$(".sunstone-list", context).hide();
$(".sunstone-info", context).hide();
@@ -1022,6 +1032,10 @@ define(function(require) {
}
function _enableFormPanelSubmit(tabId) {
if (tabId == undefined){
tabId = _getTab()
}
var context = $("#" + tabId);
$(".submit_button", context).
removeAttr("disabled").
@@ -63,7 +63,7 @@ define(function(require) {
type: "single",
call: OpenNebulaResource.instantiate,
callback: function(request, response){
Sunstone.hideFormPanel(TAB_ID);
Sunstone.hideFormPanel();
OpenNebulaAction.clear_cache("SERVICE");
Notifier.notifyCustom(Locale.tr("Service created"), " ID: " + response.DOCUMENT.ID, false);
@@ -72,7 +72,7 @@ define(function(require) {
return Sunstone.getDataTable(TAB_ID).elements(opts);
},
error: function(request, response){
Sunstone.hideFormPanelLoading(TAB_ID);
Sunstone.hideFormPanelLoading();
Notifier.onError(request, response);
},
notify: false
@@ -160,7 +160,7 @@ define(function(require) {
n_roles_done += 1;
if(n_roles_done == n_roles){
Sunstone.enableFormPanelSubmit(TAB_ID);
Sunstone.enableFormPanelSubmit();
}
},
error: function(request,error_json, container){
@@ -153,7 +153,7 @@ define(function(require) {
type: "multiple",
call: OpenNebulaResource.instantiate,
callback: function(request, response) {
Sunstone.hideFormPanel(TAB_ID);
Sunstone.hideFormPanel();
OpenNebulaAction.clear_cache("VM");
Notifier.notifyCustom(Locale.tr("VM created"), " ID: " + response, false);
@@ -172,7 +172,7 @@ define(function(require) {
type: "single",
call: OpenNebulaResource.instantiate,
callback: function(request, response) {
Sunstone.hideFormPanel(TAB_ID);
Sunstone.hideFormPanel();
OpenNebulaAction.clear_cache("VM");
},
error: function(request, response){
@@ -198,7 +198,7 @@ define(function(require) {
type: "single",
call: OpenNebulaResource.instantiate_persistent,
callback: function(request, response) {
Sunstone.hideFormPanel(TAB_ID);
Sunstone.hideFormPanel();
OpenNebulaAction.clear_cache("VM");
Notifier.notifyCustom(Locale.tr("VM created"), " ID: " + response, false);
@@ -128,7 +128,7 @@ define(function(require) {
if (!this.selected_nodes || this.selected_nodes.length == 0) {
Notifier.notifyError(Locale.tr("No template selected"));
Sunstone.hideFormPanelLoading(this.tabId);
Sunstone.hideFormPanelLoading();
return false;
}