add: questions timelines
This commit is contained in:
parent
5d53ceb09c
commit
063e33899e
22 changed files with 407 additions and 90 deletions
|
@ -20,60 +20,11 @@
|
|||
<div class="card tertiary flex flex-col gap-4">
|
||||
<!-- prettier-ignore -->
|
||||
{% for question in feed %}
|
||||
<div class="card-nest">
|
||||
{{ components::question(question=question[0], owner=question[1],
|
||||
show_community=false) }}
|
||||
{{ components::global_question(question=question, can_manage_questions=can_manage_questions) }}
|
||||
{% endfor %}
|
||||
|
||||
<div class="card flex flex-wrap gap-2">
|
||||
<a
|
||||
href="/question/{{ question[0].id }}"
|
||||
class="button quaternary small"
|
||||
>
|
||||
{{ icon "external-link" }} {% if user %}
|
||||
<span>{{ text "requests:label.answer" }}</span>
|
||||
{% else %}
|
||||
<span>{{ text "general:action.open" }}</span>
|
||||
{% endif %}
|
||||
</a>
|
||||
|
||||
{% if user %} {% if can_manage_questions or is_helper or
|
||||
question[1].id == user.id %}
|
||||
<button
|
||||
class="quaternary small red"
|
||||
onclick="remove_question('{{ question[0].id }}')"
|
||||
>
|
||||
{{ icon "trash" }}
|
||||
<span>{{ text "general:action.delete" }}</span>
|
||||
</button>
|
||||
{% endif %} {% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %} {{ components::pagination(page=page, items=feed|length)
|
||||
}}
|
||||
{{ components::pagination(page=page, items=feed|length) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
async function remove_question(id) {
|
||||
if (
|
||||
!(await trigger("atto::confirm", [
|
||||
"Are you sure you want to do this?",
|
||||
]))
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
fetch(`/api/v1/questions/${id}`, {
|
||||
method: "DELETE",
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then((res) => {
|
||||
trigger("atto::toast", [
|
||||
res.ok ? "success" : "error",
|
||||
res.message,
|
||||
]);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
|
|
@ -698,4 +698,36 @@ is_global=false) -%}
|
|||
});
|
||||
}
|
||||
</script>
|
||||
{%- endmacro %} {% macro global_question(question, can_manage_questions=false,
|
||||
secondary=false) -%}
|
||||
<div class="card-nest">
|
||||
{{ components::question(question=question[0], owner=question[1],
|
||||
show_community=false) }}
|
||||
|
||||
<div
|
||||
class="card flex flex-wrap gap-2{% if secondary %} secondary{% endif %}"
|
||||
>
|
||||
<a
|
||||
href="/question/{{ question[0].id }}"
|
||||
class="button quaternary small"
|
||||
>
|
||||
{{ icon "external-link" }} {% if user %}
|
||||
<span>{{ text "requests:label.answer" }}</span>
|
||||
{% else %}
|
||||
<span>{{ text "general:action.open" }}</span>
|
||||
{% endif %}
|
||||
</a>
|
||||
|
||||
{% if user %} {% if can_manage_questions or is_helper or question[1].id
|
||||
== user.id %}
|
||||
<button
|
||||
class="quaternary small red"
|
||||
onclick="trigger('me::remove_question', ['{{ question[0].id }}'])"
|
||||
>
|
||||
{{ icon "trash" }}
|
||||
<span>{{ text "general:action.delete" }}</span>
|
||||
</button>
|
||||
{% endif %} {% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{%- endmacro %}
|
||||
|
|
|
@ -185,8 +185,24 @@
|
|||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{%- endmacro %} {% macro community_nav(community, selected="") -%} {% if
|
||||
community.context.enable_questions %}
|
||||
{%- endmacro %} {% macro timelines_secondary_nav(posts="", questions="",
|
||||
selected="posts") -%} {% if user %}
|
||||
<div class="pillmenu w-full">
|
||||
<a href="{{ posts }}" class="{% if selected == 'posts' %}active{% endif %}">
|
||||
{{ icon "newspaper" }}
|
||||
<span>{{ text "communities:label.posts" }}</span>
|
||||
</a>
|
||||
|
||||
<a
|
||||
href="{{ questions }}"
|
||||
class="{% if selected == 'questions' %}active{% endif %}"
|
||||
>
|
||||
{{ icon "message-circle-heart" }}
|
||||
<span>{{ text "communities:label.questions" }}</span>
|
||||
</a>
|
||||
</div>
|
||||
{% endif %} {%- endmacro %} {% macro community_nav(community, selected="") -%}
|
||||
{% if community.context.enable_questions %}
|
||||
<div class="pillmenu">
|
||||
<a
|
||||
href="/community/{{ community.title }}"
|
||||
|
|
|
@ -69,7 +69,7 @@
|
|||
|
||||
<div class="flex gap-2">
|
||||
<button class="primary">{{ text "requests:label.answer" }}</button>
|
||||
<button class="red quaternary" onclick="remove_question('{{ question[0].id }}')">{{ text "general:action.delete" }}</button>
|
||||
<button class="red quaternary" onclick="trigger('me::remove_question', ['{{ question[0].id }}'])">{{ text "general:action.delete" }}</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
@ -121,27 +121,6 @@
|
|||
});
|
||||
}
|
||||
|
||||
async function remove_question(id) {
|
||||
if (
|
||||
!(await trigger("atto::confirm", [
|
||||
"Are you sure you want to do this?",
|
||||
]))
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
fetch(`/api/v1/questions/${id}`, {
|
||||
method: "DELETE",
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then((res) => {
|
||||
trigger("atto::toast", [
|
||||
res.ok ? "success" : "error",
|
||||
res.message,
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
async function answer_question_from_form(e, answering) {
|
||||
e.preventDefault();
|
||||
await trigger("atto::debounce", ["posts::create"]);
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
<title>Latest posts - {{ config.name }}</title>
|
||||
{% endblock %} {% block body %} {{ macros::nav() }}
|
||||
<main class="flex flex-col gap-2">
|
||||
{{ macros::timelines_nav(selected="all") }}
|
||||
{{ macros::timelines_nav(selected="all") }} {{
|
||||
macros::timelines_secondary_nav(posts="/all", questions="/all/questions") }}
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
<div class="card w-full flex flex-col gap-2">
|
||||
|
|
18
crates/app/src/public/html/timelines/all_questions.html
Normal file
18
crates/app/src/public/html/timelines/all_questions.html
Normal file
|
@ -0,0 +1,18 @@
|
|||
{% extends "root.html" %} {% block head %}
|
||||
<title>Latest questions - {{ config.name }}</title>
|
||||
{% endblock %} {% block body %} {{ macros::nav() }}
|
||||
<main class="flex flex-col gap-2">
|
||||
{{ macros::timelines_nav(selected="all") }} {{
|
||||
macros::timelines_secondary_nav(posts="/all", questions="/all/questions",
|
||||
selected="questions") }}
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
<div class="card w-full flex flex-col gap-2">
|
||||
{% for question in list %}
|
||||
{{ components::global_question(question=question, can_manage_questions=false, secondary=true) }}
|
||||
{% endfor %}
|
||||
|
||||
{{ components::pagination(page=page, items=list|length) }}
|
||||
</div>
|
||||
</main>
|
||||
{% endblock %}
|
|
@ -2,7 +2,9 @@
|
|||
<title>Following - {{ config.name }}</title>
|
||||
{% endblock %} {% block body %} {{ macros::nav() }}
|
||||
<main class="flex flex-col gap-2">
|
||||
{{ macros::timelines_nav(selected="following") }}
|
||||
{{ macros::timelines_nav(selected="following") }} {{
|
||||
macros::timelines_secondary_nav(posts="/following",
|
||||
questions="/following/questions") }}
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
<div class="card w-full flex flex-col gap-2">
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
{% extends "root.html" %} {% block head %}
|
||||
<title>Following (questions) - {{ config.name }}</title>
|
||||
{% endblock %} {% block body %} {{ macros::nav() }}
|
||||
<main class="flex flex-col gap-2">
|
||||
{{ macros::timelines_nav(selected="following") }} {{
|
||||
macros::timelines_secondary_nav(posts="/following",
|
||||
questions="/following/questions", selected="questions") }}
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
<div class="card w-full flex flex-col gap-2">
|
||||
{% for question in list %}
|
||||
{{ components::global_question(question=question, can_manage_questions=false, secondary=true) }}
|
||||
{% endfor %}
|
||||
|
||||
{{ components::pagination(page=page, items=list|length) }}
|
||||
</div>
|
||||
</main>
|
||||
{% endblock %}
|
|
@ -3,7 +3,8 @@
|
|||
{% endblock %} {% block body %} {{ macros::nav(selected="home") }}
|
||||
<main class="flex flex-col gap-2">
|
||||
<!-- prettier-ignore -->
|
||||
{{ macros::timelines_nav(selected="home") }}
|
||||
{{ macros::timelines_nav(selected="home") }} {{
|
||||
macros::timelines_secondary_nav(posts="/", questions="/questions") }}
|
||||
|
||||
{% if list|length == 0 and page == 0 %}
|
||||
<div class="card-nest">
|
||||
|
|
18
crates/app/src/public/html/timelines/home_questions.html
Normal file
18
crates/app/src/public/html/timelines/home_questions.html
Normal file
|
@ -0,0 +1,18 @@
|
|||
{% extends "root.html" %} {% block head %}
|
||||
<title>From my communities (questions) - {{ config.name }}</title>
|
||||
{% endblock %} {% block body %} {{ macros::nav() }}
|
||||
<main class="flex flex-col gap-2">
|
||||
{{ macros::timelines_nav(selected="home") }} {{
|
||||
macros::timelines_secondary_nav(posts="/", questions="/questions",
|
||||
selected="questions") }}
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
<div class="card w-full flex flex-col gap-2">
|
||||
{% for question in list %}
|
||||
{{ components::global_question(question=question, can_manage_questions=false, secondary=true) }}
|
||||
{% endfor %}
|
||||
|
||||
{{ components::pagination(page=page, items=list|length) }}
|
||||
</div>
|
||||
</main>
|
||||
{% endblock %}
|
|
@ -193,6 +193,27 @@
|
|||
});
|
||||
});
|
||||
|
||||
self.define("remove_question", async (_, id) => {
|
||||
if (
|
||||
!(await trigger("atto::confirm", [
|
||||
"Are you sure you want to do this?",
|
||||
]))
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
fetch(`/api/v1/questions/${id}`, {
|
||||
method: "DELETE",
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then((res) => {
|
||||
trigger("atto::toast", [
|
||||
res.ok ? "success" : "error",
|
||||
res.message,
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
// token switcher
|
||||
self.define(
|
||||
"set_login_account_tokens",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue