You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ol...@apache.org on 2012/07/25 10:13:19 UTC

git commit: CS-15533: Add instance/Review tab fix empty value.

Updated Branches:
  refs/heads/master 71fddd095 -> dc19c86fd


CS-15533: Add instance/Review tab fix empty value.


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/dc19c86f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/dc19c86f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/dc19c86f

Branch: refs/heads/master
Commit: dc19c86fded660ccc4d89ca54e33b4633c07fb7a
Parents: 71fddd0
Author: olgasmola <ol...@gmail.com>
Authored: Thu Jul 12 13:56:49 2012 +0300
Committer: olgasmola <ol...@gmail.com>
Committed: Wed Jul 25 10:42:43 2012 +0300

----------------------------------------------------------------------
 ui/index.jsp                           |   19 +++++-
 ui/scripts/ui-custom/instanceWizard.js |   93 ++++++++++++++++----------
 2 files changed, 73 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/dc19c86f/ui/index.jsp
----------------------------------------------------------------------
diff --git a/ui/index.jsp b/ui/index.jsp
index d942bb9..1ee8f0b 100644
--- a/ui/index.jsp
+++ b/ui/index.jsp
@@ -273,7 +273,7 @@
                                 </div>
 
                                 <div class="secondary-input hide-if-unselected">
-                                  <input type="radio" name="defaultNetwork" value="new-network" />
+                                  <input type="radio" name="defaultNetwork" value="new-network" wizard-field="default-network" />
                                   <div class="name"><fmt:message key="label.default"/></div>
                                 </div>
                               </div>
@@ -347,7 +347,7 @@
                       <span wizard-field="hypervisor"></span>
                     </div>
                     <div class="edit">
-                      <a href="1"><fmt:message key="label.edit"/></a>
+                      <a href="2"><fmt:message key="label.edit"/></a>
                     </div>
                   </div>
 
@@ -396,7 +396,20 @@
                       <span><fmt:message key="label.network"/></span>
                     </div>
                     <div class="value">
-                      <span wizard-field="default-network"></span>
+                      <span wizard-field="default-network" conditional-field="select-network"></span>
+                    </div>
+                    <div class="edit">
+                      <a href="5"><fmt:message key="label.edit"/></a>
+                    </div>
+                  </div>
+                  
+                  <!-- Security groups -->
+                  <div class="select odd">
+                    <div class="name">
+                      <span><fmt:message key="label.security.groups"/></span>
+                    </div>
+                    <div class="value">
+                      <span wizard-field="security-groups" conditional-field="select-security-group"></span>
                     </div>
                     <div class="edit">
                       <a href="5"><fmt:message key="label.edit"/></a>

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/dc19c86f/ui/scripts/ui-custom/instanceWizard.js
----------------------------------------------------------------------
diff --git a/ui/scripts/ui-custom/instanceWizard.js b/ui/scripts/ui-custom/instanceWizard.js
index 13719d4..b94e587 100644
--- a/ui/scripts/ui-custom/instanceWizard.js
+++ b/ui/scripts/ui-custom/instanceWizard.js
@@ -134,7 +134,8 @@
                 $('<input>')
                   .attr({
                     type: options.secondary.type,
-                    name: options.secondary.name
+                    name: options.secondary.name,
+                    'wizard-field': options.secondary['wizard-field']
                   })
                   .val(id)
                   .click(function() {
@@ -513,7 +514,8 @@
                       secondary: {
                         desc: 'Default',
                         name: 'defaultNetwork',
-                        type: 'radio'
+                        type: 'radio',
+                        'wizard-field': 'default-network'
                       }
                     })
                   );
@@ -525,7 +527,8 @@
                       desc: 'description',
                       id: 'id'
                     }, {
-                      type: 'checkbox'
+                      type: 'checkbox',
+                      'wizard-field': 'security-groups'
                     })
                   );
 
@@ -536,37 +539,55 @@
           },
 
           'review': function($step, formData) {
-            return {
-              response: {
-                success: function(args) {
-                  $step.find('[wizard-field]').each(function() {
-                    var field = $(this).attr('wizard-field');
-                    var fieldName;
-                    var $input = $wizard.find('[wizard-field=' + field + ']').filter(function() {
-                      return $(this).is(':selected') || $(this).is(':checked');
-                    });
+            $step.find('[wizard-field]').each(function() {
+              var field = $(this).attr('wizard-field');
+              var fieldName;
+              var $input = $wizard.find('[wizard-field=' + field + ']').filter(function() {
+                return $(this).is(':selected') || $(this).is(':checked');
+              });
 
-                    if ($input.is('option')) {
-                      fieldName = $input.html();
-                    } else if ($input.is('input[type=radio]')) {
-                      fieldName = $input.parent().find('.select-desc .name').html();
-                    }
+              if ($input.is('option')) {
+                fieldName = $input.html();
+              } else if ($input.is('input[type=radio]')) {
+                // Choosen New network as default
+                if ($input.parents('div.new-network').size()) {
+                  fieldName = $input.closest('div.new-network').find('input[name="new-network-name"]').val();
+                // Choosen Network from existed
+                } else if ($input.parents('div.my-networks').size()) {
+                  fieldName = $input.closest('div.select').find('.select-desc .name').html();
+                } else {
+                  fieldName = $input.parent().find('.select-desc .name').html();
+                }
+              } else if ($input.eq(0).is('input[type=checkbox]')) {
+                fieldName = '';
+                $input.each(function(index) {
+                  if (index != 0) fieldName += '<br />';
+                  fieldName += $(this).next('div.select-desc').find('.name').html();
+                });
+              }
 
-                    if (fieldName) {
-                      $(this).html(fieldName);
-                    } else {
-                      $(this).html('(' + _l('label.none') + ')');
-                    }
-                  });
+              if (fieldName) {
+                $(this).html(fieldName);
+              } else {
+                $(this).html('(' + _l('label.none') + ')');
+              }
+              
+              var conditionalFieldFrom = $(this).attr('conditional-field');
+              if (conditionalFieldFrom) {
+                if ($wizard.find('.'+conditionalFieldFrom).css('display') == 'block') {
+                    $(this).closest('div.select').show();
+                } else {
+                    $(this).closest('div.select').hide();
                 }
               }
-            };
+            });
           }
         };
 
         // Go to specified step in wizard,
         // updating nav items and diagram
-        var showStep = function(index) {
+        var showStep = function(index, options) {
+          if (!options) options = {};
           var targetIndex = index - 1;
 
           if (index <= 1) targetIndex = 0;
@@ -651,17 +672,17 @@
                 return false;
               }
             }
-						
-						//step 6 - review (spcifiy displyname, group as well)		
-						if ($activeStep.hasClass('review')) {						  
-						  if($activeStep.find('input[name=displayname]').size() > 0 && $activeStep.find('input[name=displayname]').val().length > 0) {
-							  //validate 
-								var b = cloudStack.validate.vmHostName($activeStep.find('input[name=displayname]').val());								
-								if(b == false)
-								  return false;
-							}
-            }						
-						
+
+            //step 6 - review (spcifiy displyname, group as well)
+            if ($activeStep.hasClass('review')) {
+              if($activeStep.find('input[name=displayname]').size() > 0 && $activeStep.find('input[name=displayname]').val().length > 0) {
+                  //validate 
+                  var b = cloudStack.validate.vmHostName($activeStep.find('input[name=displayname]').val());
+                  if(b == false)
+                    return false;
+                }
+            }
+
             if (!$form.valid()) {
               if ($form.find('input.error:visible, select.error:visible').size()) {
                 return false;