diff --git a/rhodecode/controllers/changeset.py b/rhodecode/controllers/changeset.py --- a/rhodecode/controllers/changeset.py +++ b/rhodecode/controllers/changeset.py @@ -208,6 +208,7 @@ class ChangesetController(BaseRepoContro c.statuses = [] c.comments = [] + c.unresolved_comments = [] if len(c.commit_ranges) == 1: commit = c.commit_ranges[0] c.comments = CommentsModel().get_comments( @@ -226,6 +227,9 @@ class ChangesetController(BaseRepoContro for pr in prs: c.comments.extend(pr.comments) + c.unresolved_comments = CommentsModel()\ + .get_commit_unresolved_todos(commit.raw_id) + # Iterate over ranges (default commit view is always one commit) for commit in c.commit_ranges: c.changes[commit.raw_id] = [] @@ -275,7 +279,6 @@ class ChangesetController(BaseRepoContro # sort comments by how they were generated c.comments = sorted(c.comments, key=lambda x: x.comment_id) - if len(c.commit_ranges) == 1: c.commit = c.commit_ranges[0] c.parent_tmpl = ''.join( diff --git a/rhodecode/model/comment.py b/rhodecode/model/comment.py --- a/rhodecode/model/comment.py +++ b/rhodecode/model/comment.py @@ -146,6 +146,23 @@ class CommentsModel(BaseModel): return todos + def get_commit_unresolved_todos(self, commit_id, show_outdated=True): + + todos = Session().query(ChangesetComment) \ + .filter(ChangesetComment.revision == commit_id) \ + .filter(ChangesetComment.resolved_by == None) \ + .filter(ChangesetComment.comment_type + == ChangesetComment.COMMENT_TYPE_TODO) + + if not show_outdated: + todos = todos.filter( + coalesce(ChangesetComment.display_state, '') != + ChangesetComment.COMMENT_OUTDATED) + + todos = todos.all() + + return todos + def create(self, text, repo, user, commit_id=None, pull_request=None, f_path=None, line_no=None, status_change=None, status_change_type=None, comment_type=None, diff --git a/rhodecode/public/js/src/rhodecode.js b/rhodecode/public/js/src/rhodecode.js --- a/rhodecode/public/js/src/rhodecode.js +++ b/rhodecode/public/js/src/rhodecode.js @@ -241,6 +241,9 @@ function scrollToElement(element, percen time = (time === undefined ? 100 : time); var $element = $(element); + if ($element.length == 0) { + throw('Cannot scroll to {0}'.format(element)) + } var elOffset = $element.offset().top; var elHeight = $element.height(); var windowHeight = $(window).height(); diff --git a/rhodecode/public/js/src/rhodecode/comments.js b/rhodecode/public/js/src/rhodecode/comments.js --- a/rhodecode/public/js/src/rhodecode/comments.js +++ b/rhodecode/public/js/src/rhodecode/comments.js @@ -461,6 +461,7 @@ var CommentsController = function() { }; this.scrollToComment = function(node, offset, outdated) { + var offset = offset || 1; var outdated = outdated || false; var klass = outdated ? 'div.comment-outdated' : 'div.comment-current'; @@ -486,6 +487,7 @@ var CommentsController = function() { nextIdx = 0; } var $next = $(klass).eq(nextIdx); + var $cb = $next.closest('.cb'); $cb.removeClass('cb-collapsed'); diff --git a/rhodecode/templates/changeset/changeset.mako b/rhodecode/templates/changeset/changeset.mako --- a/rhodecode/templates/changeset/changeset.mako +++ b/rhodecode/templates/changeset/changeset.mako @@ -155,6 +155,23 @@ +