Bulk edit tags

This commit is contained in:
Bad Manners 2025-04-20 10:23:51 -03:00
parent 8fac396d7e
commit 94269d82f0
8 changed files with 252 additions and 24 deletions

View file

@ -0,0 +1,37 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bulk edit tag - {{ application_name }}</title>
<meta property="og:site_name" content="{{ application_name }}" />
{% include "fragments/common_headers.html" %}
</head>
<body>
{% if age_confirmation %}{% include "fragments/age_restricted_check.html"
%}{% endif %}
<div><a href="/">&lt; To home</a></div>
<main>
<h1>Bulk edit tag</h1>
<article>
<h2>Select tag to edit</h2>
<form method="post" action="/bulk_edit_tag">
{% let tags_value = "" %} {% include "fragments/tags_input.html" %}
<div
hx-trigger="keyup[key=='Escape'] from:previous .tags"
hx-target="next .tags-autocomplete"
hx-swap="innerHTML"
hx-delete="/remove"
hidden
></div>
<ul class="reset tags-autocomplete" id="search-autocomplete"></ul>
<input type="text" name="new_tag" placeholder="New tag" />
<button type="submit">Submit</button>
{% match message %}{% when BulkEditTagMessage::Success %}
<div>Success!</div>
{% when BulkEditTagMessage::Failure with (msg) %}
<div>Error: {{ msg }}</div>
{% when BulkEditTagMessage::None %}{% endmatch %}
</form>
</article>
</main>
</body>
</html>

View file

@ -41,6 +41,9 @@
<a href="/create_pool">Create pool</a>
</li>
{% if user.is_admin %}
<li>
<a href="/bulk_edit_tag">Bulk edit tag</a>
</li>
<li>
<a href="/settings">Settings</a>
</li>

View file

@ -100,7 +100,11 @@
<ul>
{% for tag in tags %}
<li>
<a href="/posts?tags={{ tag.name }}">{{ tag.name }}</a>
{% if let Some(tags_text) = tags_text %}
<a href="/posts?tags={{ tags_text.replace(' ', "+") }}+{{ tag.name }}">+</a> <a href="/posts?tags={{ tags_text.replace(' ', "+") }}+-{{ tag.name }}">-</a> <a href="/posts?tags={{ tag.name }}">{{ tag.name }}</a>
{% else %}
<a href="/posts?tags={{ tag.name }}">+</a> <a href="/posts?tags=-{{ tag.name }}">-</a> <a href="/posts?tags={{ tag.name }}">{{ tag.name }}</a>
{% endif %}
</li>
{% endfor %}
</ul>