serializeData: ->
files = @options.main.source.get('duplicationFiles')
- blocks = _.groupBy @collection.toJSON(), '_ref'
- duplications = _.map blocks, (blocks, fileRef) ->
+ groupedBlocks = _.groupBy @collection.toJSON(), '_ref'
+ duplications = _.map groupedBlocks, (blocks, fileRef) ->
blocks: blocks
file: files[fileRef]
duplications: duplications
e.stopPropagation()
$('body').click()
index = $(e.currentTarget).data 'index'
+ 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)
popup = new DuplicationPopupView
triggerEl: $(e.currentTarget)
main: @options.main
- collection: new Backbone.Collection @model.get('duplications')[index - 1].blocks
+ collection: new Backbone.Collection blocks
popup.render()
<tr class="row"
data-line-number="{{lineNumber}}">
- {{#if ../../settings.duplications}}
- <td class="stat duplications">
- {{#each duplications}}
- <span class="duplication {{#if this}}duplication-exists{{/if}}" data-index="{{this}}"></span>
- {{/each}}
- </td>
- {{/if}}
-
{{#if ../../settings.scm}}
<td class="stat {{#if scm}}scm{{/if}}">
{{#if scm}}
</td>
{{/if}}
+ {{#if ../../settings.duplications}}
+ <td class="stat duplications">
+ {{#each duplications}}
+ <span class="duplication {{#if this}}duplication-exists{{/if}}" data-index="{{this}}"></span>
+ {{/each}}
+ </td>
+ {{/if}}
+
{{#if ../../settings.coverage}}
<td class="stat {{#if coverage}}coverage-{{#if coverage.covered}}green{{else}}red{{/if}}{{/if}}">
{{#if coverage}}