#3981 Fix rendering comment added via JS (ajax or SSE)
Merged 5 years ago by pingou. Opened 5 years ago by pingou.

file modified
+16 -16
@@ -33,24 +33,22 @@ 

  

    } else {

      var _csrf = $('#csrf_token').clone();

-     var _data ='<div class="card clearfix">'

-     + '  <div class="card-header bg-light d-flex align-items-center px-3 py-2">'

+     var _data =

+       '<div class="card mb-4 clearfix">'

+     + '  <div id="comment-' + data.comment_id + '" class="card-header bg-light d-flex align-items-center px-3 py-2">'

      + '    <div>'

-     + '      <div id="comment-' + data.comment_id + '">'

-     + '        <img class="avatar circle" src="' + data.avatar_url + '"/>'

-     + '        <a href="/user/' + data.comment_user + '"'

-     + '            class="notblue font-weight-bold">'+data.comment_user+'</a>'

-     + '        commented'

-     + '        <a class="notblue" title="Permalink to this headline"'

-     + '           href="#comment-' + data.comment_id + '">'

-     + '          <span> seconds ago</span>'

-     + '        </a>'

-     + '      </div>'

+     + '      <img class="avatar circle" src="' + data.avatar_url + '"/>'

+     + '      <a href="/user/' + data.comment_user + '"'

+     + '        class="notblue font-weight-bold">'+data.comment_user+'</a>'

+     + '      <a class="notblue" title="Permalink to this headline"'

+     + '          href="#comment-' + data.comment_id + '">'

+     + '        <span>commented seconds ago</span>'

+     + '      </a>'

      + '    </div>';

  

      if ( data.comment_user == username && data.comment_id !== 'undefined') {

          _data = _data

-     + '    <div class="mr-auto">'

+     + '    <div class="issue_actions ml-auto">'

      + '      <a href="/' + data.project + '/pull-request/' + data.request_id + '/comment/' + data.comment_id + '/edit"'

      + '         class="btn btn-outline-primary border-0" data-comment="' + data.comment_id + '" data-objid="' + data.request_id + '">'

      + '        <i class="fa fa-pencil"  title="Edit comment"></i>'
@@ -64,11 +62,13 @@ 

  

      _data = _data

      + '  </div>'

-     + '  <div class="card-block">'

-     + '    <small></small>'

+     + '  <div class="card-body pb-1">'

      + '    <section class="issue_comment">'

-     + '      <div class="comment_body">'

+     + '      <div>'

+     + '        <span class="edit_date" title=""></span>'

+     + '        <span class="comment_text comment_body">'

      + emojione.toImage(data.comment_added)

+     + '        </span>'

      + '      </div>'

      + '    </section>'

      + '  </div>'

@@ -378,14 +378,14 @@ 

      <div class="row">

      <div class="col-md-8">

      {{ show_pr_initial_comment(pull_request, repo, form, username) }}

-     <section class="request_comment" id="request_comment">

+     <section class="request_comment" >

      {% if pull_request.comments %}

        <form action="{{ url_for('ui_ns.pull_request_drop_comment',

              repo=repo.name,

              username=username,

              namespace=repo.namespace,

              requestid=requestid)

-           }}" method="post"

+           }}" method="post" id="request_comment"

            onsubmit="return try_async_comment(this, null)">

  

        {% for comment in pull_request.comments %}

Basically the HTML generated in the JS wasn't in synced with the html
used by the regular templates.
This commit fixes that.

Fixes https://pagure.io/pagure/issue/3938

Signed-off-by: Pierre-Yves Chibon pingou@pingoured.fr

rebased onto a16bede

5 years ago

Pull-Request has been merged by pingou

5 years ago