add: ability to edit community title through ui

add: finish README
This commit is contained in:
trisua 2025-04-02 18:44:31 -04:00
parent 7c9d5de535
commit 53cf75b53c
11 changed files with 203 additions and 55 deletions

View file

@ -98,6 +98,36 @@
</select>
</div>
</div>
<div class="card-nest" ui_ident="change_title">
<div class="card small">
<b>{{ text "communities:label.change_title" }}</b>
</div>
<form
class="card flex flex-col gap-2"
onsubmit="change_title(event)"
>
<div class="flex flex-col gap-1">
<label for="new_title"
>{{ text "communities:label.new_title" }}</label
>
<input
type="text"
name="new_title"
id="new_title"
placeholder="new_title"
required
minlength="2"
/>
</div>
<button class="primary">
{{ icon "check" }}
<span>{{ text "general:action.save" }}</span>
</button>
</form>
</div>
</div>
<div class="card-nest" ui_ident="danger_zone">
@ -412,6 +442,35 @@
});
};
globalThis.change_title = async (e) => {
e.preventDefault();
if (
!(await trigger("atto::confirm", [
"Are you sure you would like to do this?",
]))
) {
return;
}
fetch("/api/v1/communities/{{ community.id }}/title", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
title: e.target.new_title.value,
}),
})
.then((res) => res.json())
.then((res) => {
trigger("atto::toast", [
res.ok ? "success" : "error",
res.message,
]);
});
};
globalThis.delete_community = async () => {
if (
!(await trigger("atto::confirm", [
@ -437,6 +496,7 @@
"read_access",
"join_access",
"write_access",
"change_title",
"change_avatar",
"change_banner",
]);

View file

@ -88,6 +88,22 @@ community %}
<span>{{ dislikes }}</span>
{% endif %}
</button>
{%- endmacro %} {% macro full_username(user) -%}
<div class="flex">
<a href="/@{{ user.username }}" class="flush" style="font-weight: 600">
{{ components::username(user=user) }}
</a>
{{ components::online_indicator(user=user) }} {% if user.is_verified %}
<span
title="Verified"
style="color: var(--color-primary)"
class="flex items-center"
>
{{ icon "badge-check" }}
</span>
{% endif %}
</div>
{%- endmacro %} {% macro post(post, owner, secondary=false, community=false,
show_community=true) -%} {% if community and show_community %}
<div class="card-nest">
@ -113,13 +129,7 @@ show_community=true) -%} {% if community and show_community %}
<div class="flex flex-col w-full gap-1">
<div class="flex flex-wrap gap-2 items-center">
<div class="flex">
<a href="/@{{ owner.username }}"
>{{ components::username(user=owner) }}</a
>
{{ components::online_indicator(user=owner) }}
</div>
{{ components::full_username(user=owner) }}
<span class="fade date">{{ post.created }}</span>

View file

@ -75,11 +75,6 @@ show_lhs=true) -%}
<span>{{ text "auth:link.settings" }}</span>
</a>
<a href="https://github.com/trisuaso/tetratto">
{{ icon "code" }}
<span>{{ text "general:link.source_code" }}</span>
</a>
{% if is_helper %}
<b class="title">{{ text "general:label.mod" }}</b>
@ -94,6 +89,18 @@ show_lhs=true) -%}
</a>
{% endif %}
<b class="title">{{ config.name }}</b>
<a href="https://github.com/trisuaso/tetratto">
{{ icon "code" }}
<span>{{ text "general:link.source_code" }}</span>
</a>
<a href="https://trisuaso.github.io/tetratto">
{{ icon "book" }}
<span>{{ text "general:link.reference" }}</span>
</a>
<div class="title"></div>
<button class="red" onclick="trigger('me::logout')">
{{ icon "log-out" }}

View file

@ -121,7 +121,7 @@
<!-- dialogs -->
<dialog id="link_filter">
<div class="inner">
<div class="inner flex flex-col gap-2">
<p>Pressing continue will bring you to the following URL:</p>
<pre><code id="link_filter_url"></code></pre>
<p>Are sure you want to go there?</p>
@ -135,14 +135,16 @@
target="_blank"
onclick="document.getElementById('link_filter').close()"
>
{{ text "dialog:action.continue" }}
{{ icon "external-link" }}
<span>{{ text "dialog:action.continue" }}</span>
</a>
<button
class="secondary"
type="button"
onclick="document.getElementById('link_filter').close()"
>
{{ text "dialog:action.cancel" }}
{{ icon "x" }}
<span>{{ text "dialog:action.cancel" }}</span>
</button>
</div>
</div>