<div class="bubble-popup-container">
- <div class="bubble-popup-title">{{t 'component_viewer.transition.duplication'}}</div>
- {{#each duplications}}
- <div class="bubble-popup-section">
- <div class="component-name">
- {{#notEqComponents file ../component}}
- <div class="component-name-parent">
- <i class="icon-qualifier-trk"></i> <a href="{{dashboardUrl file.project}}">{{file.projectName}}</a>
- </div>
- {{#if file.subProjectName}}
+ {{#if inRemovedComponent}}
+ <div class="alert alert-warning spacer-bottom">{{t 'duplications.dups_found_on_deleted_resource'}}</div>
+ {{/if}}
+ {{#notEmpty duplications}}
+ <div class="bubble-popup-title">{{t 'component_viewer.transition.duplication'}}</div>
+ {{#each duplications}}
+ <div class="bubble-popup-section">
+ <div class="component-name">
+ {{#notEqComponents file ../component}}
<div class="component-name-parent">
- <i class="icon-qualifier-trk"></i> <a
- href="{{dashboardUrl file.subProject}}">{{file.subProjectName}}</a>
+ <i class="icon-qualifier-trk"></i> <a href="{{dashboardUrl file.project}}">{{file.projectName}}</a>
+ </div>
+ {{#if file.subProjectName}}
+ <div class="component-name-parent">
+ <i class="icon-qualifier-trk"></i> <a
+ href="{{dashboardUrl file.subProject}}">{{file.subProjectName}}</a>
+ </div>
+ {{/if}}
+ {{/notEqComponents}}
+
+ {{#notEq file.key ../component.key}}
+ <div class="component-name-path">
+ <a class="link-action" data-key="{{file.key}}" title="{{file.name}}">
+ <span>{{collapsedDirFromPath file.name}}</span><span
+ class="component-name-file">{{fileFromPath file.name}}</span>
+ </a>
</div>
- {{/if}}
- {{/notEqComponents}}
+ {{/notEq}}
- {{#notEq file.key ../component.key}}
<div class="component-name-path">
- <a class="link-action" data-key="{{file.key}}" title="{{file.name}}">
- <span>{{collapsedDirFromPath file.name}}</span><span
- class="component-name-file">{{fileFromPath file.name}}</span>
- </a>
+ Lines:
+ {{#joinEach blocks ','}}
+ <a class="link-action" data-key="{{../file.key}}" data-line="{{from}}">
+ {{from}} – {{sum from size -1}}
+ </a>
+ {{/joinEach}}
</div>
- {{/notEq}}
-
- <div class="component-name-path">
- Lines:
- {{#joinEach blocks ','}}
- <a class="link-action" data-key="{{../file.key}}" data-line="{{from}}">
- {{from}} – {{sum from size -1}}
- </a>
- {{/joinEach}}
</div>
</div>
- </div>
- {{else}}
- {{t 'duplications.block_was_duplicated_by_a_deleted_resource'}}
- {{/each}}
+ {{/each}}
+ {{/notEmpty}}
</div>
<div class="bubble-popup-arrow"></div>
},
serializeData: function () {
- var duplications, files, groupedBlocks;
- files = this.model.get('duplicationFiles');
- groupedBlocks = _.groupBy(this.collection.toJSON(), '_ref');
- duplications = _.map(groupedBlocks, function (blocks, fileRef) {
- return {
- blocks: blocks,
- file: files[fileRef]
- };
+ var that = this,
+ files = this.model.get('duplicationFiles'),
+ groupedBlocks = _.groupBy(this.collection.toJSON(), '_ref'),
+ duplications = _.map(groupedBlocks, function (blocks, fileRef) {
+ return {
+ blocks: blocks,
+ file: files[fileRef]
+ };
+ });
+ duplications = _.sortBy(duplications, function (d) {
+ var a = d.file.projectName !== that.model.get('projectName'),
+ b = d.file.subProjectName !== that.model.get('subProjectName'),
+ c = d.file.key !== that.model.get('key');
+ return '' + a + b + c;
});
- duplications = _.sortBy(duplications, (function (_this) {
- return function (d) {
- var a, b, c;
- a = d.file.projectName !== _this.model.get('projectName');
- b = d.file.subProjectName !== _this.model.get('subProjectName');
- c = d.file.key !== _this.model.get('key');
- return '' + a + b + c;
- };
- })(this));
return {
component: this.model.toJSON(),
- duplications: duplications
+ duplications: duplications,
+ inRemovedComponent: this.options.inRemovedComponent
};
}
});
this.clearTooltips();
var index = $(e.currentTarget).data('index'),
line = $(e.currentTarget).data('line-number'),
- blocks = this.model.get('duplications')[index - 1].blocks;
+ blocks = this.model.get('duplications')[index - 1].blocks,
+ inRemovedComponent = _.some(blocks, function (b) {
+ return b._ref == null;
+ }),
+ foundOne = false;
blocks = _.filter(blocks, function (b) {
- var outOfBounds = b.from > line || b.from + b.size < line;
- return (b._ref !== '1') || (b._ref === '1' && outOfBounds);
+ var outOfBounds = b.from > line || b.from + b.size < line,
+ currentFile = b._ref === '1',
+ isOk = (b._ref != null) && (!currentFile || (currentFile && (outOfBounds || foundOne)));
+ if (b._ref === '1' && !outOfBounds) {
+ foundOne = true;
+ }
+ return isOk;
});
var popup = new DuplicationPopupView({
triggerEl: $(e.currentTarget),
model: this.model,
+ inRemovedComponent: inRemovedComponent,
collection: new Backbone.Collection(blocks)
});
popup.render();