]> source.dussan.org Git - sonarqube.git/commitdiff
New Issues Page: if an issue is at file level, display 30 lines of source code below
authorStas Vilchik <vilchiks@gmail.com>
Tue, 4 Feb 2014 10:26:20 +0000 (16:26 +0600)
committerStas Vilchik <vilchiks@gmail.com>
Tue, 4 Feb 2014 10:26:20 +0000 (16:26 +0600)
sonar-server/src/main/webapp/javascripts/navigator/issues.js

index 5d39841af3af5d4a2761bc6ebb067ae76b3a6ba8..a00409cd8e770e780a0bb50665a0d36fde21126e 100644 (file)
@@ -176,25 +176,19 @@ jQuery(function() {
           });
 
       jQuery('.navigator-details').empty().addClass('navigator-fetching');
-      if (this.model.get('line')) {
-        jQuery.when(detailView.model.fetch()).done(function() {
-          that.fetchSource(detailView, function() {
-            jQuery('.navigator-details').removeClass('navigator-fetching');
-            app.detailsRegion.show(detailView);
-          });
-        });
-      } else {
-        jQuery.when(detailView.model.fetch()).done(function() {
+      jQuery.when(detailView.model.fetch()).done(function() {
+        that.fetchSource(detailView, function() {
           jQuery('.navigator-details').removeClass('navigator-fetching');
           app.detailsRegion.show(detailView);
         });
-      }
+      });
     },
 
 
     fetchSource: function (view, callback) {
-      var from = this.model.get('line') - 10,
-          to = this.model.get('line') + 30;
+      var line = this.model.get('line') || 0,
+          from = line >= 10 ? line - 10 : 0,
+          to = line + 30;
 
       return jQuery
           .ajax({
@@ -202,7 +196,7 @@ jQuery(function() {
             url: baseUrl + '/api/sources/show',
             data: {
               key: this.model.get('component'),
-              from: from >= 0 ? from : 0,
+              from: from,
               to: to,
               format: 'json'
             }