diff --git a/src/sunstone/public/app/tabs/vnets-tab/form-panels/create.js b/src/sunstone/public/app/tabs/vnets-tab/form-panels/create.js
index 264db5d87f..da87440e1f 100644
--- a/src/sunstone/public/app/tabs/vnets-tab/form-panels/create.js
+++ b/src/sunstone/public/app/tabs/vnets-tab/form-panels/create.js
@@ -12,6 +12,7 @@ define(function(require) {
var ArTab = require('tabs/vnets-tab/utils/ar-tab');
var SecurityGroupsTable = require('tabs/secgroups-tab/datatable');
var TemplateUtils = require('utils/template-utils');
+ var WizardFields = require('utils/wizard-fields');
/*
TEMPLATES
@@ -215,7 +216,7 @@ define(function(require) {
this.securityGroupsTable.initialize();
this.securityGroupsTable.refreshResourceTableSelect();
- CustomTags.setup( $("#vnetCreateContextTab", context) );
+ CustomTags.setup($("#vnetCreateContextTab", context));
// Add first AR
$("#vnet_wizard_ar_btn", context).trigger("click");
@@ -232,13 +233,13 @@ define(function(require) {
this.arTabObjects[ar_id] = ar_tab;
var html_tab_content =
- '
'+
+ '
' +
ar_tab.html(str_ar_tab_id) +
'
';
// Append the new div containing the tab and add the tab to the list
- var a = $("
"+
- Locale.tr("Address Range")+" "
+ var a = $("
" +
+ Locale.tr("Address Range") + " "
).appendTo($("dl#vnet_wizard_ar_tabs", context));
$(html_tab_content).appendTo($("#vnet_wizard_ar_tabs_content", context));
@@ -255,16 +256,16 @@ define(function(require) {
//Fetch values
var network_json = {};
- this.retrieveWizardFields($("#vnetCreateGeneralTab", context), network_json);
- this.retrieveWizardFields($("#vnetCreateBridgeTab", context), network_json);
- this.retrieveWizardFields($("#vnetCreateContextTab", context), network_json);
+ $.extend(network_json, WizardFields.retrieve($("#vnetCreateGeneralTab", context)));
+ $.extend(network_json, WizardFields.retrieve($("#vnetCreateBridgeTab", context)));
+ $.extend(network_json, WizardFields.retrieve($("#vnetCreateContextTab", context)));
var secgroups = this.securityGroupsTable.retrieveResourceTableSelect();
if (secgroups != undefined && secgroups.length != 0) {
network_json["SECURITY_GROUPS"] = secgroups.join(",");
}
- $.extend(network_json, CustomTags.retrieve( $("#vnetCreateContextTab", context) ));
+ $.extend(network_json, CustomTags.retrieve($("#vnetCreateContextTab", context)));
$('.ar_tab', context).each(function() {
var ar_id = $(this).attr("ar_id");
@@ -315,32 +316,32 @@ define(function(require) {
$("#default_sg_warning").hide();
// Populates the Avanced mode Tab
- $('#template',context).val(TemplateUtils.convert_template_to_string(element.TEMPLATE).replace(/^[\r\n]+$/g, ""));
+ $('#template', context).val(TemplateUtils.convert_template_to_string(element.TEMPLATE).replace(/^[\r\n]+$/g, ""));
- $('[wizard_field="NAME"]',context).val(
+ $('[wizard_field="NAME"]', context).val(
element.NAME). //TODO escapeDoubleQuotes(htmlDecode( element.NAME ))).
prop("disabled", true).
prop('wizard_field_disabled', true);
- this.fillWizardFields($("#vnetCreateGeneralTab", context), element.TEMPLATE);
- this.fillWizardFields($("#vnetCreateBridgeTab", context), element.TEMPLATE);
- this.fillWizardFields($("#vnetCreateContextTab", context), element.TEMPLATE);
+ WizardFields.fill($("#vnetCreateGeneralTab", context), element.TEMPLATE);
+ WizardFields.fill($("#vnetCreateBridgeTab", context), element.TEMPLATE);
+ WizardFields.fill($("#vnetCreateContextTab", context), element.TEMPLATE);
// Show all network mode inputs, and make them not required. This will change
// if a different network model is selected
- $('input#bridge,label[for="bridge"]',context).show().prop('wizard_field_disabled', false).removeAttr('required');
- $('input#phydev,label[for="phydev"]',context).show().prop('wizard_field_disabled', false).removeAttr('required');
- $('select#vlan,label[for="vlan"]',context).show().prop('wizard_field_disabled', false).removeAttr('required');
- $('input#vlan_id,label[for="vlan_id"]',context).show().prop('wizard_field_disabled', false).removeAttr('required');
- $('input#ip_spoofing,label[for="ip_spoofing"]',context).show().prop('wizard_field_disabled', false);
- $('input#mac_spoofing,label[for="mac_spoofing"]',context).show().prop('wizard_field_disabled', false);
+ $('input#bridge,label[for="bridge"]', context).show().prop('wizard_field_disabled', false).removeAttr('required');
+ $('input#phydev,label[for="phydev"]', context).show().prop('wizard_field_disabled', false).removeAttr('required');
+ $('select#vlan,label[for="vlan"]', context).show().prop('wizard_field_disabled', false).removeAttr('required');
+ $('input#vlan_id,label[for="vlan_id"]', context).show().prop('wizard_field_disabled', false).removeAttr('required');
+ $('input#ip_spoofing,label[for="ip_spoofing"]', context).show().prop('wizard_field_disabled', false);
+ $('input#mac_spoofing,label[for="mac_spoofing"]', context).show().prop('wizard_field_disabled', false);
if (element.TEMPLATE["SECURITY_GROUPS"] != undefined &&
- element.TEMPLATE["SECURITY_GROUPS"].length != 0){
+ element.TEMPLATE["SECURITY_GROUPS"].length != 0) {
var secgroups = element.TEMPLATE["SECURITY_GROUPS"].split(",");
- this.securityGroupsTable.selectResourceTableSelect({ ids : secgroups });
+ this.securityGroupsTable.selectResourceTableSelect({ids : secgroups});
} else {
this.securityGroupsTable.refreshResourceTableSelect();
}
@@ -350,11 +351,11 @@ define(function(require) {
var fields = $('[wizard_field]', context);
- fields.each(function(){
- var field = $(this);
- var field_name = field.attr('wizard_field');
+ fields.each(function() {
+ var field = $(this);
+ var field_name = field.attr('wizard_field');
- delete element.TEMPLATE[field_name];
+ delete element.TEMPLATE[field_name];
});
CustomTags.fill($("#vnetCreateContextTab", context), element.TEMPLATE);
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 5c7dc6a8f1..679cdc8b59 100644
--- a/src/sunstone/public/app/utils/form-panels/form-panel.js
+++ b/src/sunstone/public/app/utils/form-panels/form-panel.js
@@ -14,9 +14,7 @@ define(function(require) {
'show': _show,
'hide': _hide,
'reset': _reset,
- 'setAction': _setAction,
- 'retrieveWizardFields': _retrieveWizardFields,
- 'fillWizardFields': _fillWizardFields
+ 'setAction': _setAction
}
return BaseFormPanel;
@@ -87,57 +85,4 @@ define(function(require) {
function _setAction(action) {
this.action = action
}
-
- // TODO: other types: radio, checkbox
- function _retrieveWizardFields(dialog, template_json) {
- var fields = $('[wizard_field]', dialog);
-
- fields.each(function() {
- var field = $(this);
-
- if (field.prop('wizard_field_disabled') != true &&
- field.val() != null && field.val().length &&
- (field.attr("type") != "checkbox" || field.prop("checked"))
- ) {
-
- var field_name = field.attr('wizard_field');
- template_json[field_name] = field.val();
- }
- });
- }
-
- function _fillWizardFields(dialog, template_json) {
- var fields = $('[wizard_field]', dialog);
-
- fields.each(function() {
- var field = $(this);
- var field_name = field.attr('wizard_field');
- if (template_json[field_name]) {
- switch (field.attr("type")){
- case "radio":
- var checked = (field.val() == template_json[field_name]);
-
- field.prop("checked", checked);
-
- if (checked) {
- field.change();
- }
- break;
- case "checkbox":
- var checked = (field.val().toUpperCase() ==
- template_json[field_name].toUpperCase());
-
- field.prop("checked", checked);
-
- if (checked) {
- field.change();
- }
- break;
- default:
- field.val(template_json[field_name]) //TODO field.val(escapeDoubleQuotes(htmlDecode(template_json[field_name])));
- field.change();
- }
- }
- });
- }
})
diff --git a/src/sunstone/public/app/utils/wizard-fields.js b/src/sunstone/public/app/utils/wizard-fields.js
new file mode 100644
index 0000000000..e02075a78c
--- /dev/null
+++ b/src/sunstone/public/app/utils/wizard-fields.js
@@ -0,0 +1,61 @@
+define(function(require) {
+ return {
+ 'retrieve': _retrieveWizardFields,
+ 'fill': _fillWizardFields
+ }
+
+ // TODO: other types: radio, checkbox
+ function _retrieveWizardFields(dialog) {
+ var template_json = {};
+ var fields = $('[wizard_field]', dialog);
+
+ fields.each(function() {
+ var field = $(this);
+
+ if (field.prop('wizard_field_disabled') != true &&
+ field.val() != null && field.val().length &&
+ (field.attr("type") != "checkbox" || field.prop("checked"))
+ ) {
+
+ var field_name = field.attr('wizard_field');
+ template_json[field_name] = field.val();
+ }
+ });
+ return template_json;
+ }
+
+ function _fillWizardFields(dialog, template_json) {
+ var fields = $('[wizard_field]', dialog);
+
+ fields.each(function() {
+ var field = $(this);
+ var field_name = field.attr('wizard_field');
+ if (template_json[field_name]) {
+ switch (field.attr("type")){
+ case "radio":
+ var checked = (field.val() == template_json[field_name]);
+
+ field.prop("checked", checked);
+
+ if (checked) {
+ field.change();
+ }
+ break;
+ case "checkbox":
+ var checked = (field.val().toUpperCase() ==
+ template_json[field_name].toUpperCase());
+
+ field.prop("checked", checked);
+
+ if (checked) {
+ field.change();
+ }
+ break;
+ default:
+ field.val(template_json[field_name]) //TODO field.val(escapeDoubleQuotes(htmlDecode(template_json[field_name])));
+ field.change();
+ }
+ }
+ });
+ }
+});