diff --git a/rhodecode/controllers/changeset.py b/rhodecode/controllers/changeset.py --- a/rhodecode/controllers/changeset.py +++ b/rhodecode/controllers/changeset.py @@ -342,11 +342,14 @@ class ChangesetController(BaseRepoContro % {'transition_icon': '>', 'status': ChangesetStatus.get_status_lbl(status)}) - multi_commit_ids = filter( - lambda s: s not in ['', None], - request.POST.get('commit_ids', '').split(','),) + multi_commit_ids = [] + for _commit_id in request.POST.get('commit_ids', '').split(','): + if _commit_id not in ['', None, EmptyCommit.raw_id]: + if _commit_id not in multi_commit_ids: + multi_commit_ids.append(_commit_id) commit_ids = multi_commit_ids or [commit_id] + comment = None for current_id in filter(None, commit_ids): c.co = comment = CommentsModel().create( 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 @@ -43,12 +43,16 @@ var bindToggleButtons = function() { }; /* Comment form for main and inline comments */ +(function(mod) { -(function(mod) { - if (typeof exports == "object" && typeof module == "object") // CommonJS - module.exports = mod(); - else // Plain browser env - (this || window).CommentForm = mod(); + if (typeof exports == "object" && typeof module == "object") { + // CommonJS + module.exports = mod(); + } + else { + // Plain browser env + (this || window).CommentForm = mod(); + } })(function() { "use strict"; @@ -236,6 +240,8 @@ var bindToggleButtons = function() { $(this.statusChange).select2('readonly', false); }; + this.globalSubmitSuccessCallback = function(){}; + this.submitAjaxPOST = function(url, postData, successHandler, failHandler) { failHandler = failHandler || function() {}; var postData = toQueryString(postData); @@ -262,6 +268,11 @@ var bindToggleButtons = function() { this.handleFormSubmit = callback; }; + // overwrite a submitSuccessHandler + this.setGlobalSubmitSuccessCallback = function(callback) { + this.globalSubmitSuccessCallback = callback; + }; + // default handler for for submit for main comments this.handleFormSubmit = function() { var text = self.cm.getValue(); @@ -287,6 +298,7 @@ var bindToggleButtons = function() { if (resolvesCommentId){ postData['resolves_comment_id'] = resolvesCommentId; } + var submitSuccessCallback = function(o) { if (status) { location.reload(true); @@ -300,6 +312,10 @@ var bindToggleButtons = function() { self.markCommentResolved(resolvesCommentId); } } + + // run global callback on submit + self.globalSubmitSuccessCallback(); + }; var submitFailCallback = function(){ self.resetCommentFormState(text); @@ -585,22 +601,25 @@ var CommentsController = function() { return commentForm; }; - this.createGeneralComment = function(lineNo, placeholderText, resolvesCommentId){ + this.createGeneralComment = function (lineNo, placeholderText, resolvesCommentId) { var tmpl = $('#cb-comment-general-form-template').html(); tmpl = tmpl.format(null, 'general'); var $form = $(tmpl); - var curForm = $('#cb-comment-general-form-placeholder').find('form'); + var $formPlaceholder = $('#cb-comment-general-form-placeholder'); + var curForm = $formPlaceholder.find('form'); if (curForm){ curForm.remove(); } - $('#cb-comment-general-form-placeholder').append($form); + $formPlaceholder.append($form); var _form = $($form[0]); var commentForm = this.createCommentForm( _form, lineNo, placeholderText, true, resolvesCommentId); commentForm.initStatusChangeSelector(); + + return commentForm; }; this.createComment = function(node, resolutionComment) { @@ -690,6 +709,9 @@ var CommentsController = function() { commentForm.markCommentResolved(resolvesCommentId); } + // run global callback on submit + commentForm.globalSubmitSuccessCallback(); + } catch (e) { console.error(e); } diff --git a/rhodecode/templates/changeset/changeset_file_comment.mako b/rhodecode/templates/changeset/changeset_file_comment.mako --- a/rhodecode/templates/changeset/changeset_file_comment.mako +++ b/rhodecode/templates/changeset/changeset_file_comment.mako @@ -190,7 +190,7 @@ if is_pull_request: placeholder = _('Leave a comment on this Pull Request.') elif is_compare: - placeholder = _('Leave a comment on all commits in this range.') + placeholder = _('Leave a comment on {} commits in this range.').format(len(form_extras)) else: placeholder = _('Leave a comment on this Commit.') %> @@ -207,7 +207,59 @@ % else: ## form state when not logged in diff --git a/rhodecode/templates/compare/compare_diff.mako b/rhodecode/templates/compare/compare_diff.mako --- a/rhodecode/templates/compare/compare_diff.mako +++ b/rhodecode/templates/compare/compare_diff.mako @@ -171,50 +171,6 @@ %>
${comment.comments(h.url('changeset_comment', repo_name=c.repo_name, revision='0'*16), None, is_compare=True, form_extras=revs(c.commit_ranges))} -