From 40c6aeafd6ab0844ff2a9ecca4c123d71808ec90 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Tue, 22 Jul 2014 13:44:08 +0200 Subject: SONAR-5468 Improve rendering of duplications that are on the same file --- .../coffee/component-viewer/duplication-popup.coffee | 17 +++++++++++------ .../src/main/coffee/component-viewer/main.coffee | 5 ++--- .../src/main/coffee/component-viewer/source.coffee | 2 +- .../main/hbs/component-viewer/cw-duplication-popup.hbs | 8 +++++--- 4 files changed, 19 insertions(+), 13 deletions(-) (limited to 'server') diff --git a/server/sonar-web/src/main/coffee/component-viewer/duplication-popup.coffee b/server/sonar-web/src/main/coffee/component-viewer/duplication-popup.coffee index cd24e404ac4..8cec94774c6 100644 --- a/server/sonar-web/src/main/coffee/component-viewer/duplication-popup.coffee +++ b/server/sonar-web/src/main/coffee/component-viewer/duplication-popup.coffee @@ -24,8 +24,6 @@ define [ goToFile: (e) -> key = $(e.currentTarget).data 'key' line = $(e.currentTarget).data 'line' - if key == @options.main.component.get 'key' - return @options.main.scrollToLine line files = @options.main.source.get('duplicationFiles') @options.main.addTransition 'duplication', @collection.map (item) -> file = files[item.get('_ref')] @@ -34,10 +32,14 @@ define [ name: x.name subname: x.dir active: file.key == key - @options.main._open key - @options.main.on 'sized', => - @options.main.off 'sized' + if key == @options.main.component.get 'key' @options.main.scrollToLine line + @options.main.workspaceView.render() + else + @options.main._open key + @options.main.on 'sized', => + @options.main.off 'sized' + @options.main.scrollToLine line serializeData: -> @@ -47,6 +49,9 @@ define [ blocks: blocks file: files[fileRef] duplications = _.sortBy duplications, (d) => - d.file.projectName != @options.main.component.get 'projectName' + a = d.file.projectName != @options.main.component.get 'projectName' + b = d.file.key != @options.main.component.get 'key' + '' + a + b + component: @options.main.component.toJSON() duplications: duplications diff --git a/server/sonar-web/src/main/coffee/component-viewer/main.coffee b/server/sonar-web/src/main/coffee/component-viewer/main.coffee index fcf5ca96c13..0aca76e4798 100644 --- a/server/sonar-web/src/main/coffee/component-viewer/main.coffee +++ b/server/sonar-web/src/main/coffee/component-viewer/main.coffee @@ -347,10 +347,9 @@ define [ setTimeout (=> @scrollToLine(line)), 100 return @scrolled = line - d = row.offset().top - @$el.offset().top - SCROLL_OFFSET + d = row.offset().top - @$(@sourceRegion.$el).offset().top + @$(@sourceRegion.$el).scrollTop() - SCROLL_OFFSET @scrollPlusDelta d scrollPlusDelta: (delta) -> - parent = @$el.scrollParent() - parent.scrollTop delta + @$(@sourceRegion.$el).scrollTop delta diff --git a/server/sonar-web/src/main/coffee/component-viewer/source.coffee b/server/sonar-web/src/main/coffee/component-viewer/source.coffee index a9f612367bd..c4a9b5c9619 100644 --- a/server/sonar-web/src/main/coffee/component-viewer/source.coffee +++ b/server/sonar-web/src/main/coffee/component-viewer/source.coffee @@ -202,7 +202,7 @@ define [ line = $(e.currentTarget).closest('[data-line-number]').data 'line-number' blocks = @model.get('duplications')[index - 1].blocks blocks = _.filter blocks, (b) -> - (b._ref != '1') || (b._ref == '1' && b.from > line) || (b._ref == '1' && b.from + b.size <= line) + (b._ref != '1') || (b._ref == '1' && b.from > line) || (b._ref == '1' && b.from + b.size < line) popup = new DuplicationPopupView triggerEl: $(e.currentTarget) main: @options.main diff --git a/server/sonar-web/src/main/hbs/component-viewer/cw-duplication-popup.hbs b/server/sonar-web/src/main/hbs/component-viewer/cw-duplication-popup.hbs index 8161966f29b..cc1d8a74fd2 100644 --- a/server/sonar-web/src/main/hbs/component-viewer/cw-duplication-popup.hbs +++ b/server/sonar-web/src/main/hbs/component-viewer/cw-duplication-popup.hbs @@ -5,9 +5,11 @@ {{#notEq file.projectName ../component.projectName}} {{file.projectName}} {{/notEq}} - - {{file.name}} - + {{#notEq file.key ../component.key}} + + {{file.name}} + + {{/notEq}}
Lines: -- cgit v1.2.3