Updated Branches:
  refs/heads/4.2-forward 5a11fe77b -> 5b93398c1

CLOUDSTACK-4508 (WIP): Conditionally make VSM fields required

If VSM is active, and either traffic overrides are checked, make VSM
fields required.

** This creates new VSM fields, with '_req' appended to end of ID. API
calls need to be changes to account for this.


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

Branch: refs/heads/4.2-forward
Commit: ef7dbf230a3036cc60b3f0f3d8fe24e03342ae16
Parents: 5a11fe7
Author: Brian Federle <[email protected]>
Authored: Mon Aug 26 11:53:04 2013 -0700
Committer: Jessica Wang <[email protected]>
Committed: Mon Aug 26 16:02:35 2013 -0700

----------------------------------------------------------------------
 ui/scripts/system.js | 69 ++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 66 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ef7dbf23/ui/scripts/system.js
----------------------------------------------------------------------
diff --git a/ui/scripts/system.js b/ui/scripts/system.js
index 7fe8882..e6bf03a 100644
--- a/ui/scripts/system.js
+++ b/ui/scripts/system.js
@@ -10284,6 +10284,47 @@
                             },
                             createForm: {
                                 title: 'label.add.cluster',
+                                preFilter: function(args) {
+                                    var $form = args.$form;
+                                    
+                                    $form.click(function() {
+                                        // VSM fields need to be required if a 
traffic override is selected
+                                        //
+                                        // ** This is done by switching out 
optional fields for required fields;
+                                        //    need to check for *either* 
vsm[...]_req or vsm[...]
+                                        var $overrideGuestTraffic = 
$form.find('.form-item[rel=overrideguesttraffic] input[type=checkbox]');
+                                        var $overridePublicTraffic = 
$form.find('.form-item[rel=overridepublictraffic] input[type=checkbox]');
+                                        var $vsmFields = 
$form.find('.form-item').filter(function() {
+                                            var vsmFields = [
+                                                'vsmipaddress',
+                                                'vsmusername',
+                                                'vsmpassword'
+                                            ];
+
+                                            return 
$.inArray($(this).attr('rel'), vsmFields) > -1;
+                                        });
+                                        var $vsmReqFields = 
$form.find('.form-item').filter(function() {
+                                            var vsmFields = [
+                                                'vsmipaddress_req',
+                                                'vsmusername_req',
+                                                'vsmpassword_req'
+                                            ];
+
+                                            return 
$.inArray($(this).attr('rel'), vsmFields) > -1;
+                                        });
+
+
+                                        if 
($overridePublicTraffic.is(':checked') ||
+                                            
$overrideGuestTraffic.is(':checked')) {
+                                            $vsmReqFields.css('display', 
'inline-block');
+                                            $vsmFields.hide();
+                                        } else {
+                                            $vsmFields.css('display', 
'inline-block');
+                                            $vsmReqFields.hide();
+                                        }
+
+                                    });
+                                },
                                 fields: {
                                     zoneid: {
                                         label: 'Zone Name',
@@ -10722,14 +10763,28 @@
                                         validation: {
                                             required: false
                                         },
-                                        isHidden: false
+                                        isHidden: true
+                                    },
+                                    vsmipaddress_req: {
+                                        label: 'Nexus 1000v IP Address',
+                                        validation: {
+                                            required: true
+                                        },
+                                        isHidden: true
                                     },
                                     vsmusername: {
                                         label: 'Nexus 1000v Username',
                                         validation: {
                                             required: false
                                         },
-                                        isHidden: false
+                                        isHidden: true
+                                    },
+                                    vsmusername_req: {
+                                        label: 'Nexus 1000v Username',
+                                        validation: {
+                                            required: true
+                                        },
+                                        isHidden: true
                                     },
                                     vsmpassword: {
                                         label: 'Nexus 1000v Password',
@@ -10737,7 +10792,15 @@
                                             required: false
                                         },
                                         isPassword: true,
-                                        isHidden: false
+                                        isHidden: true
+                                    },
+                                    vsmpassword_req: {
+                                        label: 'Nexus 1000v Password',
+                                        validation: {
+                                            required: true
+                                        },
+                                        isPassword: true,
+                                        isHidden: true
                                     }
                                     //hypervisor==VMWare ends here
                                 }

Reply via email to