Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Помещает форму ответа на один уровень с комментариями #1225

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions frontend/html/posts/show/battle.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,20 +108,17 @@

{% if comments %}
{% if post.is_commentable and me %}
<reply-container
<reply-form
:reply-to="replyTo"
comment-order="{{ comment_order }}"
avatar-url="{{ me.get_avatar }}"
username="{{ me.full_name }}"
create-comment-url="{% url "create_comment" post.slug %}"
>
></reply-form>
{% endif %}
<div class="post-comments-list">
{% include "comments/list.html" with comments=comments reply_form=reply_form type="battle" %}
</div>
{% if post.is_commentable and me %}
</reply-container>
{% endif %}
{% endif %}

{% if me and me.is_active_membership and post.is_commentable and post.is_visible or me.is_moderator %}
Expand Down
8 changes: 2 additions & 6 deletions frontend/html/posts/show/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,22 +77,18 @@

{% if comments %}
{% if post.is_commentable and me %}
<reply-container
<reply-form
:reply-to="replyTo"
comment-order="{{ comment_order }}"
avatar-url="{{ me.get_avatar }}"
username="{{ me.full_name }}"
create-comment-url="{% url "create_comment" post.slug %}"
>
></reply-form>
{% endif %}

<div class="post-comments-list">
{% include "comments/list.html" with comments=comments reply_form=reply_form type="normal" muted_user_ids=muted_user_ids %}
</div>

{% if post.is_commentable and me %}
</reply-container>
{% endif %}
{% endif %}

{% if me and me.is_active_membership and post.is_commentable and post.is_visible or me.is_moderator %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

<script>
export default {
name: 'ReplyContainer',
name: 'ReplyForm',
props: {
// type { commentId: string, username: string, draftKey?: string }
replyTo: {
Expand Down Expand Up @@ -82,8 +82,8 @@ export default {
updated: function() {
if (this.replyTo !== null && this.getEditor()) {
// move the reply form under the comment
const replyForm = this.$el.querySelector("#comment-reply-form")
const newCommentEl = this.$el.querySelector(`#comment-${this.replyTo.commentId}`)
const replyForm = document.getElementById("comment-reply-form")
const newCommentEl = document.getElementById(`comment-${this.replyTo.commentId}`)
newCommentEl.after(replyForm)
const editor = this.getEditor()
const draftKey = getDraftKey(this.replyTo)
Expand All @@ -110,7 +110,7 @@ export default {
},
methods: {
appendMarkdownTextareaValue: function(value) {
const textarea = this.$el.querySelector("#comment-reply-form textarea")
const textarea = document.querySelector("#comment-reply-form textarea")
textarea.focus(); // on mobile
textarea.value = textarea.value + value;
Expand All @@ -128,7 +128,7 @@ export default {
},
getEditor: function() {
if (!this.editor) {
const textarea = this.$el.querySelector("#comment-reply-form textarea")
const textarea = document.querySelector("#comment-reply-form textarea")
textarea.focus(); // on mobile
if (!textarea.nextElementSibling) {
Expand Down
2 changes: 1 addition & 1 deletion frontend/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Vue.component("comment-markdown-editor", () => import("./components/CommentMarkd
Vue.component("v-select", vSelect);
Vue.component("tag-select", () => import("./components/TagSelect.vue"));
Vue.component("simple-select", () => import("./components/SimpleSelect.vue"));
Vue.component("reply-container", () => import("./components/ReplyContainer.vue"));
Vue.component("reply-form", () => import("./components/ReplyForm.vue"));

// Since our pages have user-generated content, any fool can insert "{{" on the page and break it.
// We have no other choice but to completely turn off template matching and leave it on only for components.
Expand Down
Loading