diff --git a/pagure/static/request_ev.js b/pagure/static/request_ev.js new file mode 100644 index 0000000..a293315 --- /dev/null +++ b/pagure/static/request_ev.js @@ -0,0 +1,50 @@ +add_comment = function(data) { + console.log('Adding comment ' + data.comment_added); + if (data.commit_id){ + // Inline comment + console.log('Inline'); + var _data = ' \ + \ + \ +
\ + ' + + data.comment_user + '' + data.comment_date + '
' + + data.comment_added + + '
'; + var field = $('[data-commit="' + data.commit_id + '"]').parent(); + var id = field.children().children().attr('id').split('_')[0]; + var row = $('#' + id + '_' + (parseInt(data.line) + 1)).parent().parent(); + row.before(_data); + } else { + // Generic comment + console.log('generic'); + var field = $('#request_comment'); + var _data = '
\ +
\ + \ + \ + ' + data.comment_user + '\ + - seconds ago \ + ΒΆ \ + \ +
\ +
\ +

' + data.comment_added + '

\ +
\ +
'; + + field.html(field.html() + _data); + } +} + +process_event = function(data, requestid){ + console.log(data); + if (data.comment_added){ + add_comment(data); + } +} diff --git a/pagure/templates/pull_request.html b/pagure/templates/pull_request.html index 581883e..910a139 100644 --- a/pagure/templates/pull_request.html +++ b/pagure/templates/pull_request.html @@ -273,13 +273,14 @@ {% if pull_request and pull_request.comments%} -
+
{% for comment in pull_request.discussion %} {% if not comment.commit_id %} - {{ show_comment(comment, loop.index, repo, username, requestid, form, repo_admin) }} + {{ show_comment(comment, loop.index, repo, username, + requestid, form, repo_admin) }} {% endif %} {% endfor %} {{ mergeform.csrf_token }} @@ -516,14 +517,7 @@ function try_async_comment(form) { .done(function(data) { if(data == 'ok') { // We have submitted the comment correctly - var comment_fld = $(form).find("#comment")[0]; - var comment = comment_fld.value; - var comment_view = "" + - ""; - $(form).closest('tr').before($(comment_view)).remove(); + $(form).remove(); } else { // Make the browser submit the form sync $(form).off('submit'); @@ -540,5 +534,31 @@ function try_async_comment(form) { {% endif %} + + +{% if config['EVENTSOURCE_SOURCE'] %} + + + +{% endif %} + {% endblock %}
" + - "{{ g.fas_user.username }}" + - "Now

" + - comment + "