changeset 4819:990ec5ed4ee5

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.
author Thomas De Schampheleire <thomas.de_schampheleire@alcatel-lucent.com>
date Thu, 29 Jan 2015 21:48:54 +0100
parents 051624cb5f3a
children 953ee49f3b30
files kallithea/public/js/base.js kallithea/templates/changeset/changeset.html kallithea/templates/pullrequests/pullrequest_show.html
diffstat 3 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/public/js/base.js	Tue Jan 27 22:03:55 2015 +0100
+++ b/kallithea/public/js/base.js	Thu Jan 29 21:48:54 2015 +0100
@@ -818,6 +818,7 @@
         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,
@@ -825,6 +826,7 @@
                 'target_id': target_id
             }
             if (_renderInlineComment(data)) {
+                obsolete_comments.push(comments[i]);
                 $(comments[i]).hide();
             }else{
                 var txt = document.createTextNode(
@@ -834,6 +836,12 @@
                 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();
     }
 }
--- a/kallithea/templates/changeset/changeset.html	Tue Jan 27 22:03:55 2015 +0100
+++ b/kallithea/templates/changeset/changeset.html	Thu Jan 29 21:48:54 2015 +0100
@@ -208,7 +208,7 @@
           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')}",
--- a/kallithea/templates/pullrequests/pullrequest_show.html	Tue Jan 27 22:03:55 2015 +0100
+++ b/kallithea/templates/pullrequests/pullrequest_show.html	Thu Jan 29 21:48:54 2015 +0100
@@ -361,7 +361,7 @@
           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;