KYLIN-2641 - The current selected project is incorrect after we delete a 
project.

Signed-off-by: Billy Liu <billy...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/9fef04d9
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/9fef04d9
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/9fef04d9

Branch: refs/heads/KYLIN-2606
Commit: 9fef04d9a98e11454d00247d8cd2f4d501ba66a2
Parents: 81ed301
Author: 10069681 <peng.jian...@zte.com.cn>
Authored: Tue May 23 18:34:26 2017 +0800
Committer: Billy Liu <billy...@apache.org>
Committed: Tue May 23 20:02:21 2017 +0800

----------------------------------------------------------------------
 webapp/app/js/model/projectModel.js | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/9fef04d9/webapp/app/js/model/projectModel.js
----------------------------------------------------------------------
diff --git a/webapp/app/js/model/projectModel.js 
b/webapp/app/js/model/projectModel.js
index d2d32b4..77f47e8 100644
--- a/webapp/app/js/model/projectModel.js
+++ b/webapp/app/js/model/projectModel.js
@@ -21,7 +21,6 @@ KylinApp.service('ProjectModel', function () {
   this.projects = [];
   this.selectedProject = "_null";
 
-
   this.setSelectedProject = function (project) {
     var _projects =[];
     angular.forEach(this.projects,function(pro){
@@ -31,6 +30,7 @@ KylinApp.service('ProjectModel', function () {
       this.selectedProject = project;
     }
   };
+
   this.getSelectedProject = function (project) {
     if (this.selectedProject == "_null") {
       return null;
@@ -56,10 +56,10 @@ KylinApp.service('ProjectModel', function () {
     this.sortProjects();
   }
 
-  this.removeProject = function (project) {
+  this.removeProject = function (projectName) {
     var index = -1;
     for (var i = 0; i < this.projects.length; i++) {
-      if (this.projects[i].name == project) {
+      if (this.projects[i].name == projectName) {
         index = i;
         break;
       }
@@ -67,7 +67,15 @@ KylinApp.service('ProjectModel', function () {
     if (index > -1) {
       this.projects.splice(index, 1);
     }
-    this.selectedProject = this.projects[0];
+
+    if (this.selectedProject == projectName) {
+        if (this.projects.length) {
+               this.selectedProject = this.projects[0].name;
+        } else {
+               this.selectedProject = "_null";
+        }
+    }
+
     this.sortProjects();
   }
 
@@ -96,7 +104,6 @@ KylinApp.service('ProjectModel', function () {
         }
       }
     }
-    ;
     return this.getSelectedProject();
   }
 
@@ -124,7 +131,6 @@ KylinApp.service('ProjectModel', function () {
       }
     }
     return index;
-
   }
 
 })

Reply via email to