Changeset - 9c067ee8d368
[Not reviewed]
stable
0 1 0
Jan Heylen - 11 years ago 2015-05-29 18:18:23
heyleke@gmail.com
changeset comment: fix delete button issue

issue:
when deleting comments in a list of comments on the same line,
sometimes the add new comment button stops working

root cause:
when deleting a comment in a list of comments that are all on the same line,
the wrong previous tr is chosen, the chosen tr could be an inline comments
instead of a line tr, resulting in the fact that injectinlineform function
will return immediatly

solution:
loop over the found tr until its no longer an inline comment

remark:
could probably be optimised futher to immediatly search for the line tr object
1 file changed with 3 insertions and 0 deletions:
0 comments (0 inline, 0 general)
kallithea/public/js/base.js
Show inline comments
 
@@ -727,24 +727,27 @@ var injectInlineForm = function(tr){
 
        MentionsAutoComplete('text_'+lineno, 'mentions_container_'+lineno,
 
                             _USERS_AC_DATA, _GROUPS_AC_DATA);
 
        $('#text_'+lineno).focus();
 
    },10)
 
};
 

	
 
var deleteComment = function(comment_id){
 
    var url = AJAX_COMMENT_DELETE_URL.replace('__COMMENT_ID__',comment_id);
 
    var postData = {'_method':'delete'};
 
    var success = function(o){
 
        var $deleted = $('#comment-tr-'+comment_id);
 
        var $prev = $deleted.prev('tr');
 
        while ($prev.hasClass('inline-comments')){
 
            $prev = $prev.prev('tr');
 
        }
 
        $deleted.remove();
 
        _placeAddButton($prev);
 
    }
 
    ajaxPOST(url,postData,success);
 
}
 

	
 
var _getLineNo = function(tr) {
 
    var line;
 
    var o = $(tr).children()[0].id.split('_');
 
    var n = $(tr).children()[1].id.split('_');
 

	
 
    if (n.length >= 2) {
0 comments (0 inline, 0 general)