add: post warnings
This commit is contained in:
parent
24cf61c783
commit
71d017693c
8 changed files with 151 additions and 12 deletions
|
@ -65,6 +65,15 @@
|
|||
{{ components::emoji_picker(element_id="content",
|
||||
render_dialog=true) }}
|
||||
|
||||
<button
|
||||
class="small square quaternary"
|
||||
title="More options"
|
||||
onclick="document.getElementById('post_options_dialog').showModal()"
|
||||
type="button"
|
||||
>
|
||||
{{ icon "ellipsis" }}
|
||||
</button>
|
||||
|
||||
<button class="primary">
|
||||
{{ text "communities:action.create" }}
|
||||
</button>
|
||||
|
@ -89,13 +98,35 @@
|
|||
}),
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then((res) => {
|
||||
.then(async (res) => {
|
||||
trigger("atto::toast", [
|
||||
res.ok ? "success" : "error",
|
||||
res.message,
|
||||
]);
|
||||
|
||||
if (res.ok) {
|
||||
// update settings
|
||||
if (
|
||||
JSON.stringify(
|
||||
window.POST_INITIAL_SETTINGS,
|
||||
) !== window.BLANK_INITIAL_SETTINGS
|
||||
) {
|
||||
await fetch(
|
||||
`/api/v1/posts/${res.payload}/context`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type":
|
||||
"application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
context:
|
||||
window.POST_INITIAL_SETTINGS,
|
||||
}),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
window.location.href = `/post/${res.payload}`;
|
||||
}, 100);
|
||||
|
@ -137,4 +168,85 @@
|
|||
window.history.back();
|
||||
}
|
||||
</script>
|
||||
|
||||
<dialog id="post_options_dialog">
|
||||
<div class="inner flex flex-col gap-2">
|
||||
<div id="post_options" class="flex flex-col gap-2"></div>
|
||||
|
||||
<hr />
|
||||
|
||||
<div class="flex justify-between">
|
||||
<div></div>
|
||||
|
||||
<div class="flex gap-2">
|
||||
<button
|
||||
class="bold red quaternary"
|
||||
onclick="document.getElementById('post_options_dialog').close()"
|
||||
type="button"
|
||||
>
|
||||
{{ icon "x" }} {{ text "dialog:action.close" }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
setTimeout(() => {
|
||||
window.POST_INITIAL_SETTINGS = {
|
||||
comments_enabled: true,
|
||||
reposts_enabled: true,
|
||||
reactions_enabled: true,
|
||||
is_nsfw: false,
|
||||
content_warning: "",
|
||||
};
|
||||
|
||||
window.BLANK_INITIAL_SETTINGS = JSON.stringify(
|
||||
window.POST_INITIAL_SETTINGS,
|
||||
);
|
||||
|
||||
const settings_fields = [
|
||||
[
|
||||
[
|
||||
"comments_enabled",
|
||||
"Allow people to comment on your post",
|
||||
],
|
||||
window.POST_INITIAL_SETTINGS.comments_enabled.toString(),
|
||||
"checkbox",
|
||||
],
|
||||
[
|
||||
[
|
||||
"reposts_enabled",
|
||||
"Allow people to repost/quote your post",
|
||||
],
|
||||
window.POST_INITIAL_SETTINGS.reposts_enabled.toString(),
|
||||
"checkbox",
|
||||
],
|
||||
[
|
||||
[
|
||||
"reactions_enabled",
|
||||
"Allow people to like/dislike your post",
|
||||
],
|
||||
window.POST_INITIAL_SETTINGS.reactions_enabled.toString(),
|
||||
"checkbox",
|
||||
],
|
||||
[
|
||||
["is_nsfw", "Hide from public timelines"],
|
||||
window.POST_INITIAL_SETTINGS.is_nsfw.toString(),
|
||||
"checkbox",
|
||||
],
|
||||
[
|
||||
["content_warning", "Content warning"],
|
||||
window.POST_INITIAL_SETTINGS.content_warning,
|
||||
"textarea",
|
||||
],
|
||||
];
|
||||
|
||||
trigger("ui::generate_settings_ui", [
|
||||
document.getElementById("post_options"),
|
||||
settings_fields,
|
||||
window.POST_INITIAL_SETTINGS,
|
||||
]);
|
||||
}, 250);
|
||||
</script>
|
||||
</div>
|
||||
</dialog>
|
||||
{% endblock %}
|
||||
|
|
|
@ -227,9 +227,24 @@ and show_community and community.id != config.town_square or question %}
|
|||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% if not post.context.content_warning %}
|
||||
<span id="post-content:{{ post.id }}" class="no_p_margin"
|
||||
>{{ post.content|markdown|safe }}</span
|
||||
>
|
||||
{% else %}
|
||||
<details>
|
||||
<summary
|
||||
class="card flex gap-2 items-center secondary red w-full"
|
||||
>
|
||||
{{ icon "triangle-alert" }}
|
||||
<b>{{ post.context.content_warning }}</b>
|
||||
</summary>
|
||||
|
||||
<span id="post-content:{{ post.id }}" class="no_p_margin"
|
||||
>{{ post.content|markdown|safe }}</span
|
||||
>
|
||||
</details>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -159,10 +159,15 @@
|
|||
"checkbox",
|
||||
],
|
||||
[
|
||||
["is_nsfw", "Mark as NSFW"],
|
||||
["is_nsfw", "Hide from public timelines"],
|
||||
"{{ community.context.is_nsfw }}",
|
||||
"checkbox",
|
||||
],
|
||||
[
|
||||
["content_warning", "Content warning"],
|
||||
settings.content_warning,
|
||||
"textarea",
|
||||
],
|
||||
];
|
||||
|
||||
if (can_manage_pins) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue