diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2014-07-22 13:44:08 +0200 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2014-07-22 13:44:08 +0200 |
commit | 40c6aeafd6ab0844ff2a9ecca4c123d71808ec90 (patch) | |
tree | 7208baaee1cb39f955461c194293178fc7c3baec /server | |
parent | b3bbe32f490ef117d4bc66ba33923bc7bdeeffd9 (diff) | |
download | sonarqube-40c6aeafd6ab0844ff2a9ecca4c123d71808ec90.tar.gz sonarqube-40c6aeafd6ab0844ff2a9ecca4c123d71808ec90.zip |
SONAR-5468 Improve rendering of duplications that are on the same file
Diffstat (limited to 'server')
4 files changed, 19 insertions, 13 deletions
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}} <span class="component-viewer-popup-label">{{file.projectName}}</span> {{/notEq}} - <a class="link-action" data-key="{{file.key}}" title="{{file.name}}"> - {{file.name}} - </a> + {{#notEq file.key ../component.key}} + <a class="link-action" data-key="{{file.key}}" title="{{file.name}}"> + {{file.name}} + </a> + {{/notEq}} <div class="component-viewer-popup-duplications"> Lines: |