You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bf...@apache.org on 2013/01/14 21:07:32 UTC

[2/4] git commit: UI multi view all: Support updateContext and preFilter

UI multi view all: Support updateContext and preFilter

-If preFilter is specified for a viewAll item in an array,
 show/hide view all button based on if it returns true/false

-If updateContext is specified, add returned object to the
 proceeding list view's context.


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

Branch: refs/heads/ui-quick-view-v2
Commit: a756f7da89e95d88b197ac24ce01e01529668c27
Parents: 49849a8
Author: Brian Federle <br...@citrix.com>
Authored: Mon Jan 14 11:45:00 2013 -0800
Committer: Brian Federle <br...@citrix.com>
Committed: Mon Jan 14 11:45:10 2013 -0800

----------------------------------------------------------------------
 ui/scripts/ui/widgets/detailView.js |   23 +++++++++++++++++++----
 1 files changed, 19 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a756f7da/ui/scripts/ui/widgets/detailView.js
----------------------------------------------------------------------
diff --git a/ui/scripts/ui/widgets/detailView.js b/ui/scripts/ui/widgets/detailView.js
index a712267..f0cc8fd 100644
--- a/ui/scripts/ui/widgets/detailView.js
+++ b/ui/scripts/ui/widgets/detailView.js
@@ -578,7 +578,7 @@
     }
   };
 
-  var viewAll = function(viewAllID) {
+  var viewAll = function(viewAllID, options) {
     var $detailView = $('div.detail-view:last');
     var args = $detailView.data('view-args');
     var cloudStackArgs = $('[cloudstack-container]').data('cloudStack-args');
@@ -586,6 +586,7 @@
     var listViewArgs, viewAllPath;
     var $listView;
     var isCustom = $.isFunction(viewAllID.custom);
+    var updateContext = options.updateContext;
 
     if (isCustom) {
       $browser.cloudBrowser('addPanel', {
@@ -637,6 +638,10 @@
     // Load context data
     var context = $.extend(true, {}, $detailView.data('view-args').context);
 
+    if (updateContext) {
+      $.extend(context, updateContext({ context: context }));
+    }
+
     // Make panel
     var $panel = $browser.cloudBrowser('addPanel', {
       title: _l(listViewArgs.title),
@@ -915,6 +920,11 @@
           $(detailViewArgs.viewAll).each(function() {
             var viewAllItem = this;
 
+            if (viewAllItem.preFilter &&
+                !viewAllItem.preFilter({ context: context })) {
+              return true;
+            }
+
             $('<div>')
               .addClass('view-all')
               .append(
@@ -1199,12 +1209,17 @@
   $('a').live('click', function(event) {
     var $target = $(event.target);
     var $viewAll = $target.closest('td.view-all a');
+    var viewAllArgs;
 
     if ($target.closest('div.detail-view').size() && $target.closest('td.view-all a').size()) {
+      viewAllArgs = $viewAll.data('detail-view-link-view-all');
       viewAll(
-        $viewAll.data('detail-view-link-view-all').custom ?
-          $viewAll.data('detail-view-link-view-all') :
-          $viewAll.data('detail-view-link-view-all').path
+        viewAllArgs.custom ?
+          viewAllArgs :
+          viewAllArgs.path,
+        {
+          updateContext: viewAllArgs.updateContext
+        }
       );
       return false;
     }