changeset 4327:64d6e8e298a4

comments: don't hide comments made to lines outside the diff context This is a hack but seems like the best way to solve the problem of users increasing the context size and then making comments. The way things are done makes it hard to come up with a better solution. It should perhaps also be made impossible to comment on lines that isn't changed in the changeset. This issue is related to the need for a way to easily navigate to the (unresolved) comments that has been made on a huge changeset.
author Mads Kiilerich <madski@unity3d.com>
date Mon, 17 Jun 2013 18:23:13 +0200
parents fb3b45acd172
children 93e5683e3d2e
files kallithea/public/js/base.js
diffstat 1 files changed, 15 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/public/js/base.js	Fri Jul 18 18:44:54 2014 +0200
+++ b/kallithea/public/js/base.js	Mon Jun 17 18:23:13 2013 +0200
@@ -803,6 +803,9 @@
  */
 var _placeInline = function(target_id, lineno, html){
     var $td = $("#{0}_{1}".format(target_id, lineno));
+    if (!$td.length){
+        return false;
+    }
 
     // check if there are comments already !
     var $line_tr = $td.parent(); // the tr
@@ -815,6 +818,7 @@
 
     // scan nodes, and attach add button to last one
     _placeAddButton($line_tr);
+    return true;
 }
 
 /**
@@ -824,7 +828,7 @@
     var html =  json_data['rendered_text'];
     var lineno = json_data['line_no'];
     var target_id = json_data['target_id'];
-    _placeInline(target_id, lineno, html);
+    return _placeInline(target_id, lineno, html);
 }
 
 /**
@@ -844,8 +848,17 @@
                 'line_no': $(comments[i]).attr('line'),
                 'target_id': target_id
             }
-            _renderInlineComment(data);
+            if (_renderInlineComment(data)) {
+                $(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);
+            }
         }
+        $(box).show();
     }
 }