diff --git a/src/sunstone/public/app/sunstone.js b/src/sunstone/public/app/sunstone.js index 9d587af8ac..2c9e7d7f29 100644 --- a/src/sunstone/public/app/sunstone.js +++ b/src/sunstone/public/app/sunstone.js @@ -704,7 +704,7 @@ define(function(require) { formPanelInstance.insert(context); } - formPanelInstance.setAction(action); + formPanelInstance.setAction(context, action); tab["activeFormPanel"] = formPanelInstance; // Hide wizard/advanced selector if advanced not defined diff --git a/src/sunstone/public/app/tabs/clusters-tab/actions.js b/src/sunstone/public/app/tabs/clusters-tab/actions.js index dc01ce2fd6..44945dbacf 100644 --- a/src/sunstone/public/app/tabs/clusters-tab/actions.js +++ b/src/sunstone/public/app/tabs/clusters-tab/actions.js @@ -68,7 +68,6 @@ define(function(require) { type: "single", call: OpenNebulaResource.show, callback: function(request, response) { - Sunstone.resetFormPanel(TAB_ID, CREATE_DIALOG_ID); Sunstone.showFormPanel(TAB_ID, CREATE_DIALOG_ID, "update", function(formPanelInstance, context) { formPanelInstance.fill(context, response[XML_ROOT]); diff --git a/src/sunstone/public/app/tabs/clusters-tab/form-panels/create.js b/src/sunstone/public/app/tabs/clusters-tab/form-panels/create.js index 4a2a5c0620..6f9d2933ae 100644 --- a/src/sunstone/public/app/tabs/clusters-tab/form-panels/create.js +++ b/src/sunstone/public/app/tabs/clusters-tab/form-panels/create.js @@ -161,7 +161,6 @@ define(function(require) { } }); - Sunstone.resetFormPanel(TAB_ID, FORM_PANEL_ID); Sunstone.hideFormPanel(TAB_ID); return false; diff --git a/src/sunstone/public/app/tabs/templates-tab/actions.js b/src/sunstone/public/app/tabs/templates-tab/actions.js index 9c3c4fe6e6..ad3959af09 100644 --- a/src/sunstone/public/app/tabs/templates-tab/actions.js +++ b/src/sunstone/public/app/tabs/templates-tab/actions.js @@ -53,7 +53,6 @@ define(function(require) { type: "single", call: OpenNebulaTemplate.show, callback: function(request, response) { - Sunstone.resetFormPanel(TAB_ID, CREATE_DIALOG_ID); Sunstone.showFormPanel(TAB_ID, CREATE_DIALOG_ID, "update", function(formPanelInstance, context) { formPanelInstance.fill(context, response[XML_ROOT]) @@ -65,7 +64,6 @@ define(function(require) { type: "single", call: OpenNebulaTemplate.update, callback: function(request, response) { - Sunstone.resetFormPanel(TAB_ID, CREATE_DIALOG_ID); Sunstone.hideFormPanel(TAB_ID); Notifier.notifyMessage(Locale.tr("Virtual Template updated correctly")); }, diff --git a/src/sunstone/public/app/tabs/vdcs-tab/actions.js b/src/sunstone/public/app/tabs/vdcs-tab/actions.js index b5298c7e0a..dcfa867a06 100644 --- a/src/sunstone/public/app/tabs/vdcs-tab/actions.js +++ b/src/sunstone/public/app/tabs/vdcs-tab/actions.js @@ -155,7 +155,6 @@ define(function(require) { type: "single", call: OpenNebulaResource.show, callback: function(request, response) { - Sunstone.resetFormPanel(TAB_ID, CREATE_DIALOG_ID); Sunstone.showFormPanel(TAB_ID, CREATE_DIALOG_ID, "update", function(formPanelInstance, context) { formPanelInstance.fill(context, response.VDC); @@ -168,7 +167,6 @@ define(function(require) { type: "single", call: OpenNebulaResource.update, callback: function(request, response){ - Sunstone.resetFormPanel(TAB_ID, CREATE_DIALOG_ID); Sunstone.hideFormPanel(TAB_ID); Notifier.notifyMessage(Locale.tr("VDC updated correctly")); }, diff --git a/src/sunstone/public/app/tabs/vnets-tab/actions.js b/src/sunstone/public/app/tabs/vnets-tab/actions.js index 00c3342f8e..f6c646c57f 100644 --- a/src/sunstone/public/app/tabs/vnets-tab/actions.js +++ b/src/sunstone/public/app/tabs/vnets-tab/actions.js @@ -269,7 +269,6 @@ define(function(require) { type: "single", call: OpenNebulaNetwork.show, callback: function(request, response) { - Sunstone.resetFormPanel(TAB_ID, CREATE_DIALOG_ID); Sunstone.showFormPanel(TAB_ID, CREATE_DIALOG_ID, "update", function(formPanelInstance, context) { formPanelInstance.fill(context, response.VNET) @@ -282,7 +281,6 @@ define(function(require) { type: "single", call: OpenNebulaNetwork.update, callback: function(request, response) { - Sunstone.resetFormPanel(TAB_ID, CREATE_DIALOG_ID); Sunstone.hideFormPanel(TAB_ID); Notifier.notifyMessage(Locale.tr("Virtual Network updated correctly")); }, diff --git a/src/sunstone/public/app/utils/form-panels/form-panel.js b/src/sunstone/public/app/utils/form-panels/form-panel.js index df272ef137..c54ecbf5f5 100644 --- a/src/sunstone/public/app/utils/form-panels/form-panel.js +++ b/src/sunstone/public/app/utils/form-panels/form-panel.js @@ -73,8 +73,14 @@ define(function(require) { this.insert(context); } - function _setAction(action) { - this.action = action + function _setAction(context, action) { + var prevAction = this.action; + + this.action = action; + + if (prevAction != action || action == "update") { + this.reset(context); + } } // @return [Object] actionOptions of the form based on the defined action