add: forum threads ui
This commit is contained in:
parent
155fe34c6e
commit
3958d5eaef
8 changed files with 260 additions and 15 deletions
|
@ -201,7 +201,7 @@
|
|||
(text "{%- endif %}")
|
||||
(text "{%- endmacro %}")
|
||||
|
||||
(text "{% macro post_buttons_box(post, community, owner, can_manage_post) -%}")
|
||||
(text "{% macro post_buttons_box(post, community, owner, can_manage_post, show_comments=true) -%}")
|
||||
(div
|
||||
("class" "flex justify_between items_center gap_2 w_full")
|
||||
(text "{% if user -%}")
|
||||
|
@ -220,7 +220,7 @@
|
|||
(text "{%- endif %}")
|
||||
(div
|
||||
("class" "flex gap_1 buttons_box")
|
||||
(text "{% if post.context.comments_enabled %}")
|
||||
(text "{% if show_comments and post.context.comments_enabled %}")
|
||||
(a
|
||||
("href" "/post/{{ post.id }}")
|
||||
("class" "button camo small")
|
||||
|
@ -526,7 +526,7 @@
|
|||
(text "{{ text \"general:action.delete\" }}"))))))
|
||||
(text "{%- endmacro %}")
|
||||
|
||||
(text "{% macro forum_post(post, owner, community, can_manage_post, poll=false) -%}")
|
||||
(text "{% macro forum_post(post, owner, community, can_manage_post, poll=false, show_show_thread=true) -%}")
|
||||
(div
|
||||
("class" "card_nest_horizontal_wrapper post post:{{ post.id }}")
|
||||
("data-community" "{{ post.community }}")
|
||||
|
@ -580,7 +580,32 @@
|
|||
(text "{% if poll -%} {{ self::poll(post=post, poll=poll) }} {%- endif %}"))
|
||||
|
||||
(hr ("class" "margin_top"))
|
||||
(text "{{ self::post_buttons_box(post=post, community=community, owner=owner, can_manage_post=can_manage_post) }}"))))
|
||||
(text "{{ self::post_buttons_box(post=post, community=community, owner=owner, can_manage_post=can_manage_post, show_comments=false) }}"))))
|
||||
|
||||
; show thread
|
||||
(text "{% if show_show_thread and post.comment_count > 0 -%}")
|
||||
(div
|
||||
("class" "flex gap_2")
|
||||
(text "{% if post.context.comments_enabled %}")
|
||||
(a
|
||||
("href" "/post/{{ post.id }}")
|
||||
("class" "button lowered")
|
||||
(icon (text "message-circle"))
|
||||
(span
|
||||
(text "{{ post.comment_count }}")))
|
||||
(text "{% endif %}")
|
||||
|
||||
(button
|
||||
("class" "lowered")
|
||||
("onclick" "globalThis.continue_thread(event.target, '{{ post.id }}', 'replies_{{ post.id }}', 0)")
|
||||
(icon (text "chevron-down"))
|
||||
(str (text "general:action.show_thread"))))
|
||||
(text "{%- endif %}")
|
||||
|
||||
; replies
|
||||
(div
|
||||
("class" "flex flex_col gap_2 hidden thread")
|
||||
("id" "replies_{{ post.id }}"))
|
||||
(text "{%- endmacro %}")
|
||||
|
||||
(text "{% macro user_card(user) -%}")
|
||||
|
|
24
crates/app/src/public/html/post/forum_quick_replies.lisp
Normal file
24
crates/app/src/public/html/post/forum_quick_replies.lisp
Normal file
|
@ -0,0 +1,24 @@
|
|||
(text "{%- import \"components.html\" as components -%} {%- import \"macros.html\" as macros -%}")
|
||||
|
||||
(div
|
||||
("class" "flex flex_col gap_2")
|
||||
("id" "replies_{{ post.id }}_{{ page }}")
|
||||
; replies
|
||||
(text "{% for post in replies -%}")
|
||||
(div
|
||||
("style" "display: contents")
|
||||
(text "{{ components::forum_post(post=post[0], owner=post[1], community=community, can_manage_post=can_manage_posts, poll=post[4]) }}"))
|
||||
(text "{%- endfor %}")
|
||||
|
||||
; load more button
|
||||
(text "{% set len = replies|length %}")
|
||||
(text "{% if len != 0 and (page * 12) + len != post.comment_count -%}")
|
||||
(div
|
||||
(button
|
||||
("class" "lowered")
|
||||
("onclick" "globalThis.continue_thread(event.target, '{{ post.id }}', 'replies_{{ post.id }}', {{ page + 1 }})")
|
||||
(icon (text "chevron-down"))
|
||||
(str (text "general:action.load_more"))))
|
||||
(text "{% else %}")
|
||||
(div ("class" "squig"))
|
||||
(text "{%- endif %}"))
|
|
@ -56,7 +56,7 @@
|
|||
(text "{% else %}")
|
||||
(div
|
||||
("style" "display: contents")
|
||||
(text "{{ components::forum_post(post=post, owner=owner, community=community, can_manage_post=can_manage_posts, poll=poll) }}"))
|
||||
(text "{{ components::forum_post(post=post, owner=owner, community=community, can_manage_post=can_manage_posts, poll=poll, show_show_thread=false) }}"))
|
||||
(text "{%- endif %}")
|
||||
; ...
|
||||
(text "{% if user and post.context.comments_enabled -%}")
|
||||
|
@ -332,7 +332,24 @@
|
|||
(text "{%- endif %} {% endfor %} {{ components::pagination(page=page, items=replies|length) }}"))))
|
||||
|
||||
(script
|
||||
(text "async function create_reply_from_form(e) {
|
||||
(text "globalThis.continue_thread = async (target, post_id, id, page = 0) => {
|
||||
const btn_id = `tmp_${window.crypto.randomUUID()}`;
|
||||
target.setAttribute(\"disabled\", \"true\");
|
||||
target.id = btn_id;
|
||||
|
||||
document.getElementById(id).innerHTML +=
|
||||
await (await fetch(`/post/${post_id}/_quick_replies?page=${page}`)).text();
|
||||
document.getElementById(id).classList.remove(\"hidden\");
|
||||
|
||||
await trigger(\"atto::clean_date_codes\");
|
||||
await trigger(\"atto::link_filter\");
|
||||
await trigger(\"atto::hooks::check_reactions\");
|
||||
await trigger(\"atto::hooks::online_indicator\");
|
||||
|
||||
document.getElementById(btn_id).parentElement.remove();
|
||||
}
|
||||
|
||||
async function create_reply_from_form(e) {
|
||||
e.preventDefault();
|
||||
await trigger(\"atto::debounce\", [\"posts::create\"]);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue