<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <br>
    Some issues I found:<br>
    <br>
    1. While trying to add a new network:<br>
    <div selected="true" role="tabpanel" class="netInfoResponseText
      netInfoText ">
      <pre role="list"><code class="wrappedText focusRow" role="listitem">{
</code><code class="wrappedText focusRow" role="listitem">  "reason":"KCHTMPL0017E: All networks for the template must be specified in a list.",
</code><code class="wrappedText focusRow" role="listitem">  "code":"400 Bad Request",
</code><code class="wrappedText focusRow" role="listitem">  "call_stack":"Traceback (most recent call last):\n  File \"/usr/lib/python2.7/site-packages/cherrypy</code><code class="wrappedText focusRow" role="listitem">/_cprequest.py\", 
line 656, in respond\n    response.body = self.handler()\n  File \"/usr/lib/python2</code><code class="wrappedText focusRow" role="listitem">.7/site-packages/cherrypy/lib/encoding.py\", 
line 188, in __call__\n    self.body = self.oldhandler(</code><code class="wrappedText focusRow" role="listitem">*args, **kwargs)\n  File \"/usr/lib/python2.7/site-packages/cherrypy/_cpdispatch.py\", 
line 34, in __call__</code><code class="wrappedText focusRow" role="listitem">\n    return self.callable(*self.args, **self.kwargs)\n  File \"/home/alinefm/kimchi/src/kimchi/control</code><code class="wrappedText focusRow" role="listitem">/base.py\", line 162, 
in index\n    raise cherrypy.HTTPError(400, e.message)\nHTTPError: (400, u'KCHTMPL0017E</code><code class="wrappedText focusRow" role="listitem">: All networks for the template must be specified in a list.')\n"
</code><code class="wrappedText focusRow" role="listitem">}</code></pre>
    </div>
    2. The "Save" button on footer must be shown only in the General Tab
    as Storage and Network Tabs have different save handlers.<br>
    <br>
    <br>
    <div class="moz-cite-prefix">On 11/13/2014 04:47 AM, Wen Wang wrote:<br>
    </div>
    <blockquote
      cite="mid:1415861245-24379-1-git-send-email-wenwang@linux.vnet.ibm.com"
      type="cite">
      <pre wrap="">From: Wen Wang <a class="moz-txt-link-rfc2396E" href="mailto:wenwang@linux.vnet.ibm.com">&lt;wenwang@linux.vnet.ibm.com&gt;</a>

V2 -&gt; V3:
Fix the bug that iscsi and scsi disk size won't change automatically

V1 -&gt; V2:

1) Enable "iSCSI" and "SCSI" for storage.
2) Changed the storage tab from "storage" to "Storage".
3) Fix the defect that when editing/adding "Storage" or "Interface" line
went down issue.
4) "Storage" and "Interface" content can display properly on Remote and
Image created template.
5) Fix the defect that "Image" didn't show properly when using a Image
created template.

This patch redesigned "Edit Template" diaguage in "Templates". New "Edit
Template" will display all the related information into tabs of
"General", "Storage" and "Interface". Due to unfinished back-end work,
functions are not fully supported, which will be finished in the future
work.

Temporary disabled functions:
1) Multiple disk operation with multiple storage pools edit in template
for which reason the add button in "Storage" tab is disabled.
2) iSCSI and SCSI storage pool add is removed since we are going to
allow this kind of operation in the process of creating a VM.

Signed-off-by: Wen Wang <a class="moz-txt-link-rfc2396E" href="mailto:wenwang@linux.vnet.ibm.com">&lt;wenwang@linux.vnet.ibm.com&gt;</a>
---
 ui/css/theme-default/template-edit.css |  116 +++++++----
 ui/js/src/kimchi.template_edit_main.js |  366 +++++++++++++++++++++++---------
 ui/pages/template-edit.html.tmpl       |  168 ++++++++-------
 3 files changed, 434 insertions(+), 216 deletions(-)

diff --git a/ui/css/theme-default/template-edit.css b/ui/css/theme-default/template-edit.css
index 4975f1b..094e909 100644
--- a/ui/css/theme-default/template-edit.css
+++ b/ui/css/theme-default/template-edit.css
@@ -17,24 +17,33 @@
  */
 #template-edit-window {
     font-size: 13px;
-    height: 600px;
-    width: 1000px;
+    height: 500px;
+    width: 800px;
 }

-.template-edit-fieldset {
-    float: left;
-    padding: 1em;
+#edit-template-tabs {
+    background: none repeat scroll 0 0 transparent;
+    border: medium none;
+    height: 100%;
+    padding: 0;
 }

-.template-edit-wrapper-label, .template-edit-wrapper-controls {
+#edit-template-tabs .form-template-inline-wrapper {
+    display: inline-block;
     vertical-align: top;
-    width: 470px;
 }

 .template-edit-wrapper-label {
-    height: 18px;
-    line-height: 18px;
-    margin-top: 8px;
+    vertical-align: top;
+    min-width: 100px;
+    height: 35px;
+    line-height: 35px;
+    margin: 7px 0 8px;
+}
+
+.template-edit-wrapper-controls {
+    vertical-align: top;
+    width: 400px;
 }

 .template-edit-wrapper-controls input[type="text"] {
@@ -56,7 +65,7 @@

 .template-edit-wrapper-controls &gt; .dropdown {
     margin: 5px 0 0 1px;
-    width: 440px;
+    width: 372px;
 }

 .template-edit-wrapper-controls input[type="text"][disabled] {
@@ -65,41 +74,72 @@
     cursor: not-allowed;
 }

-.hidden-area {
-    display: none;
+#edit-template-tabs .template-tab-header {
+    margin-bottom: 8px;
+    padding-bottom: 2px;
+    font-weight: bold;
+    border-bottom: 1px solid #999999;
+    overflow: hidden;
 }

-.template-edit-wrapper-controls .select-list-box {
-    width: 464px;
-    max-height: 168px;
-    overflow: auto;
-    margin-top: 5px;
-    border: 1px solid #ccc;
+#edit-template-tabs .template-tab-header .action-area {
+    float: right;
+    height: 20px;
+    width: 20px;
 }

-.template-edit-wrapper-controls .select-list-box&gt;li&gt;label {
-    display: block;
+#edit-template-tabs .template-interface-cell {
+    display: inline-block;
+    width: 250px;
 }

-.template-edit-wrapper-controls .select-list-box&gt;li&gt;label&gt;
-input[type="checkbox"] {
-    display: none;
+#edit-template-tabs .template-storage-cell{
+    display: inline-block;
+    width: 230px;
+}
+
+#edit-template-tabs .template-storage-cell label {
+    height: 25px;
+    padding: 2px;
+    border: 1px;
 }

-.template-edit-wrapper-controls .select-list-box&gt;li&gt;label&gt;.item {
-    display: block;
-    height: 41px;
-    line-height: 41px;
-    padding: 0 20px 0 40px;
-    border-bottom: 1px solid #ccc;
-    box-shadow: 0px 1px 1px #fff;
-    text-shadow: -1px -1px 1px #ddd, 1px 1px 1px #fff;
-    color: #222;
-    font-size: 12px;
+#form-template-storage .template-tab-body select {
+    width: 140px;
 }

-.template-edit-wrapper-controls .select-list-box&gt;li&gt;label&gt;
-input[type="checkbox"]:CHECKED+.item {
-    background: #f8f8f8 url(../images/theme-default/check-green.png) no-repeat
-                10px center;
+#form-template-storage .template-tab-body input {
+    width: 56px;
+    height: 17px;
 }
+
+#form-template-storage .template-tab-body .template-storage-name {
+    width: 220px;
+}
+
+#edit-template-tabs .template-tab-body input[readonly] {
+    background: none repeat scroll 0 0 rgba(0, 0, 0, 0);
+    border-color: transparent;
+    text-overflow: ellipsis;
+}
+
+#edit-template-tabs .template-tab-body .item {
+    height: 25px;
+}
+
+#form-template-interface .template-tab-body select {
+    width: 180px;
+}
+
+#edit-template-tabs .template-tab-body .action-area {
+    float: right;
+}
+
+#edit-template-tabs .template-tab-body .action-area button {
+    width: 20px;
+    height: 20px;
+}
+
+#edit-template-tabs .hide {
+    display: none;
+}
\ No newline at end of file
diff --git a/ui/js/src/kimchi.template_edit_main.js b/ui/js/src/kimchi.template_edit_main.js
index 2f4cc9a..5073c62 100644
--- a/ui/js/src/kimchi.template_edit_main.js
+++ b/ui/js/src/kimchi.template_edit_main.js
@@ -16,19 +16,23 @@
  * limitations under the License.
  */
 kimchi.template_edit_main = function() {
-    var templateEditForm = $('#form-template-edit');
+    var templateEditMain = $('#edit-template-tabs');
     var origDisks;
     var origPool;
+    var origNetworks;
     var templateDiskSize;
-    $('#template-name', templateEditForm).val(kimchi.selectedTemplate);
-    kimchi.retrieveTemplate(kimchi.selectedTemplate, function(template) {
+    $('#template-name', templateEditMain).val(kimchi.selectedTemplate);
+    templateEditMain.tabs();
+
+    var initTemplate = function(template) {
         origDisks =  template.disks;
         origPool = template.storagepool;
+        origNetworks = template.networks;
         for(var i=0;i&lt;template.disks.length;i++){
             if(template.disks[i].base){
                 template["vm-image"] = template.disks[i].base;
-                $('#templ-edit-cdrom').addClass('hide-content');
-                $('#templ-edit-vm-image').removeClass('hide-content');
+                $('.templ-edit-cdrom').addClass('hide');
+                $('.templ-edit-vm-image').removeClass('hide');
                 break;
             }
         }
@@ -37,18 +41,12 @@ kimchi.template_edit_main = function() {
             if (prop == 'graphics') {
                value = value["type"];
             }
-            $('input[name="' + prop + '"]', templateEditForm).val(value);
-        }
-        var disks = template.disks;
-        $('input[name="disks"]').val(disks[0].size);
-        templateDiskSize = $('input[name="disks"]').val();
-        if (disks[0].volume) {
-            var spool_value = $('#form-template-edit [name="storagepool"]').val();
-            $('input[name="storagepool"]', templateEditForm).val(spool_value + '/' + disks[0].volume);
-            $('input[name="disks"]', templateEditForm).attr('disabled','disabled');
+            $('input[name="' + prop + '"]', templateEditMain).val(value);
         }

         var vncOpt = [{label: 'VNC', value: 'vnc'}];
+        $('#template-edit-graphics').append('&lt;option selected&gt;VNC&lt;/option&gt;');
+        $('#template-edit-graphics').append('&lt;option&gt;Spice&lt;/option&gt;');
         kimchi.select('template-edit-graphics-list', vncOpt);
         var enableSpice = function() {
             if (kimchi.capabilities == undefined) {
@@ -61,119 +59,283 @@ kimchi.template_edit_main = function() {
             }
         };
         enableSpice();
-
-        var scsipools = {};
-        kimchi.listStoragePools(function(result) {
-            var options = [];
-            if (result &amp;&amp; result.length) {
-                $.each(result, function(index, storagePool) {
-                    if ((storagePool.state=="active") &amp;&amp; (storagePool.type !== 'kimchi-iso')) {
-                        if ((storagePool.type == 'iscsi') || (storagePool.type == 'scsi')){
-                            scsipools[storagePool.name] = [];
-                            kimchi.listStorageVolumes(storagePool.name, function(result) {
-                                if (result &amp;&amp; result.length) {
-                                    $.each(result, function(index, storageVolume) {
-                                        options.push({
-                                            label: storagePool.name + '/' + storageVolume.name,
-                                            value: '/storagepools/' + storagePool.name + '/' + storageVolume.name
-                                        });
-                                        scsipools[storagePool.name].push(storageVolume)
-                                    });
-                                }
-                                kimchi.select('template-edit-storagePool-list', options);
-                            });
-                        }
-                        else {
-                            options.push({
-                                label: storagePool.name,
-                                value: '/storagepools/' + storagePool.name
-                            });
-                        }
+        var initStorage = function(result) {
+            var scsipools = {};
+            var addStorageItem = function(storageData) {
+                var thisName;
+                var thisType;
+                var thisDisk;
+                var nodeStorage = $.parseHTML(kimchi.substitute($('#template-storage-pool-tmpl').html(), storageData));
+                $('.template-tab-body', '#form-template-storage').append(nodeStorage);
+                $('.edit', '#form-template-storage').button({
+                    icons : {primary : 'ui-icon-pencil'},
+                    text : false
+                }).click(function(evt) {
+                    evt.preventDefault();
+                    var storageItem = $(this).parent().parent();
+                    thisName = $('.template-storage-name', storageItem).val();
+                    thisType = $('.template-storage-type', storageItem).val();
+                    thisDisk = $('.template-storage-disk', storageItem).val();
+                    $('.template-storage-name', storageItem).hide();
+                    $('.template-storage-disk', storageItem).attr('readonly', false);
+                    if (thisType === 'iscsi' || thisType === 'scsi') {
+                        $('.template-storage-disk', storageItem).attr('readonly', true);
+                    } else {
+                        $('.template-storage-disk', storageItem).attr('readonly', false);
                     }
+                    $('.save', storageItem).parent().show();
+                    $('.delete', storageItem).parent().hide();
+                    var selectedStorage = $('select', storageItem).val();
+                    $('.template-storage-name', storageItem).val(selectedStorage).hide();
+                    $('select', storageItem).val(thisName).show();
                 });
-            }
-            if ($.isEmptyObject(scsipools)) {
-                kimchi.select('template-edit-storagePool-list', options);
-            }
-        });
-        kimchi.listNetworks(function(result) {
-            if(result &amp;&amp; result.length &gt; 0) {
-                var html = '';
-                var tmpl = $('#tmpl-network').html();
-                $.each(result, function(index, network) {
-                    if (result[index].state === 'active')
-                        html += kimchi.substitute(tmpl, network);
+                $('.delete', '#form-template-storage').button({
+                    icons : {primary : 'ui-icon-trash'},
+                    text : false
+                }).click(function(evt) {
+                    evt.preventDefault();
+                    $(this).parent().parent().remove();
+                });
+                $('.cancel', '#form-template-storage').button({
+                    icons : {primary : 'ui-icon-arrowreturnthick-1-w'},
+                    text : false
+                }).click(function(evt) {
+                    evt.preventDefault();
+                    var cancelEntity = $(this).parent().parent();
+                    if ($('.template-storage-name', cancelEntity).val() === 'null') {
+                        cancelEntity.remove();
+                    } else {
+                        $('select', cancelEntity).hide();
+                        $('.template-storage-name', cancelEntity).val(thisName).attr('readonly', true).show();
+                        $('.template-storage-type', cancelEntity).val(thisType).attr('readonly', true);
+                        $('.template-storage-disk', cancelEntity).val(thisDisk).attr('readonly', true);
+                        $('.save', cancelEntity).parent().hide();
+                        $('.edit', cancelEntity).parent().show();
+                    }
+                });
+                $('.save', '#form-template-storage').button({
+                    icons : {primary : 'ui-icon-disk'},
+                    text : false
+                }).click(function(evt) {
+                    evt.preventDefault();
+                    var storageItem = $(this).parent().parent();
+                    $('.save', storageItem).parent().hide();
+                    $('.delete', storageItem).parent().show();
+                    var selectedStorage = $('select', storageItem).val();
+                    $('.template-storage-name', storageItem).val(selectedStorage).attr('readonly', true).show();
+                    $('.template-storage-disk', storageItem).attr('readonly', true);
+                    $('.template-storage-type', storageItem).attr('readonly', true);
+                    $('select', storageItem).hide();
                 });
-                $('#template-edit-network-list').html(html).show();
-                if(template.networks &amp;&amp; template.networks.length &gt; 0) {
-                    $('input[name="networks"]', templateEditForm).each(function(index, element) {
-                        var value = $(element).val();
-                        if(template.networks.indexOf(value) &gt;= 0) {
-                            $(element).prop('checked', true);
+                var storageOptions = '';
+                var scsiOptions = '';
+                $('select', '#form-template-storage').find('option').remove();
+                $.each(result, function(index, storageEntities) {
+                    if((storageEntities.state === 'active') &amp;&amp; (storageEntities.type != 'kimchi-iso')) {
+                        if(storageEntities.type === 'iscsi' || storageEntities.type === 'scsi') {
+                            kimchi.listStorageVolumes(storageEntities.name, function(currentVolume) {
+                                $.each(currentVolume, function(indexSCSI, scsiEntities) {
+                                    scsiOptions += '&lt;option&gt;' + storageEntities.name + '/' + scsiEntities.name + '&lt;/option&gt;';
+                                });
+                                $('select', '#form-template-storage').append(scsiOptions);
+                            }, function() {});
+                        } else {
+                            var isSlected = storageEntities.name === 'default' ? ' selected' : '';
+                            storageOptions += '&lt;option' + isSlected + '&gt;' + storageEntities.name + '&lt;/option&gt;';
+                        }
+                    }
+                });
+                $('select', '#form-template-storage').append(storageOptions);
+                $('select', '#form-template-storage').change(function() {
+                    var selectedItem = $(this).parent().parent();
+                    var tempStorageName = $(this).val();
+                    var tempType;
+                    tempStorageName =tempStorageName.split('/')[0];
+                    var scsiCap;
+                    $.each(result, function(index, storageEntities) {
+                        if (tempStorageName === storageEntities.name) {
+                            selectedItem.find('.template-storage-type').val(storageEntities.type);
+                            scsiCap = storageEntities.capacity / Math.pow(1024, 3);
+                            tempType = storageEntities.type;
                         }
                     });
+                    if (tempType === 'iscsi' || tempType === 'scsi') {
+                        $('.template-storage-disk', selectedItem).attr('readonly', true).val(scsiCap);
+                    } else {
+                        $('.template-storage-disk', selectedItem).attr('readonly', false).val('10');
+                    }
+                });
+            };
+
+            if ((origDisks &amp;&amp; origDisks.length) &amp;&amp; (origPool &amp;&amp; origPool.length)) {
+                splitPool = origPool.split('/');
+                var defaultPool;
+                var defaultType;
+                $.each(result, function(index, poolEntities) {
+                    if (poolEntities.name === splitPool[splitPool.length-1]) {
+                        defaultType = poolEntities.type;
+                        defaultPool = splitPool[splitPool.length-1]
+                    }
+                });
+                if (origDisks[0]['volume']) {
+                    defaultPool = defaultPool + '/' + origDisks[0]['volume'];
                 }
-            } else {
-                $('#template-edit-network-list').hide();
+                $.each(origDisks, function(index, diskEntities) {
+                    var storageNodeData = {
+                        viewMode : '',
+                        editMode : 'hide',
+                        storageName : defaultPool,
+                        storageType : defaultType,
+                        storageDisk : diskEntities.size
+                    }
+                    addStorageItem(storageNodeData);
+                });
+                $('.template-storage-disk').attr('readonly', true);
             }
-        });
-    });

-    $('#template-edit-storagePool').change(function() {
-        storagepool = $(this).val();
-        var storageArray = storagepool.split("/");
-        if (storageArray.length &gt; 3) {
-            volumeName = storageArray.pop();
-            poolName = storageArray.pop();
-            kimchi.getStoragePoolVolume(poolName, volumeName, function(result) {
-                $('input[name="disks"]', templateEditForm).val(result.capacity / Math.pow(1024,3));
-                $('input[name="disks"]', templateEditForm).attr('disabled','disabled');
-                return false;
-            }, function (err) {
-                kimchi.message.error(err.responseJSON.reason);
+            $('#template-edit-storage-add-button').button({
+                icons: {
+                    primary: "ui-icon-plusthick"
+                },
+                text: false,
+                disabled: true
+            }).click(function(event) {
+                event.preventDefault();
+                var storageNodeData = {
+                    viewMode : 'hide',
+                    editMode : '',
+                    storageName : 'null',
+                    storageType : 'dir',
+                    storageDisk : '10'
+                }
+                addStorageItem(storageNodeData);
             });
-        } else {
-            $('input[name="disks"]', templateEditForm).removeAttr('disabled');
-            $('input[name="disks"]', templateEditForm).val(templateDiskSize);
-        }
-    });
-    $('input[name="disks"]', templateEditForm).keyup(function() {
-        templateDiskSize = $('input[name="disks"]', templateEditForm).val();
-    });
+        };
+        var initInterface = function(result) {
+            var addInterfaceItem = function(networkData) {
+                var nodeInterface = $.parseHTML(kimchi.substitute($('#template-interface-tmpl').html(), networkData));
+                $('.template-tab-body', '#form-template-interface').append(nodeInterface);
+                $('.edit', '#form-template-interface').button({
+                    icons : {primary : 'ui-icon-pencil'},
+                    text : false,
+                    disabled : true
+                });
+                $('.delete', '#form-template-interface').button({
+                    icons : {primary : 'ui-icon-trash'},
+                    text : false
+                }).click(function(evt) {
+                    evt.preventDefault();
+                    $(this).parent().parent().remove();
+                });
+                $('.cancel', '#form-template-interface').button({
+                    icons : {primary : 'ui-icon-arrowreturnthick-1-w'},
+                    text : false
+                }).click(function(evt) {
+                    evt.preventDefault();
+                    $(this).parent().parent().remove();
+                });
+                $('.save', '#form-template-interface').button({
+                    icons : {primary : 'ui-icon-disk'},
+                    text : false
+                }).click(function(evt) {
+                    evt.preventDefault();
+                    var interItem = $(this).parent().parent();
+                    $('.save', interItem).parent().hide();
+                    $('.delete', interItem).parent().show();
+                    var selectedInterface = $('select', interItem).val();
+                    $('.template-interface-name', interItem).val(selectedInterface).show();
+                    $('select', interItem).hide();
+                });
+                var networkOptions = '';
+                for(var i=0;i&lt;result.length;i++){
+                    if(result[i].state === "active") {
+                        var isSlected = i==0 ? ' selected' : '';
+                        networkOptions += '&lt;option' + isSlected + '&gt;' + result[i].name + '&lt;/option&gt;';
+                    }
+                }
+                $('select', '#form-template-interface').find('option').remove();
+                $('select', '#form-template-interface').append(networkOptions);
+            };
+            if(result &amp;&amp; result.length &gt; 0) {
+                $.each(result, function(index, data) {
+                    if($.inArray(data.name, origNetworks) &gt; -1) {
+                        addInterfaceItem({
+                            mac : '',
+                            network : data.name,
+                            type : 'network',
+                            viewMode : '',
+                            editMode : 'hide'
+                        });
+                    }
+                });
+            }
+            $('#template-edit-interface-add-button').button({
+                icons: {
+                    primary: 'ui-icon-plusthick'
+                },
+                text: false
+            }).click(function(evt) {
+                evt.preventDefault();
+                addInterfaceItem({
+                    mac : '',
+                    network : '',
+                    type : 'network',
+                    viewMode : 'hide',
+                    editMode : ''
+                });
+            });
+        };
+        kimchi.listNetworks(initInterface);
+        kimchi.listStoragePools(initStorage);
+    };
+    kimchi.retrieveTemplate(kimchi.selectedTemplate, initTemplate);
+

     $('#tmpl-edit-button-save').on('click', function() {
-        var editableFields = [ 'name', 'cpus', 'memory', 'storagepool', 'disks', 'graphics'];
+        var editableFields = [ 'name', 'cpus', 'memory', 'disks', 'graphics'];
         var data = {};
+        //Fix me: Only support one storage pool now
+        var storages = $('.template-tab-body .item', '#form-template-storage');
+        var tempName = $('.template-storage-name', storages).val();
+        tempName = tempName.split('/');
+        var tempNameHead =tempName[0];
+        var tempNameTail = tempNameHead;
+        if(tempNameHead === 'iscsi' || tempNameHead =='scsi') {
+            tempNameTail = tempName[tempName.length-1];
+        }
+        tempName = '/storagepools/' + tempNameHead;
+        data['storagepool'] = tempName;
         $.each(editableFields, function(i, field) {
             /* Support only 1 disk at this moment */
             if (field == 'disks') {
-               origDisks[0].size = Number($('#form-template-edit [name="' + field + '"]').val());
+                var tmpItem = $('#form-template-storage .item');
+                origDisks[0].size = Number($('.template-storage-disk', tmpItem).val());
+                if($('.template-storage-type', tmpItem).val() === 'iscsi' || $('.template-storage-type', tmpItem).val() =='scsi') {
+                    origDisks[0]['volume'] = tempNameTail;
+                } else {
+                    origDisks[0]['volume'] &amp;&amp; delete origDisks[0]['volume'];
+                }
                data[field] = origDisks;
             }
             else if (field == 'graphics') {
-               var type = $('#form-template-edit [name="' + field + '"]').val();
+               var type = $('#form-template-general [name="' + field + '"]').val();
                data[field] = {'type': type};
             }
             else {
-               data[field] = $('#form-template-edit [name="' + field + '"]').val();
+               data[field] = $('#form-template-general [name="' + field + '"]').val();
             }
         });
         data['memory'] = Number(data['memory']);
         data['cpus']   = Number(data['cpus']);
-        storagepool = data['storagepool'];
-        storageArray = storagepool.split("/");
-        if (storageArray.length &gt; 3){
-            /* Support only 1 disk at this moment */
-            data["disks"][0].volume = storageArray.pop();
-            data['storagepool'] = storageArray.join("/");
-        } else if (data["disks"][0].volume) {
-            delete data["disks"][0].volume;
-        }
-        var networks = templateEditForm.serializeObject().networks;
-        if (networks instanceof Array) {
-            data.networks = networks;
-        } else if (networks != null) {
-            data.networks = [networks];
+        var networks = $('.template-tab-body .item', '#form-template-interface');
+        var networkForUpdate = new Array();
+        $.each(networks, function(index, networkEntities) {
+            networkForUpdate.push($('.template-interface-name', networkEntities).val());
+        });
+        if (networkForUpdate instanceof Array) {
+            data.networks = networkForUpdate;
+        } else if (networkForUpdate != null) {
+            data.networks = [networkForUpdate];
         } else {
             data.networks = [];
         }
diff --git a/ui/pages/template-edit.html.tmpl b/ui/pages/template-edit.html.tmpl
index 5a71d91..018ac10 100644
--- a/ui/pages/template-edit.html.tmpl
+++ b/ui/pages/template-edit.html.tmpl
@@ -28,74 +28,67 @@
         &lt;div class="close"&gt;X&lt;/div&gt;
     &lt;/header&gt;
     &lt;div class="content"&gt;
-        &lt;form id="form-template-edit"&gt;
+        &lt;div id="edit-template-tabs"&gt;
             &lt;input type="hidden" id="template-name" name="templateName" /&gt;
-            &lt;fieldset class="template-edit-fieldset"&gt;
-                &lt;div&gt;
+            &lt;ul&gt;
+                &lt;li&gt;
+                    &lt;a href="#form-template-general"&gt;$_("General")&lt;/a&gt;
+                &lt;/li&gt;
+                &lt;li&gt;
+                    &lt;a href="#form-template-storage"&gt;$_("Storage")&lt;/a&gt;
+                &lt;/li&gt;
+                &lt;li&gt;
+                    &lt;a href="#form-template-interface"&gt;$_("Interface")&lt;/a&gt;
+                &lt;/li&gt;
+            &lt;/ul&gt;
+            &lt;form id="form-template-general"&gt;
+                &lt;div class="form-template-inline-wrapper"&gt;
                     &lt;div class="template-edit-wrapper-label"&gt;
                         &lt;label for="template-edit-id-textbox"&gt;$_("Name")&lt;/label&gt;
                     &lt;/div&gt;
-                    &lt;div class="template-edit-wrapper-controls"&gt;
-                        &lt;input id="template-edit-id-textbox" name="name" type="text" /&gt;
-                    &lt;/div&gt;
-                &lt;/div&gt;
-                &lt;div&gt;
                     &lt;div class="template-edit-wrapper-label"&gt;
                         &lt;label for="template-edit-vendor-textbox"&gt;$_("Vendor")&lt;/label&gt;
                     &lt;/div&gt;
-                    &lt;div class="template-edit-wrapper-controls"&gt;
-                        &lt;input id="template-edit-vendor-textbox" name="os_distro" type="text" disabled="disabled" /&gt;
-                    &lt;/div&gt;
-                &lt;/div&gt;
-                &lt;div&gt;
                     &lt;div class="template-edit-wrapper-label"&gt;
                         &lt;label for="template-edit-version-textbox"&gt;$_("Version")&lt;/label&gt;
                     &lt;/div&gt;
-                    &lt;div class="template-edit-wrapper-controls"&gt;
-                        &lt;input id="template-edit-version-textbox" name="os_version" type="text" disabled="disabled" /&gt;
-                    &lt;/div&gt;
-                &lt;/div&gt;
-                &lt;div&gt;
                     &lt;div class="template-edit-wrapper-label"&gt;
                         &lt;label for="template-edit-cpu-textbox"&gt;$_("CPU Number")&lt;/label&gt;
                     &lt;/div&gt;
-                    &lt;div class="template-edit-wrapper-controls"&gt;
-                        &lt;input id="template-edit-cpu-textbox" name="cpus" type="text" /&gt;
-                    &lt;/div&gt;
-                &lt;/div&gt;
-                &lt;div&gt;
                     &lt;div class="template-edit-wrapper-label"&gt;
                         &lt;label for="template-edit-memory-textbox"&gt;$_("Memory (MB)")&lt;/label&gt;
                     &lt;/div&gt;
-                    &lt;div class="template-edit-wrapper-controls"&gt;
-                        &lt;input id="template-edit-memory-textbox" name="memory" type="text" /&gt;
+                    &lt;div class="template-edit-wrapper-label templ-edit-cdrom"&gt;
+                        &lt;label for="template-edit-cdrom-textbox"&gt;$_("CDROM")&lt;/label&gt;
+                    &lt;/div&gt;
+                    &lt;div class="template-edit-wrapper-label templ-edit-vm-image hide"&gt;
+                        &lt;label for="template-edit-vmimage-textbox"&gt;$_("Image File")&lt;/label&gt;
                     &lt;/div&gt;
-                &lt;/div&gt;
-                &lt;div&gt;
                     &lt;div class="template-edit-wrapper-label"&gt;
-                        &lt;label for="template-edit-disk-textbox"&gt;$_("Disk (GB)")&lt;/label&gt;
+                        &lt;label&gt;$_("Graphics")&lt;/label&gt;
                     &lt;/div&gt;
+                &lt;/div&gt;
+                &lt;div class="form-template-inline-wrapper"&gt;
                     &lt;div class="template-edit-wrapper-controls"&gt;
-                        &lt;input id="template-edit-disk-textbox" name="disks" type="text" /&gt;
+                        &lt;input id="template-edit-id-textbox" name="name" type="text" /&gt;
                     &lt;/div&gt;
-                &lt;/div&gt;
-            &lt;/fieldset&gt;
-            &lt;fieldset class="template-edit-fieldset"&gt;
-                &lt;div id="templ-edit-cdrom"&gt;
-                    &lt;div class="template-edit-wrapper-label"&gt;
-                        &lt;label for="template-edit-cdrom-textbox"&gt;$_("CDROM")&lt;/label&gt;
+                    &lt;div class="template-edit-wrapper-controls"&gt;
+                        &lt;input id="template-edit-vendor-textbox" name="os_distro" type="text" disabled="disabled" /&gt;
                     &lt;/div&gt;
                     &lt;div class="template-edit-wrapper-controls"&gt;
-                        &lt;input id="template-edit-cdrom-textbox" name="cdrom" type="text" disabled="disabled"/&gt;
+                        &lt;input id="template-edit-version-textbox" name="os_version" type="text" disabled="disabled" /&gt;
                     &lt;/div&gt;
-                &lt;/div&gt;
-                &lt;div id="templ-edit-vm-image" class="hide-content"&gt;
-                    &lt;div class="template-edit-wrapper-label"&gt;$_("Image File")&lt;/div&gt;
-                    &lt;div class="template-edit-wrapper-controls"&gt;&lt;input name="vm-image" type="text" disabled/&gt;&lt;/div&gt;
-                &lt;/div&gt;
-                &lt;div&gt;
-                    &lt;div class="template-edit-wrapper-label"&gt;
-                        &lt;label&gt;$_("Graphics")&lt;/label&gt;
+                    &lt;div class="template-edit-wrapper-controls"&gt;
+                        &lt;input id="template-edit-cpu-textbox" name="cpus" type="text" /&gt;
+                    &lt;/div&gt;
+                    &lt;div class="template-edit-wrapper-controls"&gt;
+                        &lt;input id="template-edit-memory-textbox" name="memory" type="text" /&gt;
+                    &lt;/div&gt;
+                    &lt;div class="template-edit-wrapper-controls templ-edit-cdrom"&gt;
+                        &lt;input id="template-edit-cdrom-textbox" name="cdrom" type="text" disabled="disabled" /&gt;
+                    &lt;/div&gt;
+                    &lt;div class="template-edit-wrapper-controls templ-edit-vm-image hide"&gt;
+                        &lt;input id="template-edit-vmimage-textbox" name="vm-image" type="text" disabled="disabled" /&gt;
                     &lt;/div&gt;
                     &lt;div class="template-edit-wrapper-controls"&gt;
                         &lt;div class="btn dropdown popable"&gt;
@@ -108,40 +101,26 @@
                         &lt;/div&gt;
                     &lt;/div&gt;
                 &lt;/div&gt;
-                &lt;div&gt;
-                    &lt;div class="template-edit-wrapper-label"&gt;
-                        &lt;label&gt;$_("Storage Pool")&lt;/label&gt;
-                    &lt;/div&gt;
-                    &lt;div class="template-edit-wrapper-controls"&gt;
-                        &lt;div class="btn dropdown popable"&gt;
-                            &lt;input id="template-edit-storagePool" name="storagepool" type="hidden" /&gt;
-                            &lt;span class="text" id="template-edit-storage-label"&gt;&lt;/span&gt;&lt;span class="arrow"&gt;&lt;/span&gt;
-                            &lt;div class="popover" style="width: 100%"&gt;
-                                &lt;ul class="select-list" id="template-edit-storagePool-list" data-target="template-edit-storagePool" data-label="template-edit-storage-label"&gt;
-                                &lt;/ul&gt;
-                            &lt;/div&gt;
-                        &lt;/div&gt;
-                    &lt;/div&gt;
+            &lt;/form&gt;
+            &lt;form id="form-template-storage"&gt;
+                &lt;div class="template-tab-header"&gt;
+                    &lt;span class="template-storage-cell"&gt;$_("Storage Pool")&lt;/span&gt;
+                    &lt;span class="template-storage-cell"&gt;$_("Type")&lt;/span&gt;
+                    &lt;span class="template-storage-cell"&gt;$_("Disk(GB)")&lt;/span&gt;
+                    &lt;button type="button" id="template-edit-storage-add-button" class="action-area"&gt;&lt;/button&gt;
                 &lt;/div&gt;
-                &lt;div&gt;
-                    &lt;div class="template-edit-wrapper-label"&gt;
-                        &lt;label&gt;$_("Network")&lt;/label&gt;
-                    &lt;/div&gt;
-                    &lt;div class="template-edit-wrapper-controls"&gt;
-                        &lt;ul class="select-list-box" id="template-edit-network-list"&gt;
-                        &lt;/ul&gt;
-                        &lt;script id="tmpl-network" type="text/html"&gt;
-                            &lt;li&gt;
-                                &lt;label&gt;
-                                    &lt;input name="networks" type="checkbox" value="{name}" /&gt;
-                                    &lt;span class="item"&gt;{name}&lt;/span&gt;
-                                &lt;/label&gt;
-                            &lt;/li&gt;
-                        &lt;/script&gt;
-                    &lt;/div&gt;
+                &lt;div class="template-tab-body"&gt;
                 &lt;/div&gt;
-            &lt;/fieldset&gt;
-        &lt;/form&gt;
+            &lt;/form&gt;
+            &lt;form id="form-template-interface"&gt;
+                &lt;div class="template-tab-header"&gt;
+                    &lt;span class="template-interface-cell"&gt;$_("Network")&lt;/span&gt;
+                    &lt;span class="template-interface-cell"&gt;$_("Type")&lt;/span&gt;
+                    &lt;button type="button" id="template-edit-interface-add-button" class="action-area"&gt;&lt;/button&gt;
+                &lt;/div&gt;
+                &lt;div class="template-tab-body"&gt;&lt;/div&gt;
+            &lt;/form&gt;
+        &lt;/div&gt;
     &lt;/div&gt;
     &lt;footer&gt;
         &lt;div class="btn-group"&gt;
@@ -152,3 +131,40 @@
 &lt;script&gt;
     kimchi.template_edit_main();
 &lt;/script&gt;
+&lt;script id="template-storage-pool-tmpl" type="text/html"&gt;
+    &lt;div class='item'&gt;
+        &lt;span class="template-storage-cell"&gt;
+            &lt;input class="template-storage-name {viewMode}" value={storageName} readonly=true type="text"/&gt;
+            &lt;select class="{editMode}"&gt;&lt;/select&gt;
+        &lt;/span&gt;
+        &lt;span class="template-storage-cell"&gt;
+            &lt;input class="template-storage-type" value={storageType} readonly=true type="text" /&gt;
+        &lt;/span&gt;
+        &lt;span class="template-storage-cell"&gt;
+            &lt;input class="template-storage-disk" value={storageDisk} type="text" /&gt;
+        &lt;/span&gt;
+        &lt;span class="action-area {editMode}"&gt;
+            &lt;button class="save"&gt;&lt;/button&gt;&lt;button class="cancel"&gt;&lt;/button&gt;
+        &lt;/span&gt;
+        &lt;span class="action-area {viewMode}"&gt;
+            &lt;button class="edit"&gt;&lt;/button&gt;&lt;button class="delete"&gt;&lt;/button&gt;
+        &lt;/span&gt;
+    &lt;/div&gt;
+&lt;/script&gt;
+&lt;script id="template-interface-tmpl" type="text/html"&gt;
+    &lt;div class="item"&gt;
+        &lt;span class="template-interface-cell"&gt;
+            &lt;input class="template-interface-name {viewMode}" readonly="true" type="text"  value={network} /&gt;
+            &lt;select class="{editMode}"&gt;&lt;/select&gt;
+        &lt;/span&gt;
+        &lt;span class="template-interface-cell"&gt;
+            &lt;input value={type} readonly=true type="text" /&gt;
+        &lt;/span&gt;
+        &lt;span class="action-area {editMode}"&gt;
+            &lt;button class="save"&gt;&lt;/button&gt;&lt;button class="cancel"&gt;&lt;/button&gt;
+        &lt;/span&gt;
+        &lt;span class="action-area {viewMode}"&gt;
+            &lt;button class="edit"&gt;&lt;/button&gt;&lt;button class="delete"&gt;&lt;/button&gt;
+        &lt;/span&gt;
+    &lt;/div&gt;
+&lt;/script&gt;
\ No newline at end of file
</pre>
    </blockquote>
    <br>
  </body>
</html>