Changeset - 990ec5ed4ee5
[Not reviewed]
default
0 3 0
Thomas De Schampheleire - 11 years ago 2015-01-29 21:48:54
thomas.de_schampheleire@alcatel-lucent.com
comment handling: extend next/previous links to global comments (issue #91)

Until now, only inline comments were linked to each other with next/previous
links.

This commit extends this mechanism to global comments, such that the last
inline comment has a next link to the first global comment, which has a next
link to the next global comment (and the other way around for previous
links).

In order to work well, instead of hiding inline comments that have been
moved, they actually have to be deleted.
3 files changed with 10 insertions and 2 deletions:
0 comments (0 inline, 0 general)
kallithea/public/js/base.js
Show inline comments
 
@@ -815,28 +815,36 @@ var renderInlineComments = function(file
 
        // holding all comments for a FILE
 
        var box = file_comments[f];
 

	
 
        var target_id = $(box).attr('target_id');
 
        // actual comments with line numbers
 
        var comments = box.children;
 
        var obsolete_comments = [];
 
        for(var i=0; i<comments.length; i++){
 
            var data = {
 
                'rendered_text': comments[i].outerHTML,
 
                'line_no': $(comments[i]).attr('line'),
 
                'target_id': target_id
 
            }
 
            if (_renderInlineComment(data)) {
 
                obsolete_comments.push(comments[i]);
 
                $(comments[i]).hide();
 
            }else{
 
                var txt = document.createTextNode(
 
                        "Comment to " + YUD.getAttribute(comments[i].parentNode,'path') +
 
                        " line " + data.line_no +
 
                        " which is outside the diff context:");
 
                comments[i].insertBefore(txt, comments[i].firstChild);
 
            }
 
        }
 
        // now remove all the obsolete comments that have been copied to their
 
        // respective locations.
 
        for (var i=0; i < obsolete_comments.length; i++) {
 
            obsolete_comments[i].parentNode.removeChild(obsolete_comments[i]);
 
        }
 

	
 
        $(box).show();
 
    }
 
}
 

	
 
/**
 
 * Double link comments
kallithea/templates/changeset/changeset.html
Show inline comments
 
@@ -205,13 +205,13 @@ ${self.repo_context_bar('changelog', c.c
 
          });
 

	
 
          // inject comments into they proper positions
 
          var file_comments = $('.inline-comment-placeholder').toArray();
 
          renderInlineComments(file_comments);
 

	
 
          linkInlineComments(document.getElementsByClassName('firstlink'), document.getElementsByClassName("inline-comment"));
 
          linkInlineComments(document.getElementsByClassName('firstlink'), document.getElementsByClassName("comment"));
 

	
 
          pyroutes.register('changeset_home',
 
                            "${h.url('changeset_home', repo_name='%(repo_name)s', revision='%(revision)s')}",
 
                            ['repo_name', 'revision']);
 

	
 
          //next links
kallithea/templates/pullrequests/pullrequest_show.html
Show inline comments
 
@@ -358,13 +358,13 @@ ${self.repo_context_bar('showpullrequest
 
          avail_r.render(avail_jsdata,40);
 

	
 
          // inject comments into they proper positions
 
          var file_comments = $('.inline-comment-placeholder').toArray();
 
          renderInlineComments(file_comments);
 

	
 
          linkInlineComments(document.getElementsByClassName('firstlink'), document.getElementsByClassName("inline-comment"));
 
          linkInlineComments(document.getElementsByClassName('firstlink'), document.getElementsByClassName("comment"));
 

	
 
          $('#updaterevs input').change(function(e){
 
              var update = !!e.target.value;
 
              $('#pr-form-save').prop('disabled',update);
 
              $('#pr-form-clone').prop('disabled',!update);
 
          });
0 comments (0 inline, 0 general)