drafts: draft finize boilerplate
This commit is contained in:
parent
f5bed7486e
commit
5bd32140fc
6 changed files with 72 additions and 19 deletions
|
|
@ -554,6 +554,10 @@ form.comment-form {
|
|||
margin-right: 0;
|
||||
}
|
||||
|
||||
#save_general {
|
||||
margin-left: -6px;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -386,6 +386,7 @@ function registerRCRoutes() {
|
|||
pyroutes.register('my_account_auth_tokens_add', '/_admin/my_account/auth_tokens/new', []);
|
||||
pyroutes.register('my_account_external_identity', '/_admin/my_account/external-identity', []);
|
||||
pyroutes.register('my_account_external_identity_delete', '/_admin/my_account/external-identity/delete', []);
|
||||
pyroutes.register('pullrequest_draft_comments_submit', '/%(repo_name)s/pull-request/%(pull_request_id)s/draft_comments_submit', ['repo_name', 'pull_request_id']);
|
||||
pyroutes.register('repo_artifacts_list', '/%(repo_name)s/artifacts', ['repo_name']);
|
||||
pyroutes.register('repo_artifacts_data', '/%(repo_name)s/artifacts_data', ['repo_name']);
|
||||
pyroutes.register('repo_artifacts_new', '/%(repo_name)s/artifacts/new', ['repo_name']);
|
||||
|
|
|
|||
|
|
@ -735,8 +735,6 @@ var CommentsController = function() {
|
|||
};
|
||||
ajaxPOST(url, postData, success, failure);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
this.deleteComment = function(node) {
|
||||
|
|
@ -757,7 +755,32 @@ var CommentsController = function() {
|
|||
};
|
||||
|
||||
this._finalizeDrafts = function(commentIds) {
|
||||
window.finalizeDrafts(commentIds)
|
||||
|
||||
// remove the drafts so we can lock them before submit.
|
||||
$.each(commentIds, function(idx, val){
|
||||
$('#comment-{0}'.format(val)).remove();
|
||||
})
|
||||
|
||||
var params = {
|
||||
'pull_request_id': templateContext.pull_request_data.pull_request_id,
|
||||
'repo_name': templateContext.repo_name,
|
||||
};
|
||||
var url = pyroutes.url('pullrequest_draft_comments_submit', params)
|
||||
var postData = {'comments': commentIds, 'csrf_token': CSRF_TOKEN};
|
||||
|
||||
var submitSuccessCallback = function(json_data) {
|
||||
self.attachInlineComment(json_data);
|
||||
|
||||
if (window.refreshDraftComments !== undefined) {
|
||||
// if we have this handler, run it, and refresh all comments boxes
|
||||
refreshDraftComments()
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
ajaxPOST(url, postData, submitSuccessCallback)
|
||||
|
||||
}
|
||||
|
||||
this.finalizeDrafts = function(commentIds) {
|
||||
|
|
@ -766,7 +789,7 @@ var CommentsController = function() {
|
|||
title: _ngettext('Submit {0} draft comment.', 'Submit {0} draft comments.', commentIds.length).format(commentIds.length),
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: _gettext('Yes, finalize drafts'),
|
||||
confirmButtonText: _gettext('Yes'),
|
||||
|
||||
}).then(function(result) {
|
||||
if (result.value) {
|
||||
|
|
|
|||
|
|
@ -1066,14 +1066,14 @@ window.ReviewerPresenceController = function (channel) {
|
|||
this.handlePresence = function (data) {
|
||||
if (data.type == 'presence' && data.channel === self.channel) {
|
||||
this.storeUsers(data.users);
|
||||
this.render()
|
||||
this.render();
|
||||
}
|
||||
};
|
||||
|
||||
this.handleChannelUpdate = function (data) {
|
||||
if (data.channel === this.channel) {
|
||||
this.storeUsers(data.state.users);
|
||||
this.render()
|
||||
this.render();
|
||||
}
|
||||
|
||||
};
|
||||
|
|
@ -1181,6 +1181,10 @@ window.refreshAllComments = function (version) {
|
|||
refreshTODOs(version);
|
||||
};
|
||||
|
||||
window.refreshDraftComments = function () {
|
||||
alert('TODO: refresh Draft Comments needs implementation')
|
||||
};
|
||||
|
||||
window.sidebarComment = function (commentId) {
|
||||
var jsonData = $('#commentHovercard{0}'.format(commentId)).data('commentJsonB64');
|
||||
if (!jsonData) {
|
||||
|
|
|
|||
|
|
@ -51,13 +51,11 @@
|
|||
<div class="tooltip comment-draft" title="${_('Draft comments are only visible to the author until submitted')}.">
|
||||
DRAFT
|
||||
</div>
|
||||
% endif
|
||||
|
||||
% if is_new:
|
||||
<div class="tooltip comment-new" title="${_('This comment was added while you browsed this page')}.">
|
||||
% elif is_new:
|
||||
<div class="tooltip comment-new" title="${_('This comment was added while you browsed this page')}.">
|
||||
NEW
|
||||
</div>
|
||||
% endif
|
||||
</div>
|
||||
% endif
|
||||
|
||||
<div class="comment-label ${comment.comment_type or 'note'}" id="comment-label-${comment.comment_id}">
|
||||
|
||||
|
|
@ -515,7 +513,7 @@
|
|||
## Disable the button for CE, the "real" validation is in the backend code anyway
|
||||
<input class="btn btn-warning comment-button-input submit-draft-action" id="save_draft_${lineno_id}" name="save_draft" type="submit" value="${_('Add draft')}" data-is-draft=true onclick="$(this).addClass('submitter')">
|
||||
% else:
|
||||
<input class="tooltip btn btn-warning comment-button-input submit-draft-action disabled" type="submit" disabled="disabled" value="${_('Add draft')}" onclick="return false;" title="Draft comments only available in EE edition of RhodeCode">
|
||||
<input class="btn btn-warning comment-button-input submit-draft-action disabled" disabled="disabled" type="submit" value="${_('Add draft')}" onclick="return false;" title="Draft comments only available in EE edition of RhodeCode">
|
||||
% endif
|
||||
% endif
|
||||
|
||||
|
|
|
|||
|
|
@ -552,6 +552,35 @@
|
|||
## CONTENT
|
||||
<div class="sidebar-content">
|
||||
|
||||
## Drafts
|
||||
% if c.rhodecode_edition_id == 'EE':
|
||||
<div class="sidebar-element clear-both">
|
||||
<div class="tooltip right-sidebar-collapsed-state" style="display: none" onclick="toggleSidebar(); return false" title="${_('Drafts')}">
|
||||
<i class="icon-comment icon-draft"></i>
|
||||
<span id="comments-count">${0}</span>
|
||||
</div>
|
||||
|
||||
<div class="right-sidebar-expanded-state pr-details-title">
|
||||
<span class="sidebar-heading noselect">
|
||||
<i class="icon-comment icon-draft"></i>
|
||||
${_('Drafts')}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div id="drafts" class="right-sidebar-expanded-state pr-details-content reviewers">
|
||||
## members redering block
|
||||
|
||||
|
||||
???
|
||||
|
||||
|
||||
## end members redering block
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
% endif
|
||||
|
||||
## RULES SUMMARY/RULES
|
||||
<div class="sidebar-element clear-both">
|
||||
<% vote_title = _ungettext(
|
||||
|
|
@ -997,12 +1026,6 @@ $(document).ready(function () {
|
|||
|
||||
var channel = '${c.pr_broadcast_channel}';
|
||||
new ReviewerPresenceController(channel)
|
||||
|
||||
|
||||
window.finalizeDrafts = function(commentIds) {
|
||||
alert('okok !' + commentIds)
|
||||
|
||||
}
|
||||
// register globally so inject comment logic can re-use it.
|
||||
window.commentsController = commentsController;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue