Repository: cloudstack
Updated Branches:
  refs/heads/saml-dialog-fix [created] 22f877ff1


CLOUDSTACK-8457: SAML UI Dialog fixes to use local $form

This uses local selector to access the DOM elements, the previous commit
would find a global element which is not in the context and fail changing the
element in the opened dialog.

Signed-off-by: Rohit Yadav <rohit.ya...@shapeblue.com>


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

Branch: refs/heads/saml-dialog-fix
Commit: 22f877ff15897acdb95c569726af573b28d88dc1
Parents: 7d11c7b
Author: Rohit Yadav <rohit.ya...@shapeblue.com>
Authored: Tue Jul 14 11:31:27 2015 +0530
Committer: Rohit Yadav <rohit.ya...@shapeblue.com>
Committed: Tue Jul 14 11:33:15 2015 +0530

----------------------------------------------------------------------
 ui/scripts/accounts.js                 |  8 ++++----
 ui/scripts/accountsWizard.js           | 27 ---------------------------
 ui/scripts/ui-custom/accountsWizard.js | 29 +++++++++++++++++++++++++++++
 3 files changed, 33 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/22f877ff/ui/scripts/accounts.js
----------------------------------------------------------------------
diff --git a/ui/scripts/accounts.js b/ui/scripts/accounts.js
index 365528c..7db28b3 100644
--- a/ui/scripts/accounts.js
+++ b/ui/scripts/accounts.js
@@ -1099,21 +1099,21 @@
                                         },
                                         select: function(args) {
                                             var samlChecked = false;
-                                            var idpUrl = "";
+                                            var idpUrl = 
args.$form.find('select[name=samlEntity]').children(':selected').val();
                                             var appendDomainToUsername = 
function() {
                                                 if (!g_appendIdpDomain) {
                                                     return;
                                                 }
-                                                var username = 
$('input[name=username]').val();
+                                                var username = 
args.$form.find('input[name=username]').val();
                                                 if (username) {
                                                     username = 
username.split('@')[0];
                                                 }
                                                 if (samlChecked) {
                                                     var link = 
document.createElement('a');
                                                     link.setAttribute('href', 
idpUrl);
-                                                    
$('input[name=username]').val(username + "@" + 
link.host.split('.').splice(-2).join('.'));
+                                                    
args.$form.find('input[name=username]').val(username + "@" + 
link.host.split('.').splice(-2).join('.'));
                                                 } else {
-                                                    
$('input[name=username]').val(username);
+                                                    
args.$form.find('input[name=username]').val(username);
                                                 }
                                             };
                                             
args.$form.find('select[name=samlEntity]').change(function() {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/22f877ff/ui/scripts/accountsWizard.js
----------------------------------------------------------------------
diff --git a/ui/scripts/accountsWizard.js b/ui/scripts/accountsWizard.js
index 3efe6f9..03dc65c 100644
--- a/ui/scripts/accountsWizard.js
+++ b/ui/scripts/accountsWizard.js
@@ -179,33 +179,6 @@
                     required: false
                 },
                 select: function(args) {
-                    var samlChecked = false;
-                    var idpUrl = "";
-                    var appendDomainToUsername = function() {
-                        if (!g_appendIdpDomain) {
-                            return;
-                        }
-                        var username = $('input[name=username]').val();
-                        if (username) {
-                            username = username.split('@')[0];
-                        }
-                        if (samlChecked) {
-                            var link = document.createElement('a');
-                            link.setAttribute('href', idpUrl);
-                            $('input[name=username]').val(username + "@" + 
link.host.split('.').splice(-2).join('.'));
-                        } else {
-                            $('input[name=username]').val(username);
-                        }
-                    };
-                    
args.$form.find('select[name=samlEntity]').change(function() {
-                        idpUrl = $(this).children(':selected').val();
-                        appendDomainToUsername();
-                    });
-                    
args.$form.find('input[name=samlEnable]').change(function() {
-                        samlChecked = $(this).context.checked;
-                        appendDomainToUsername();
-                    });
-
                     var items = [];
                     $(g_idpList).each(function() {
                         items.push({

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/22f877ff/ui/scripts/ui-custom/accountsWizard.js
----------------------------------------------------------------------
diff --git a/ui/scripts/ui-custom/accountsWizard.js 
b/ui/scripts/ui-custom/accountsWizard.js
index cfbe930..0d416e1 100644
--- a/ui/scripts/ui-custom/accountsWizard.js
+++ b/ui/scripts/ui-custom/accountsWizard.js
@@ -293,6 +293,35 @@
                 }
                 
$wizard.find('.manual-account-details').append(informationNotInLdapForm);
 
+                if (g_idpList && g_appendIdpDomain && !ldapStatus) {
+                    var samlChecked = false;
+                    var idpUrl = 
$wizard.find('select[name=samlEntity]').children(':selected').val();
+                    var appendDomainToUsername = function() {
+                        if (!g_appendIdpDomain) {
+                            return;
+                        }
+                        var username = 
$wizard.find('input[name=username]').val();
+                        if (username) {
+                            username = username.split('@')[0];
+                        }
+                        if (samlChecked) {
+                            var link = document.createElement('a');
+                            link.setAttribute('href', idpUrl);
+                            $wizard.find('input[name=username]').val(username 
+ "@" + link.host.split('.').splice(-2).join('.'));
+                        } else {
+                            $wizard.find('input[name=username]').val(username);
+                        }
+                    };
+                    $wizard.find('select[name=samlEntity]').change(function() {
+                        idpUrl = $(this).children(':selected').val();
+                        appendDomainToUsername();
+                    });
+                    $wizard.find('input[name=samlEnable]').change(function() {
+                        samlChecked = $(this).context.checked;
+                        appendDomainToUsername();
+                    });
+                }
+
                 return $wizard.dialog({
                     title: ldapStatus ? _l('Add LDAP Account') : 
_l('label.add.account'),
                     width: ldapStatus ? 800 : 330,

Reply via email to