You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by je...@apache.org on 2012/10/04 21:12:44 UTC

git commit: 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.

Updated Branches:
  refs/heads/master 15f6fbbee -> f7667e8a8


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.


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

Branch: refs/heads/master
Commit: f7667e8a885246eb71b1722b0189ef06338075a4
Parents: 15f6fbb
Author: Jessica Wang <je...@citrix.com>
Authored: Thu Oct 4 11:57:18 2012 -0700
Committer: Jessica Wang <je...@citrix.com>
Committed: Thu Oct 4 12:12:19 2012 -0700

----------------------------------------------------------------------
 ui/scripts/instances.js |   38 +++++++++++++++++++++++++++++++++++++-
 ui/scripts/ui/dialog.js |   32 +++++++++++++++++++-------------
 2 files changed, 56 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f7667e8a/ui/scripts/instances.js
----------------------------------------------------------------------
diff --git a/ui/scripts/instances.js b/ui/scripts/instances.js
index 725c1b3..d0675ac 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' }						
 			},						

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f7667e8a/ui/scripts/ui/dialog.js
----------------------------------------------------------------------
diff --git a/ui/scripts/ui/dialog.js b/ui/scripts/ui/dialog.js
index 2d22637..0aa2ac5 100644
--- a/ui/scripts/ui/dialog.js
+++ b/ui/scripts/ui/dialog.js
@@ -65,9 +65,14 @@
         var $formItem = $('<div>')
               .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 = $('<div>').addClass('name')
               .appendTo($formItem)
               .append(
@@ -198,9 +200,9 @@
           selectFn = field.select;
           $input = $('<select>')
             .attr({ name: key })
-            .data('dialog-select-fn', function(args) {
-              selectFn(args ?
-                       $.extend(true, {}, selectArgs, args) : selectArgs);
+            .data('dialog-select-fn', function(args) {								
+              if((field.isHidden == null) || (typeof(field.isHidden) == 'boolean' && field.isHidden == false) || (typeof(field.isHidden) == 'function' && field.isHidden() == false)) 			
+                selectFn(args ? $.extend(true, {}, selectArgs, args) : selectArgs);
             })
             .appendTo($value);
 
@@ -224,16 +226,20 @@
               if (!$target.children().size()) return true;
 
               dependsOnArgs[dependsOn] = $target.val();
-              selectFn($.extend(selectArgs, dependsOnArgs));
+							
+							if((field.isHidden == null) || (typeof(field.isHidden) == 'boolean' && field.isHidden == false) || (typeof(field.isHidden) == 'function' && field.isHidden() == false)) 						
+                selectFn($.extend(selectArgs, dependsOnArgs));
 
               return true;
             });
 
             if (!$dependsOn.is('select')) {
-              selectFn(selectArgs);
+						  if((field.isHidden == null) || (typeof(field.isHidden) == 'boolean' && field.isHidden == false) || (typeof(field.isHidden) == 'function' && field.isHidden() == false)) 			
+                selectFn(selectArgs);
             }
           } else {
-            selectFn(selectArgs);
+					  if((field.isHidden == null) || (typeof(field.isHidden) == 'boolean' && field.isHidden == false) || (typeof(field.isHidden) == 'function' && field.isHidden() == false)) 			
+              selectFn(selectArgs);
           }
         } else if (field.isBoolean) {
           if (field.multiArray) {