You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by is...@apache.org on 2013/06/05 14:18:19 UTC

git commit: updated refs/heads/master to 202da41

Updated Branches:
  refs/heads/master 5af702dd9 -> 202da411f


CLOUDSTACK-2855: UI - project view
1.Dynamically add newly created project to dropdown list
2.Return to default view if a user deletes the same project in project view

Modified:   ui/scripts/projects.js
Modified:   ui/scripts/ui-custom/projects.js


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

Branch: refs/heads/master
Commit: 202da411fadf3b54b1263d1087d4303a2b03bc65
Parents: 5af702d
Author: Isaac Chiang <is...@gmail.com>
Authored: Wed Jun 5 20:14:21 2013 +0800
Committer: Isaac Chiang <is...@gmail.com>
Committed: Wed Jun 5 20:14:21 2013 +0800

----------------------------------------------------------------------
 ui/scripts/projects.js           |    3 +++
 ui/scripts/ui-custom/projects.js |   25 +++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/202da411/ui/scripts/projects.js
----------------------------------------------------------------------
diff --git a/ui/scripts/projects.js b/ui/scripts/projects.js
index 4004709..ea1e6db 100644
--- a/ui/scripts/projects.js
+++ b/ui/scripts/projects.js
@@ -849,6 +849,9 @@
                           getUpdatedItem: function(data) {
                             return $.extend(data, { state: 'Destroyed' });
                           },
+                          onComplete: function(data) {
+                            $(window).trigger('cloudStack.deleteProject', args);
+                          },
                           getActionFilter: function(args) {
                             return function() {
                               return [];

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/202da411/ui/scripts/ui-custom/projects.js
----------------------------------------------------------------------
diff --git a/ui/scripts/ui-custom/projects.js b/ui/scripts/ui-custom/projects.js
index 82abadd..7824b3d 100644
--- a/ui/scripts/ui-custom/projects.js
+++ b/ui/scripts/ui-custom/projects.js
@@ -333,9 +333,15 @@
           response: {
             success: function(args) {
               var project = args.data;
+              var $projectSwitcher = $('div.project-switcher');
 
               $(window).trigger('cloudStack.fullRefresh');
 
+              // dynamically add newly created project into project switcher
+              $projectSwitcher.find('select').append(
+                $('<option>').val(project.id).html(project.name)
+              );
+
               $loading.remove();
 
               // Confirmation
@@ -681,6 +687,20 @@
     }).closest('.ui-dialog').overlay();
   };
 
+  var deleteProject = function(args) {
+    var projectId = args.id;
+    var $projectSwitcher = $('div.project-switcher');
+    var contextProjectId = cloudStack.context.projects ? cloudStack.context.projects[0].id : -1;
+
+    $projectSwitcher.find('option[value="'+projectId+'"]').remove();
+
+    //return to default view if current project is deleted
+    if(contextProjectId == projectId) {
+      $projectSwitcher.find('select').trigger('change');
+    }
+    return false;
+  };
+
   /**
    * Show the dashboard, in panel
    */
@@ -741,4 +761,9 @@
   $(window).bind('cloudStack.newProject', function() {
     addProject();
   });
+
+
+  $(window).bind('cloudStack.deleteProject', function(event, args) {
+    deleteProject({id: args.data.id});
+  });
 })(cloudStack, jQuery);