From f7667e8a885246eb71b1722b0189ef06338075a4 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Thu, 4 Oct 2012 11:57:18 -0700 Subject: [PATCH] cloudstack UI - dialog widget - (1) extend field's isHidden property to have function type other than boolean type. (2) do not call field's select function if field's isHidden property is false. --- ui/scripts/instances.js | 38 +++++++++++++++++++++++++++++++++++++- ui/scripts/ui/dialog.js | 32 +++++++++++++++++++------------- 2 files changed, 56 insertions(+), 14 deletions(-) diff --git a/ui/scripts/instances.js b/ui/scripts/instances.js index 725c1b33a4a..d0675acf6ba 100644 --- a/ui/scripts/instances.js +++ b/ui/scripts/instances.js @@ -81,7 +81,43 @@ } }); } - }, + }, + + domainid: { + label: 'Domain', + select: function(args) { + $.ajax({ + url: createURL('listDomains'), + data: { listAll: true }, + success: function(json) { + args.response.success({ + data: $.map(json.listdomainsresponse.domain, function(domain) { + return { + id: domain.id, + description: domain.path + }; + }) + }); + } + }); + }, + isHidden: function(args) { + if(isAdmin() || isDomainAdmin()) + return false; + else + return true; + } + }, + account: { + label: 'Account', + isHidden: function(args) { + if(isAdmin() || isDomainAdmin()) + return false; + else + return true; + } + }, + tagKey: { label: 'Tag Key' }, tagValue: { label: 'Tag Value' } }, diff --git a/ui/scripts/ui/dialog.js b/ui/scripts/ui/dialog.js index 2d22637f6d5..0aa2ac5b458 100644 --- a/ui/scripts/ui/dialog.js +++ b/ui/scripts/ui/dialog.js @@ -65,9 +65,14 @@ var $formItem = $('
') .addClass('form-item') .attr({ rel: key }); - - if (field.hidden || field.isHidden) $formItem.hide(); - + + if(field.isHidden != null) { + if (typeof(field.isHidden) == 'boolean' && field.isHidden == true) + $formItem.hide(); + else if (typeof(field.isHidden) == 'function' && field.isHidden() == true) + $formItem.hide(); + } + $formItem.appendTo($form); //Handling Escape KeyPress events @@ -91,10 +96,7 @@ closeOnEscape: false }); */ // Label field - - //if( field.label == 'label.network.offering' || field.label == 'label.guest.gateway') - // debugger; - + var $name = $('
').addClass('name') .appendTo($formItem) .append( @@ -198,9 +200,9 @@ selectFn = field.select; $input = $('