1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-22 18:50:08 +03:00

bug #3912: Add update to common actions

This commit is contained in:
Daniel Molina 2015-08-21 12:48:54 +02:00
parent 43f801abf0
commit e6208c5248

View File

@ -7,10 +7,11 @@ define(function(require) {
CONSTRUCTOR
*/
function CommonActions(openNebulaResource, resourceStr, tabId) {
function CommonActions(openNebulaResource, resourceStr, tabId, xmlRoot) {
this.openNebulaResource = openNebulaResource;
this.tabId = tabId;
this.resourceStr = resourceStr;
this.xmlRoot = xmlRoot;
}
CommonActions.prototype.list = _list;
@ -21,6 +22,10 @@ define(function(require) {
CommonActions.prototype.singleAction = _singleAction;
CommonActions.prototype.create = _create;
CommonActions.prototype.showCreate = _showCreate;
CommonActions.prototype.showUpdate = _showUpdate;
CommonActions.prototype.checkAndShowUpdate = _checkAndShowUpdate;
CommonActions.prototype.update = _update;
CommonActions.prototype.updateTemplate = _updateTemplate;
return CommonActions;
@ -143,4 +148,63 @@ define(function(require) {
}
}
}
function _showUpdate(formPanelId) {
var that = this;
return {
type: "single",
call: that.openNebulaResource.show,
callback: function(request, response) {
Sunstone.showFormPanel(that.tabId, formPanelId, "update",
function(formPanelInstance, context) {
formPanelInstance.fill(context, response[that.xmlRoot]);
});
},
error: Notifier.onError
}
}
function _checkAndShowUpdate() {
var that = this;
return {
type: "single",
call: function() {
var selected_nodes = Sunstone.getDataTable(that.tabId).elements();
if (selected_nodes.length != 1) {
Notifier.notifyMessage("Please select one (and just one) resource to update.");
return false;
}
var resource_id = "" + selected_nodes[0];
Sunstone.runAction(that.resourceStr + ".show_to_update", resource_id);
}
}
}
function _update() {
var that = this;
return {
type: "single",
call: that.openNebulaResource.update,
callback: function(request, response){
Sunstone.hideFormPanel(that.tabId);
},
error: function(request, response){
Sunstone.hideFormPanelLoading(that.tabId);
Notifier.onError(request, response);
}
}
}
function _updateTemplate() {
var that = this;
return {
type: "single",
call: that.openNebulaResource.update,
callback: function(request) {
Sunstone.runAction(that.resourceStr + '.show', request.request.data[0][0]);
},
error: Notifier.onError
}
}
});