diff --git a/ui/scripts/network.js b/ui/scripts/network.js index 53b78a651e8..8f548cdc89e 100755 --- a/ui/scripts/network.js +++ b/ui/scripts/network.js @@ -542,6 +542,48 @@ }, networkDomain: { label: 'label.network.domain' + }, + domain: { + label: 'label.domain', + select: function(args) { + var items = []; + $.ajax({ + url: createURL("listDomains&listAll=true"), + dataType: "json", + async: false, + success: function(json) { + var items = []; + items.push({ + id: "", + description: "" + }); + var domainObjs = json.listdomainsresponse.domain; + $(domainObjs).each(function() { + items.push({ + id: this.id, + description: this.path + }); + }); + args.response.success({ + data: items + }); + } + }); + args.$select.change(function() { + var $form = $(this).closest('form'); + if ($(this).val() == "") { + $form.find('.form-item[rel=account]').hide(); + } else { + $form.find('.form-item[rel=account]').css('display', 'inline-block'); + } + }); + }, + }, + account: { + label: 'label.account', + validation: { + required: true + }, } } }, @@ -581,6 +623,19 @@ }); } + if (args.$form.find('.form-item[rel=domain]').css("display") != "none") { + if (args.data.domain != null && args.data.domain.length > 0) { + $.extend(dataObj, { + domainid: args.data.domain + }); + } + if (args.data.account != null && args.data.account.length > 0) { + $.extend(dataObj, { + account: args.data.account + }); + } + } + $.ajax({ url: createURL('createNetwork'), data: dataObj,