]> source.dussan.org Git - sonarqube.git/commitdiff
New Issues Page: fix issue display when there are no sources
authorStas Vilchik <vilchiks@gmail.com>
Thu, 30 Jan 2014 06:40:55 +0000 (12:40 +0600)
committerStas Vilchik <vilchiks@gmail.com>
Thu, 30 Jan 2014 08:53:08 +0000 (14:53 +0600)
sonar-server/src/main/webapp/javascripts/navigator/issues.js

index 9f984a4e1c7f50a772ee934be3052c6bc83a549d..106b28ec09fdba1b828b3f505cf390a220cfd203 100644 (file)
@@ -164,14 +164,17 @@ jQuery(function() {
       this.$el.parent().children().removeClass('active');
       this.$el.addClass('active');
 
-      var app = this.options.app,
+      var that = this,
+          app = this.options.app,
           detailView = new window.SS.IssueDetailView({
             model: this.model
           });
 
       if (this.model.get('line')) {
-        jQuery.when(detailView.model.fetch(), this.fetchSource(detailView)).done(function() {
-          app.detailsRegion.show(detailView);
+        jQuery.when(detailView.model.fetch()).done(function() {
+          that.fetchSource(detailView, function() {
+            app.detailsRegion.show(detailView);
+          });
         });
       } else {
         jQuery.when(detailView.model.fetch()).done(function() {
@@ -181,27 +184,30 @@ jQuery(function() {
     },
 
 
-    fetchSource: function(view) {
+    fetchSource: function (view, callback) {
       var from = this.model.get('line') - 10,
           to = this.model.get('line') + 30;
 
-      return jQuery.ajax({
-        type: 'GET',
-        url: baseUrl + '/api/sources/show',
-        data: {
-          key: this.model.get('component'),
-          from: from >= 0 ? from : 0,
-          to: to,
-          format: 'json'
-        }
-      }).done(function(r) {
+      return jQuery
+          .ajax({
+            type: 'GET',
+            url: baseUrl + '/api/sources/show',
+            data: {
+              key: this.model.get('component'),
+              from: from >= 0 ? from : 0,
+              to: to,
+              format: 'json'
+            }
+          })
+          .done(function (r) {
             if (_.isObject(r) && r.source) {
               view.source = r.source;
             }
             if (_.isObject(r) && r.scm) {
               view.scm = r.scm;
             }
-          });
+          })
+          .always(callback);
     }
   });