fix annotate query

This commit is contained in:
Tuan-Dung Bui 2023-04-17 02:44:48 +07:00
parent c3b7d465b1
commit dfc614ac1e
7 changed files with 70 additions and 51 deletions

View file

@ -98,26 +98,19 @@
</div>
</div>
{% if node.revisions == 1 %}
{% set real_replies = node.count_replies - node.revisions + 1 %}
{% else %}
{% set real_replies = node.count_replies - node.revisions + 2 %}
{% endif %}
{% if real_replies > 1 %}
<a href="javascript:comment_reply({{ node.id }}, {{ object.id }})" class="show_more_reply">
{{ _(' View ') }} {{ real_replies }} {{ _(' replies ') }}
</a>
{% elif real_replies %}
<a href="javascript:comment_reply({{ node.id }}, {{ object.id }})" class="show_more_reply">
{{ _(' View ') }} {{ real_replies }} {{_(' reply ') }}
</a>
{% if node.count_replies > 1 %}
<a href="javascript:comment_get_replies({{ node.id }}, {{ object.id }})" class="show_more_reply"> {{ node.count_replies }} {{
_(' Replies ') }} </a>
{% elif node.count_replies %}
<a href="javascript:comment_get_replies({{ node.id }}, {{ object.id }})" class="show_more_reply"> {{ node.count_replies }} {{
_(' Reply ') }} </a>
{% endif %}
</li>
<ul id="comment-{{ node.id }}-reply" class="reply-comment" hidden></ul>
<ul id="comment-{{ node.id }}-children" class="comments"> </ul>
{% endfor %}
{% if replies - offset > 0 %}
{% if comment_count - offset > 0 %}
<a href="javascript:comment_show_more({{ comment_root_id }}, {{ object.id }}, {{ offset }} )" class="show_more_comment">
{{ _(' View ') }} {{ replies - offset }} {{ _(' comments more ') }}</a>
{{ comment_count - offset }} replies more</a>
{% endif %}

View file

@ -120,8 +120,12 @@
});
}
window.comment_reply = function (id, page) {
ajax_get_reply('{{ url('comment_reply') }}', id, page);
window.comment_get_replies = function (id, page) {
var $comment_show_btn = $("#comment-" + id + " .show_more_reply");
$comment_show_btn.hide();
var $comment = $("#comment-" + id + "-children");
$comment.append("<p class='loading'> Loading... </p>");
ajax_get_reply('{{ url('comment_get_replies') }}', id, page);
}
function ajax_get_reply(url, id, page) {
@ -133,16 +137,26 @@
page: page,
},
success: function(data) {
var $comment_loading = $("#comment-" + id + "-children .loading");
$comment_loading.hide();
var $comment = $("#comment-" + id + "-children");
var $comment_show_btn = $("#comment-" + id + " .show_more_reply");
console.log($comment_show_btn);
$comment_show_btn.hide();
$comment.append(data);
}
})
}
window.comment_show_more = function (id, page, offset) {
if (id == 0) {
var $comment_show_btn = $("#comment-" + id + " .show_more_comment");
$comment_show_btn.hide();
var $comment = $("#comment-" + id);
$comment.append("<p class='loading'> Loading... </p>");
} else {
var $comment_show_btn = $("#comment-" + id + "-children" + " .show_more_comment");
$comment_show_btn.hide();
var $comment = $("#comment-" + id + "-children");
$comment.append("<p class='loading'> Loading... </p>");
}
ajax_comment_show_more('{{ url('comment_show_more') }}', id, page, offset);
}
@ -157,14 +171,14 @@
},
success: function(data) {
if (id == 0) {
var $comment_loading = $("#comment-" + id + " .loading");
$comment_loading.hide();
var $comment = $("#comment-" + id);
var $comment_show_btn = $("#comment-" + id + " .show_more_comment");
$comment_show_btn.hide();
$comment.append(data);
} else {
var $comment_loading = $("#comment-" + id + "-children .loading");
$comment_loading.hide();
var $comment = $("#comment-" + id + "-children");
var $comment_show_btn = $("#comment-" + id + "-children" + " .show_more_comment");
$comment_show_btn.hide();
$comment.append(data);
}
}