From a040b655599e5e46917d4b53c040c3fd7b6e1d29 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Wed, 21 Aug 2013 14:56:38 +0200 Subject: [PATCH] SONAR-3524 Do not zoom in treemap if next step is empty --- .../app/models/measure_filter_display_treemap.rb | 5 +++-- .../src/main/webapp/javascripts/application.js | 11 ++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/measure_filter_display_treemap.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/measure_filter_display_treemap.rb index b234563f36d..23bfe106b1a 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/measure_filter_display_treemap.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/measure_filter_display_treemap.rb @@ -42,10 +42,11 @@ class MeasureFilterDisplayTreemap < MeasureFilterDisplay end def html - if filter.rows + # SONAR-3524 + # If filter is empty, we return a empty result in order to be treated more easily + if filter.rows && !filter.rows.empty? root = Treemap::Node.new(:id => -1, :label => '') build_tree(root) - output = Sonar::HtmlOutput.new do |o| # width in percents o.width = 100 diff --git a/sonar-server/src/main/webapp/javascripts/application.js b/sonar-server/src/main/webapp/javascripts/application.js index 501fd589a24..29a1db1a12d 100644 --- a/sonar-server/src/main/webapp/javascripts/application.js +++ b/sonar-server/src/main/webapp/javascripts/application.js @@ -201,8 +201,14 @@ Treemap.prototype.load = function () { url: baseUrl + '/treemap/index?html_id=' + this.id + '&size_metric=' + this.sizeMetric + '&color_metric=' + this.colorMetric + '&resource=' + context.rid, dataType: "html", success: function (data) { - self.rootNode().html(data); - self.initNodes(); + if (data.length > 1) { + self.rootNode().html(data); + self.initNodes(); + } else { + // SONAR-3524 + // When data is empty, do not display it and revert breadcrumb state + self.breadcrumb.pop(); + } $j("#tm-loading-" + self.id).hide(); } }); @@ -241,7 +247,6 @@ Treemap.prototype.initNodes = function () { self.breadcrumb.push(context); self.load(); } - } ); }); -- 2.39.5