From 334b447b0a40398c659b3ec422fa7f5e1be98a34 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Thu, 25 Jun 2015 18:35:57 +0200 Subject: [PATCH] feature #3748: Fix issue updating a template with nics and disks --- .../form-panels/create/wizard-tabs/network.js | 10 +++++++--- .../form-panels/create/wizard-tabs/storage.js | 6 +++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/network.js b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/network.js index 7fc650e982..f7f9c91eb4 100644 --- a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/network.js +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/network.js @@ -110,7 +110,7 @@ define(function(require) { if (!$.isEmptyObject(nicJSON)) {nicsJSON.push(nicJSON)}; }) - if (!$.isEmptyObject(nicsJSON)) { templateJSON['NIC'] = nicsJSON; }; + if (nicsJSON.length > 0) { templateJSON['NIC'] = nicsJSON; }; var nicDefault = $('#DEFAULT_MODEL', context).val(); if (nicDefault) { @@ -124,7 +124,7 @@ define(function(require) { function _fill(context, templateJSON) { var that = this; - var nics = templateJSON.NIC + var nics = templateJSON.NIC; if (nics instanceof Array) { $.each(nics, function(nicId, nicJSON) { if (nicId > 0) { @@ -141,13 +141,17 @@ define(function(require) { nicTab.fill(nicContext, nics); } + if (templateJSON.NIC) { + delete templateJSON.NIC; + } + var nicDefault = templateJSON.NIC_DEFAULT if (nicDefault != undefined) { if (nicDefault.MODEL) { $('#DEFAULT_MODEL', context).val(nicDefault.MODEL); } - delete template.NIC_DEFAULT; + delete templateJSON.NIC_DEFAULT; } } diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/storage.js b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/storage.js index ba3f45daba..f8be2042c9 100644 --- a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/storage.js +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/storage.js @@ -110,7 +110,7 @@ define(function(require) { if (!$.isEmptyObject(diskJSON)) {disksJSON.push(diskJSON)}; }) - if (!$.isEmptyObject(disksJSON)) { templateJSON['DISK'] = disksJSON; }; + if (disksJSON.length > 0) { templateJSON['DISK'] = disksJSON; }; return templateJSON; } @@ -133,6 +133,10 @@ define(function(require) { var diskContext = $('#' + diskTab.diskTabId, context); diskTab.fill(diskContext, disks); } + + if (templateJSON.DISK) { + delete templateJSON.DISK; + } } function _addDiskTab(context) {